public function addItem($title, $action = null, $class = 'Menu_Advanced_Item') { $i = $this->add($class, null, null, array_merge($this->defaultTemplate(), array('Item'))); /** @type Menu_Advanced_Item $i */ if (is_array($title)) { if ($title['badge']) { /** @type View $v */ $v = $i->add('View', null, 'Badge'); $v->setElement('span')->addClass('atk-label')->set($title['badge']); unset($title['badge']); } } if ($action) { if (is_string($action) || is_array($action) || $action instanceof URL) { $i->template->set('url', $url = $this->app->url($action)); if ($url->isCurrent($this->highlight_subpages)) { $i->addClass('active'); } } else { $i->on('click', $action); } } $i->set($title); return $i; }
public function addMenuItem($label, $href = null) { if (!$href) { $href = $this->getDefaultHref($label); $label = ucwords($label); } $this->items[] = $this->last_item = $this->add('MenuItem', $this->short_name . "_{$href}", 'Item')->setProperty(array('page' => $href, 'href' => $this->app->url($href), 'label' => $label, 'class' => $this->isCurrent($href) ? $this->current_menu_class : $this->inactive_menu_class)); return $this; }
public function isCurrent($href) { // returns true if item being added is current if (!is_object($href)) { $href = str_replace('/', '_', $href); } return $href == $this->app->page || $href == ';' . $this->app->page || $href . $this->app->getConfig('url_postfix', '') == $this->app->page || (string) $href == (string) $this->app->url(); }
/** * Reload object. * * You can bind this to custom event and trigger it if object is not * directly accessible. * If interval is given, then object will periodically reload itself. * * @param array $arg * @param jQuery_Chain $fn * @param string $url * @param int $interval Interval in milisec. how often to reload object * * @return $this */ public function reload($arg = array(), $fn = null, $url = null, $interval = null) { if ($fn && $fn instanceof self) { $fn->_enclose(); } $obj = $this->owner; if ($url === null) { $url = $this->app->url(null, array('cut_object' => $obj->name)); } return $this->univ()->_fn('reload', array($url, $arg, $fn, $interval)); }
public function addMenuItem($page, $label = null) { if (!$label) { $label = ucwords(str_replace('_', ' ', $page)); } /** @type View $li */ $li = $this->add('View'); $li->setElement('li'); /** @type View $a */ $a = $li->add('View'); $a->setElement('a')->set($label); if ($page instanceof jQuery_Chain) { $li->js('click', $page); return $li; } $a->setAttr('href', $this->app->url($page)); if ($this->isCurrent($page) && $this->current_menu_class) { $li->addClass($this->current_menu_class); } return $li; }
protected function getChunks() { // commonly replaceable chunks $this->grabTemplateChunk('form_comment'); $this->grabTemplateChunk('form_separator'); $this->grabTemplateChunk('form_line'); // form line template,must contain field_caption,field_input,field_error if ($this->template->is_set('hidden_form_line')) { $this->grabTemplateChunk('hidden_form_line'); } $this->grabTemplateChunk('field_error'); // template for error code, must contain field_error_str $this->grabTemplateChunk('field_mandatory'); // template for marking mandatory fields // other grabbing will be done by field themselves as you will add them // to the form. They will try to look into this template, and if you // don't have apropriate templates for them, they will use default ones. $this->template_chunks['form'] = $this->template; $this->template_chunks['form']->del('Content'); $this->template_chunks['form']->del('form_buttons'); $this->template_chunks['form']->trySet('form_name', $this->name . '_form'); $this->template_chunks['form']->set('form_action', $this->app->url(null, array('submit' => $this->name))); return $this; }