public function execute($request) { $this->addMenu = QubitMenu::getById(QubitMenu::ADD_EDIT_ID); $this->manageMenu = QubitMenu::getById(QubitMenu::MANAGE_ID); $this->importMenu = QubitMenu::getById(QubitMenu::IMPORT_ID); $this->adminMenu = QubitMenu::getById(QubitMenu::ADMIN_ID); }
public function execute($request) { // Get parent menu $criteria = new Criteria(); $criteria->add(QubitMenu::NAME, 'groups'); $this->groupsMenu = QubitMenu::getOne($criteria); }
public function execute($request) { // Get menu objects $this->mainMenu = QubitMenu::getById(QubitMenu::MAIN_MENU_ID); if (!$this->mainMenu instanceof QubitMenu) { return sfView::NONE; } }
public function execute($request) { // Get menu objects $this->browseMenu = QubitMenu::getById(QubitMenu::BROWSE_ID); if (!$this->browseMenu instanceof QubitMenu) { return sfView::NONE; } }
public function execute($request) { // Get menu objects $this->quickLinksMenu = QubitMenu::getById(QubitMenu::QUICK_LINKS_ID); if (!$this->quickLinksMenu instanceof QubitMenu) { return sfView::NONE; } }
public function execute($request) { // Get menu $criteria = new Criteria(); $criteria->add(QubitMenu::NAME, 'users'); $this->userAclMenu = null; if (null !== ($menu = QubitMenu::getOne($criteria))) { $this->userAclMenu = $menu; } }
public function execute($request) { $this->form = new sfForm(); $this->menu = QubitMenu::getById($request->id); if (!isset($this->menu)) { $this->forward404(); } if ($request->isMethod('delete')) { if (!$this->menu->isProtected()) { $this->menu->delete(); } // Remove cache if ($this->context->getViewCacheManager() !== null) { $this->context->getViewCacheManager()->remove('@sf_cache_partial?module=menu&action=_browseMenu&sf_cache_key=*'); $this->context->getViewCacheManager()->remove('@sf_cache_partial?module=menu&action=_mainMenu&sf_cache_key=*'); } $this->redirect(array('module' => 'menu', 'action' => 'list')); } }
public function execute($request) { // Re-order menus if "move" parameter passed if (isset($request->move) && ($menu = QubitMenu::getById($request->move))) { if (isset($request->before)) { $menu->moveBeforeById($request->before); } else { if (isset($request->after)) { $menu->moveAfterById($request->after); } } // Remove cache if ($this->context->getViewCacheManager() !== null) { $this->context->getViewCacheManager()->remove('@sf_cache_partial?module=menu&action=_browseMenu&sf_cache_key=*'); $this->context->getViewCacheManager()->remove('@sf_cache_partial?module=menu&action=_mainMenu&sf_cache_key=*'); } } // Get an array with menu ids and depth (relative to top menu) to create // and indented list $this->menuTree = QubitMenu::getTreeById(QubitMenu::ROOT_ID); foreach ($this->menuTree as $i => $menu) { // Build an array of siblings for each parentId for figuring out // prev/next buttons $siblingList[$menu['parentId']][] = array('id' => $menu['id'], 'pos' => $i); } // Build prev/next values based on number of siblings foreach ($siblingList as $siblings) { foreach ($siblings as $i => $sibling) { if (0 < $i) { $this->menuTree[$sibling['pos']]['prev'] = $siblings[$i - 1]['id']; } if (count($siblings) - 1 > $i) { $this->menuTree[$sibling['pos']]['next'] = $siblings[$i + 1]['id']; } } } }
<div class="section" id="mainMenu"> <h2 class="element-invisible"><?php echo __('Main menu'); ?> </h2> <div class="content"> <?php echo QubitMenu::displayHierarchyAsList($mainMenu, 0, array('overrideVisibility' => array('admin' => $sf_user->hasCredential('administrator')))); ?> </div> </div>
<div class="browse section"> <h2 class="element-invisible"><?php echo $browseMenu->getLabel(array('cultureFallback' => true)); ?> </h2> <div class="content"> <?php echo QubitMenu::displayHierarchyAsList($browseMenu, 0); ?> </div> </div>
/** * Display a menu hierarchy as a nested XHTML list. * * NOTE: This function is a hack that violates the rules of MVC code/template * separation; unfortunately, this was by far the cleanest method I could devise * for accurately representing a menu heirarchy as a nested XHTML list. * * @param QubitMenu $parent parent menu object for hierarchy branch * @param integer $depth current (relative) depth from top of tree (for styling) * @param array $options optional parameters * @return string an indented, nested XHTML list */ public static function displayHierarchyAsList($parent, $depth = 0, $options = array()) { $li = array(); foreach ($parent->getChildren() as $child) { // Skip this menu and children if marked "hidden" if (isset($options['overrideVisibility'][$child->getName()]) && !$options['overrideVisibility'][$child->getName()]) { continue; } $class = array(); if ($child->isSelected() || $child->isDescendantSelected()) { $class[] = 'active'; } $a = link_to($child->getLabel(array('cultureFallback' => true)), $child->getPath(array('getUrl' => true, 'resolveAlias' => true))); if ($child->hasChildren()) { $a .= self::displayHierarchyAsList($child, $depth + 1, $options); } else { $class[] = 'leaf'; } $class = implode(' ', $class); if (0 < strlen($class)) { $class = ' class="' . $class . '"'; } $id = isset($child->name) ? ' id="node_' . $child->name . '"' : ''; $li[] = '<li' . $class . $id . '>' . $a . '</li>'; } return '<ul class="clearfix links">' . implode($li) . '</ul>'; }
public function execute($request) { $this->form = new sfForm(); $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->menu = new QubitMenu(); if (isset($request->id)) { $this->menu = QubitMenu::getById($request->id); if (!isset($this->menu)) { $this->forward404(); } } foreach ($this::$NAMES as $name) { $this->addField($name); } // Handle POST data (form submit) if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { $this->processForm(); $this->menu->save(); // Remove cache if ($this->context->getViewCacheManager() !== null) { $this->context->getViewCacheManager()->remove('@sf_cache_partial?module=menu&action=_browseMenu&sf_cache_key=*'); $this->context->getViewCacheManager()->remove('@sf_cache_partial?module=menu&action=_mainMenu&sf_cache_key=*'); } $this->redirect(array('module' => 'menu', 'action' => 'list')); } } QubitDescription::addAssets($this->response); }
?> <?php } ?> <?php if ($item['protected']) { ?> <?php echo link_to($item['name'], array(QubitMenu::getById($item['id']), 'module' => 'menu', 'action' => 'edit'), array('class' => 'readOnly', 'title' => __('Edit menu'))); ?> <?php } else { ?> <?php echo link_to($item['name'], array(QubitMenu::getById($item['id']), 'module' => 'menu', 'action' => 'edit'), array('title' => __('Edit menu'))); ?> <?php } ?> </td><td> <?php echo $item['label']; ?> </td> </tr> <?php } ?> </tbody>
public static function getmenusRelatedByparentIdById($id, array $options = array()) { $criteria = new Criteria(); self::addmenusRelatedByparentIdCriteriaById($criteria, $id); return QubitMenu::get($criteria, $options); }