本文整理汇总了PHP中KObject::set方法的典型用法代码示例。如果您正苦于以下问题:PHP KObject::set方法的具体用法?PHP KObject::set怎么用?PHP KObject::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KObject
的用法示例。
在下文中一共展示了KObject::set方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initialize
/**
* Initializes the options for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param array Options
* @return array Options
*/
protected function _initialize(KConfig $options)
{
$name = $this->getName();
$this->attribs = new KObject();
$attribs = array('class' => 'toolbar toolbar-form-validate type:\'' . $this->_method . '\'', 'href' => '#');
if (isset($options->attribs)) {
$attribs = array_merge($attribs, $options->attribs);
}
$this->attribs->set($attribs);
$options->append(array('parent' => null, 'icon' => 'icon-32-' . $name, 'id' => $name, 'text' => ucfirst($name), 'method' => 'get', 'identifier' => null));
parent::_initialize($options);
}
示例2: _parseTemplate
protected function _parseTemplate($xml)
{
$template = new KObject();
foreach ($xml as $name) {
if ($name->name() == 'form') {
$template->set($name->name(), $name);
} else {
$template->set($name->name(), $name->data());
}
}
return $template;
}
示例3: getLink
public function getLink($options = array())
{
$option = $this->_options['option'];
$view = KRequest::get('get.view', 'cmd');
// modify url
$url = clone KRequest::url();
$query = new KObject();
$query->set($url->getquery(1));
//$query['view'] = 'settings';
$query->order = null;
$query->direction = null;
$query->limit = null;
$query->offset = null;
if (isset($query->tmpl)) {
JTML::_('behavior.modal');
}
$this->modal = true;
//$query['layout']= 'default';
$query->set($options);
$url->setQuery($query->get());
return $url;
}
示例4: render
public function render($content = ' ', $title = false, array $module = array(), $attribs = array())
{
/*
KLoader::load('lib.joomla.application.module.helper');
$load =& JModuleHelper::_load();
$load[] = (object) array(
'id' => 50,
'title' => $title,
'module' => 'mod_custom',
'position' => 'above',
'content' => $content,
'showtitle' => 1,
'control' => '',
'params' => '
moduleclass_sfx=-slide red
cache=0
',
'user' => 0,
'name' => 'custom',
//'style' => isset($module['style']) ? $module['style'] : 'rounded',
'style' => 'xhtml'
);
return null;
die('<pre>'.print_r($load, true).'</pre>');
//*/
/*
0 =>
stdClass::__set_state(array(
'id' => '50',
'title' => 'Breadcrumb',
'module' => 'mod_breadcrumbs',
'position' => 'breadcrumb',
'content' => '',
'showtitle' => '0',
'control' => '',
'params' => 'showHome=1
homeText=Home
showLast=1
separator=
moduleclass_sfx=
cache=0
',
'user' => 0,
'name' => 'breadcrumbs',
'style' => NULL,
)),
*/
$tmp = $module;
$module = new KObject();
$module->params = 'moduleclass_sfx=' . @$tmp['moduleclass_sfx'];
$module->module = 'mod_' . $this->_identifier->package . '_' . $this->_identifier->name;
$module->id = KFactory::tmp('lib.koowa.filter.int')->sanitize(uniqid());
$module->title = (string) $title;
$module->style = isset($tmp['style']) ? $tmp['style'] : 'rounded';
$module->position = $this->_identifier->package . '-' . $this->_identifier->name;
$module->showtitle = (bool) $title;
$module->name = $this->_identifier->package . '_' . $this->_identifier->name;
$module->user = 0;
$module->content = $content;
$module->set($tmp);
if (!isset($attribs['name'])) {
$attribs['name'] = $module->position;
}
if (!isset($attribs['style'])) {
$attribs['style'] = $module->style;
}
if (!isset($attribs['first'])) {
$attribs['first'] = null;
}
if (!isset($attribs['last'])) {
$attribs['last'] = null;
}
if (($yoofix = JPATH_THEMES . DS . KFactory::get('lib.joomla.application')->getTemplate() . DS . 'lib' . DS . 'php' . DS . 'template.php') && ($isYoo = file_exists($yoofix))) {
require_once $yoofix;
}
if ($isYoo) {
$attribs['style'] = 'yoo';
}
static $chrome;
$mainframe = JFactory::getApplication();
$scope = $mainframe->scope;
//record the scope
$mainframe->scope = $module->module;
//set scope to Component name
// Get module parameters
$params = new JParameter($module->params);
// Get module path
$module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
$path = JPATH_BASE . DS . 'modules' . DS . $module->module . DS . $module->module . '.php';
// Load the module
if (!$module->user && file_exists($path) && empty($module->content)) {
$lang =& JFactory::getLanguage();
$lang->load($module->module);
$content = '';
ob_start();
require $path;
$module->content = ob_get_contents() . $content;
ob_end_clean();
//.........这里部分代码省略.........
示例5: _instantiateContact
/**
* Instantiate a contact object
*
* @param KConfig $data The request data
*
* @return KObject
*/
protected function _instantiateContact($data)
{
$data->append(array('contact' => new KConfig()));
$contact = new KObject();
$contact->set(array('address' => $data->contact->address, 'city' => $data->contact->city, 'country' => $data->contact->country, 'state' => $data->contact->state, 'zip' => $data->contact->zip));
$this->contact = $contact;
return $contact;
}
示例6: set
/**
* Set the raw value of a property
*
* @param string $name
* @param mixed $value
* @return void;
*/
public function set($name, $value = null)
{
$property = $this->getEntityDescription()->getProperty($name);
if (!$property instanceof AnDomainPropertyAbstract) {
return parent::set($name, $value);
}
//if a value is mixin then get its mixer
if ($value instanceof KMixinAbstract) {
$value = $value->getMixer();
}
$modify = false;
$name = $property->getName();
$context = $this->getRepository()->getCommandContext();
$context['property'] = $property;
$context['value'] = $value;
$context['entity'] = $this;
if ($this->getRepository()->getCommandChain()->run('before.setdata', $context) === false) {
return $this;
}
$value = $context->value;
if ($property->isSerializable()) {
$modify = true;
if ($property->isRelationship() && $property->isManyToOne() && $value) {
if (!is($value, 'AnDomainEntityAbstract', 'AnDomainEntityProxy')) {
throw new AnDomainExceptionType('Value of ' . $property->getName() . ' must be a AnDomainEntityAbstract');
}
//if a relationship is a belongs to then make sure the parent
//is always saved before child
//example if $topic->author = new author
//then save the new author first before saving topic
//only set the dependency
if ($value->getEntityState() == AnDomain::STATE_NEW) {
//save the child before saving the parent
$this->getRepository()->getSpace()->setSaveOrder($value, $this);
}
}
//if value is not null do a composite type checking
if (!is_null($value)) {
if ($property->isAttribute() && !$property->isScalar()) {
if (!is($value, $property->getType())) {
throw new AnDomainEntityException('Value of ' . $property->getName() . ' must be a ' . $property->getType() . '. a ' . get_class($value) . ' is given.');
}
}
}
} elseif ($property->isRelationship() && $property->isOnetoOne()) {
$child = $property->getChildProperty();
$current = $this->get($property->getName());
//if there's a current value and it's existence depends on
//the parent entity then remove the current
if ($current && $child->isRequired()) {
$current->delete();
}
//if a one-to-one relationship then there must be a child key for the property
//then must set the inverse
if ($value) {
$value->set($child->getName(), $this);
}
$this->_data[$property->getName()] = $value;
} elseif ($property->isRelationship() && ($property->isManyToMany() || $property->isOneToMany())) {
$current = $this->get($name);
if ($current instanceof AnDomainDecoratorOnetomany) {
$values = KConfig::unbox($value);
//can be an KObjectArray or KObjectSet object
if ($values instanceof KObject && $values instanceof Iterator) {
$current->delete();
foreach ($values as $value) {
$current->insert($value);
}
}
}
}
//only modify if the current value is differnet than the new value
$modify = $modify && !is_eql($this->get($name), $value);
if ($modify) {
//lets bring them back to their orignal type
if (!is_null($value) && $property->isAttribute() && $property->isScalar()) {
settype($value, $property->getType());
}
if ($this->getEntityState() != AnDomain::STATE_NEW) {
//store the original value for future checking
if (!isset($this->_modified[$name])) {
$this->_modified[$name] = array('old' => $this->get($name));
}
$this->_modified[$name]['new'] = $value;
//check if the new value is the same as the old one then remove the
if (is_eql($this->_modified[$name]['old'], $this->_modified[$name]['new'])) {
//if there are no modified then reset the entity
unset($this->_modified[$name]);
if (count($this->_modified) === 0) {
$this->reset();
}
}
}
//.........这里部分代码省略.........
示例7: _createButton
protected function _createButton($url, $name, $button)
{
$html = array();
$var = KInflector::underscore($button);
$href = new KObject();
$href->set(array_merge($url->get(), array('view' => $var)));
$attr = current((array) $button->attributes());
if ($attr['view'] == KRequest::get('get.view', 'cmd', 'dashboard')) {
return false;
}
$img = isset($attr['img']) ? $attr['img'] : null;
$attr['img'] = null;
if (!empty($attr)) {
$href->set($attr);
}
$html[] = '<div><div class="dashboard-button">';
$html[] = '<a href="' . JRoute::_('index.php?' . http_build_query($href->get())) . '"><img src="' . KFactory::get('admin::com.ninja.helper.default')->img('/48/' . JFile::stripExt(basename($img)) . '.png') . '" alt="' . $button . '"/><span>' . JText::_($button) . '</span></a>';
$html[] = '</div></div>';
return implode($html);
}
示例8: sortables
public function sortables($option = array())
{
$this->sortables = true;
$document = JFactory::getDocument();
KFactory::get('admin::com.ninja.helper.default')->js('/sortables.js');
KFactory::get('admin::com.ninja.helper.default')->css('/sortables.css');
$options = new KObject();
$options->form = KFactory::get('admin::com.ninja.helper.default')->formid();
$options->list = 'tbody.sortable';
$options->handles = 'td.handle';
$options->set((array) $option);
$script = 'window.addEvent(\'domready\', function(){ new NSortables(' . json_encode($options) . '); });';
$document->addScriptDeclaration($script);
}
示例9: usergroup
public function usergroup($value = null, $name = 'usergroup', $options = array(), $control_name = 'f')
{
if (JVersion::isCompatible('1.6.0')) {
return JHtml::_('access.usergroup', $name, $value[$name], 'onchange="this.form.submit()"');
}
$node = new KObject();
$node->size = null;
$node->class = null;
$node->multiple = null;
$node->set($options);
// modify url
$url = clone KRequest::url();
$query = $url->getquery(1);
$acl =& JFactory::getACL();
$acltree = $acl->get_group_children_tree(null, 'USERS', false);
$query['usergroup'] = 0;
$reset = (string) $url->setQuery($query);
$gtree[] = JHTML::_('select.option', '', 'by usergroup');
foreach ($acltree as $i => $tree) {
$tree->text = str_replace(array(' ', '.', '-'), '', $tree->text);
$query['usergroup'] = $tree->value;
if (!in_array($tree->value, array(29, 30))) {
$gtree[] = $tree;
} else {
$gtree[] = JHTML::_('select.optgroup', $tree->text);
}
}
$ctrl = $name;
$attribs = ' onchange="this.form.submit()" ';
if ($v = $node->size) {
$attribs .= 'size="' . $v . '"';
}
if ($v = $node->class) {
$attribs .= 'class="' . $v . '"';
} else {
$attribs .= 'class="inputbox autoredirect"';
}
if ($m = $node->multiple) {
$attribs .= 'multiple="multiple"';
$ctrl .= '[]';
}
return JHTML::_('select.genericlist', $gtree, $ctrl, $attribs, 'value', 'text', @$value['usergroup'], $name);
}