protected function createMenuLinks($includeLevel = 2, $parentLabel = true) { if ($currentItem = $this->menu->getCurrent()) { $links = array(); $childItems = $currentItem->getChildren(); $parameters = $currentItem->getParameters(); $request = $this->getRequest(); $showDisabled = $includeLevel > 99; $menuSource = $this->menu->getParameterSource(); if ($parentItem = $currentItem->getParent()) { // Add only if not toplevel. if ($parentItem instanceof \Gems_Menu_SubMenuItem && $parentItem->has('controller')) { $key = $parentItem->get('controller') . '.' . $parentItem->get('action'); if ($parentLabel) { if (true === $parentLabel) { $parentLabel = $this->_('Cancel'); } $links[$key] = $parentItem->toActionLink($request, $this, $menuSource, $parentLabel); } else { $links[$key] = $parentItem->toActionLink($request, $this, $menuSource); } if ($includeLevel > 1) { $childItems = array_merge($parentItem->getChildren(), $childItems); } } } if ($includeLevel < 1) { return $links; } //The reset parameter blocks the display of buttons, so we unset it unset($parameters['reset']); if ($childItems) { foreach ($childItems as $menuItem) { if ($menuItem !== $currentItem) { // Select only children with the same parameters if ($menuItem->getParameters() == $parameters) { // And buttons only if include level higher than 2. if ($includeLevel > 2 || !$menuItem->get('button_only')) { if ($link = $menuItem->toActionLink($request, $this, $menuSource, $showDisabled)) { $key = $menuItem->get('controller') . '.' . $menuItem->get('action'); $links[$key] = $link; } } } } } } return $links; } }
/** * Creates a reset button for the search form * * @return \Zend_Form_Element_Html or null */ protected function getAutoSearchReset() { if ($menuItem = $this->menu->getCurrent()) { $link = $menuItem->toActionLink($this->request, array('reset' => 1), $this->_('Reset search')); $element = new \MUtil_Form_Element_Html('reset'); $element->setValue($link); return $element; } }
/** * overrule to add your own buttons. * * @return \Gems_Menu_MenuList */ protected function getMenuList() { $links = $this->menu->getMenuList(); $links->addParameterSources($this->request, $this->menu->getParameterSource()); $source = new \Gems_Menu_ParameterSource(array('gro_id_track' => $this->trackId, 'gro_id_round' => $this->trackEngine->getPreviousRoundId($this->roundId))); $links->append($this->menu->getCurrent()->toActionLink(true, \MUtil_Html::raw($this->_('< Previous')), $source)); $links->addCurrentParent($this->_('Cancel')); $links->addCurrentChildren(); $links->addCurrentSiblings(); $source->offsetSet('gro_id_round', $this->trackEngine->getNextRoundId($this->roundId)); $links->append($this->menu->getCurrent()->toActionLink(true, \MUtil_Html::raw($this->_('Next >')), $source)); return $links; }
/** * Adds the siblings (= other children of the parent) of the current menu item to this list * * @param boolean $anyParameters When false, siblings must have the same parameter set as the current menu item * @return \Gems_Menu_MenuList (continuation pattern) */ public function addCurrentSiblings($anyParameters = false, $includeCurrent = false) { if ($current = $this->menu->getCurrent()) { if ($parent = $current->getParent()) { $parameters = $current->getParameters(); if ($includeCurrent) { $current = null; } foreach ($parent->getChildren() as $menuItem) { // Add any menu item that is not the current menu item // and that has the same parameters, unless $anyParameters is true. if ($menuItem !== $current && ($anyParameters || $menuItem->getParameters() == $parameters)) { $this->addMenuItem($menuItem); } } } } return $this; }
/** * Show the upgrades and level for a certain context * * Usage: show/context/<context> */ public function showAction() { $this->html->h3($this->getTopicTitle()); $context = $this->_getParam('id', 'gems'); $this->_upgrades->setContext($context); if ($info = $this->_upgrades->getUpgradesInfo($context)) { $this->html->table(array('class' => 'browser'))->tr()->th($this->_('Context'))->td($info['context'])->tr()->th($this->_('Level'))->td($info['level']); $data = $this->_upgrades->getUpgrades(); foreach ($data as $level => $row) { foreach ($this->menu->getCurrent()->getChildren() as $menuItem) { if ($menuItem->is('allowed', true)) { $show = true; if ($level <= $info['level'] && $menuItem->is('action', 'execute-to')) { //When this level is < current level don't allow to execute from current level to this one $show = false; } if ($level <= $info['level'] && $menuItem->is('action', 'execute-from')) { //When this level is < current level don't allow to execute from current level to this one $show = false; } if ($show) { $row['action'][] = $menuItem->toActionLinkLower($this->getRequest(), $row, array('from' => $level, 'to' => $level)); } } } $row['level'] = $level; $data[$level] = $row; } $displayColumns = array('level' => $this->_('Level'), 'info' => $this->_('Description'), 'action' => $this->_('Action')); $this->addSnippet('SelectiveTableSnippet', 'data', $data, 'class', 'browser', 'columns', $displayColumns); } else { $this->html[] = sprintf($this->_('Context %s not found!'), $context); } if ($parentItem = $this->menu->getCurrent()->getParent()) { $this->html[] = $parentItem->toActionLink($this->getRequest(), $this->_('Cancel')); } }