/** * Convenience method * call $this->renderMenu() in the view to access * the helper * * @access public * @return string */ public function renderSubMenu() { $navigation = App_Backoffice_Navigation::getInstance()->getNavigation(); $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); //Extract the submenu we have to show foreach ($navigation as $tab) { if (isset($tab['main']['active']) && $tab['main']['active']) { $pages = $tab['pages']; break; } } $menu = array(); if (!empty($pages)) { foreach ($pages as $page) { if (isset($page['action'])) { $url = $baseUrl . '/' . $page['controller'] . '/' . $page['action']; } else { $url = $baseUrl . '/' . $page['controller']; } if (isset($page['active']) && $page['active']) { $li = sprintf($this->_linkSelectedTemplate, $url, $page['label']); } else { $li = sprintf($this->_linkTemplate, $url, $page['label']); } $menu[] = $li; } } $xhtml = '<ul class="prefix_1 clearfix">' . PHP_EOL . implode(PHP_EOL, $menu) . PHP_EOL . '</ul>'; return $xhtml; }
/** * Returns a singleton instance of the class * * @access public * @return void */ public function getInstance() { if (NULL === self::$_instance) { self::$_instance = new App_Backoffice_Navigation(); } return self::$_instance; }
/** * Convenience method * call $this->renderMenu() in the view to access * the helper * * @access public * @return string */ public function renderMenu() { $navigation = App_Backoffice_Navigation::getInstance()->getNavigation(); $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); $menu = array(); foreach ($navigation as $tab) { $tab = $tab['main']; if (isset($tab['action'])) { $url = $baseUrl . '/' . $tab['controller'] . '/' . $tab['action']; } else { $url = $baseUrl . '/' . $tab['controller']; } if (isset($tab['active']) && $tab['active']) { $li = sprintf($this->_linkSelectedTemplate, $url, $tab['label']); } else { $li = sprintf($this->_linkTemplate, $url, $tab['label']); } $menu[] = $li; } $xhtml = '<ul id="nav" class="prefix_1">' . PHP_EOL . implode(PHP_EOL, $menu) . PHP_EOL . '</ul>'; return $xhtml; }