public function buildAdminNav() { if ($this->_nav !== null) { return $this->_nav; } $adminNavResult = Zym_Message_Dispatcher::get()->post('buildAdminNav')->getResult('buildAdminNav'); $navigation = new Zend_Navigation(); $missionControlModules = array('missionControl', 'dashboard', 'admin', 'settings', 'system', 'tools'); $updateService = new FFR_Service_Update(); if ($updateService->currentSchemaVersion('missionControl') >= 2) { $settingService = new Settings_Service_Setting(); $missionControl = $settingService->fetchSetting('mission_control')->setting_value; } else { $missionControl = false; } if ($missionControl == true) { foreach ($adminNavResult as $modulePages) { if (in_array($modulePages[0]->getModule(), $missionControlModules)) { $navigation->addPages($modulePages); } } } else { foreach ($adminNavResult as $modulePages) { $navigation->addPages($modulePages); } } $this->_nav = $navigation; return $this->_nav; }
public function indexAction() { if (!$this->_hasParam('id_category')) { $this->_setParam('id_category', 'all'); } // display only the list on ajax request if ($this->getRequest()->isXmlHttpRequest()) { $this->_forward('list'); return; } // add form $form = new Application_Form_Add(); $form->getElement('id_category')->setValue($this->_getParam('id_category')); $this->view->form = $form; // build navigation with categories $navigation = new Zend_Navigation(); $mvc = array('module' => 'default', 'controller' => 'index', 'action' => 'index'); $navigation->addPage(array_merge($mvc, array('params' => array('id_category' => 'all'), 'label' => 'All', 'title' => 'All'))); $mapper = new Application_Model_CategoryMapper(); $categories = $mapper->fetchAll(); foreach ($categories as $category) { $navigation->addPage(new Zend_Navigation_Page_Mvc(array_merge($mvc, array('params' => array('id_category' => $category->id_category), 'label' => $category->name, 'title' => $category->name)))); } $this->view->navigation = $navigation; $this->view->categories = $this->_getCategories($categories); }
public function indexAction() { $this->setCanonicalUrl($this->view->url(array(), 'cms', true)); $this->setTitle(Axis::translate('cms')->__('Pages'), null, false); $categories = Axis::single('cms/category')->select(array('id', 'parent_id'))->addCategoryContentTable()->columns(array('ccc.link', 'ccc.title'))->addActiveFilter()->addSiteFilter(Axis::getSiteId())->addLanguageIdFilter(Axis_Locale::getLanguageId())->order('cc.parent_id')->where('ccc.link IS NOT NULL')->fetchAssoc(); $pages = Axis::single('cms/page')->select(array('id', 'name'))->join(array('cpca' => 'cms_page_category'), 'cp.id = cpca.cms_page_id', 'cms_category_id')->join('cms_page_content', 'cp.id = cpc.cms_page_id', array('link', 'title'))->where('cp.is_active = 1')->where('cpc.language_id = ?', Axis_Locale::getLanguageId())->where('cpca.cms_category_id IN (?)', array_keys($categories))->order('cpca.cms_category_id')->fetchAssoc(); $menu = new Zend_Navigation(); foreach ($categories as $_category) { $title = empty($_category['title']) ? $_category['link'] : $_category['title']; $page = new Zend_Navigation_Page_Mvc(array('category_id' => $_category['id'], 'label' => $title, 'title' => $title, 'route' => 'cms_category', 'params' => array('cat' => $_category['link']), 'class' => 'icon-folder')); $_container = $menu->findBy('category_id', $_category['parent_id']); if (null === $_container) { $_container = $menu; } $_container->addPage($page); } foreach ($pages as $_page) { $title = empty($_page['title']) ? $_page['link'] : $_page['title']; $page = new Zend_Navigation_Page_Mvc(array('label' => $title, 'title' => $title, 'route' => 'cms_page', 'params' => array('page' => $_page['link']), 'class' => 'icon-page')); $_container = $menu->findBy('category_id', $_page['cms_category_id']); $_container->addPage($page); } $this->view->menu = $menu; $this->render(); }
protected function _initNavigation() { $this->bootstrap('layout'); $layout = $this->getResource("layout"); $view = $layout->getView(); $navigation = new Zend_Navigation(); $front = $this->getResource('frontcontroller'); $modules = $front->getControllerDirectory(); $arrModules = array(); foreach (array_keys($modules) as $module) { $navPath = $front->getModuleDirectory($module) . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . 'navigation' . DIRECTORY_SEPARATOR . 'navigation.xml'; if (is_file($navPath)) { $weight = new Zend_Config_Xml($navPath, 'weight'); $arrModules[$weight->weight] = $module; } } ksort($arrModules); if (count($arrModules) > 0) { foreach ($arrModules as $module) { $navPath = $front->getModuleDirectory($module) . DIRECTORY_SEPARATOR . 'configs/navigation/navigation.xml'; $pages = new Zend_Config_Xml($navPath, 'nav'); $navigation->addPages($pages); } } $acl = Zend_Registry::get('acl'); $view->navigation($navigation)->setAcl($acl)->setRole($view->roleName); }
public function getNavigation($name, array $options = array(), $activeItem = null) { $pages = $this->getMenuParams($name, $options, $activeItem); $navigation = new Zend_Navigation(); $navigation->addPages($pages); return $navigation; }
function navbarMainMenu() { $config = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/configs/navbar.xml', 'main'); $container = new Zend_Navigation(); $container->setPages($config->toArray()); $view = new Zend_View(); echo $view->navigation($container)->menu()->setUlClass('nav navbar-nav')->setMaxDepth(0)->render(); }
function sidebarMenu() { $config = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/configs/sidebar.xml', 'sidebar'); $container = new Zend_Navigation(); $container->setPages($config->toArray()); $view = new Zend_View(); echo $view->navigation($container)->menu()->setMaxDepth(1)->render(); }
public function routeShutdown(Zend_Controller_Request_Abstract $request) { $navContainer = null; $viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer'); $viewRenderer->initView(); $view = $viewRenderer->view; $module = $request->getModuleName(); if ($module == "admin") { $navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/navigation.xml', 'nav'); $navContainer = new Zend_Navigation($navContainerConfig); // Load the xml navigation menu // check if the database configuration has been set if (Shineisp_Main::isReady()) { // Adding the configuration menu items $configuration = SettingsGroups::getlist(); $submenu = $navContainer->findOneByLabel('Configuration'); foreach ($configuration as $id => $item) { $pages[] = array('label' => $item, 'uri' => '/admin/settings/index/groupid/' . $id, 'resource' => 'admin:settings'); } $submenu->addPages($pages); } // Attach the Zend ACL to the Navigation menu $auth = Zend_Auth::getInstance(); if ($auth) { $acl = $auth->getStorage()->read(); if (is_object($acl)) { Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl); Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole("administrator"); } } } elseif ($module == "default") { $navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/modules/default/navigation.xml', 'nav'); $navContainer = new Zend_Navigation($navContainerConfig); // Load the xml navigation menu // Attach the Zend ACL to the Navigation menu $auth = Zend_Auth::getInstance(); if ($auth) { $acl = $auth->getStorage()->read(); if (is_object($acl)) { Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl); Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole("guest"); } } } if ($navContainer) { foreach ($navContainer->getPages() as $page) { foreach ($page->getPages() as $subpage) { foreach ($subpage->getPages() as $subsubpage) { $uri = $subsubpage->getHref(); if ($uri === $request->getRequestUri()) { $subsubpage->setActive(true); } } } } $view->navigation($navContainer); } }
public function preDispatch(\Zend_Controller_Request_Abstract $request) { $controllerName = $request->getControllerName(); $relatedLinksConfig = new \Zend_Config_Xml(APPLICATION_PATH . "/configs/related_links.xml", "links"); $navigation = new \Zend_Navigation($relatedLinksConfig); $links = $navigation->findAllByController($controllerName); if (count($links) > 0) { $view = \Zend_Layout::getMvcInstance()->getView(); $view->related_links = $links; } }
protected function _initNavigation() { $this->bootstrap('layout'); $this->bootstrap('acl'); $layout = $this->getResource('layout'); $view = $layout->getView(); $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml'); $navigation = new Zend_Navigation($config); $additionalNavigation = Zend_Registry::get('config')->navigation; $menu = $additionalNavigation->monitoring; $subMenu = $menu->enableDisable; $target = ''; if ($subMenu->target) { $target = $subMenu->target; } $navigation->addPage(array('label' => $subMenu->label, 'uri' => $subMenu->uri, 'target' => $target)); $menuPage = $navigation->findOneBy('label', 'Monitoring'); $subMenuPage = $navigation->findOneBy('label', $subMenu->label); $subMenuPage->setParent($menuPage); $pluginAdminConsolePages = array(); $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaAdminConsolePages'); foreach ($pluginInstances as $pluginInstance) { foreach ($pluginInstance->getAdminConsolePages() as $pluginAdminConsolePage) { $pluginAdminConsolePages[] = $pluginAdminConsolePage; } } foreach ($pluginAdminConsolePages as $pluginAdminConsolePage) { if (!$pluginAdminConsolePage instanceof KalturaAdminConsolePlugin) { continue; } if (!$pluginAdminConsolePage->accessCheck(Kaltura_AclHelper::getCurrentPermissions())) { continue; } $navigation->addPage(array('label' => $pluginAdminConsolePage->getNavigationActionLabel(), 'controller' => 'plugin', 'action' => get_class($pluginAdminConsolePage))); $subMenuPage = $navigation->findOneBy('label', $pluginAdminConsolePage->getNavigationActionLabel()); $menuPage = null; if ($pluginAdminConsolePage->getNavigationRootLabel()) { $menuPage = $navigation->findOneBy('label', $pluginAdminConsolePage->getNavigationRootLabel()); if (!$menuPage) { $navigation->addPage(array('label' => $pluginAdminConsolePage->getNavigationRootLabel(), 'controller' => 'plugin', 'action' => get_class($pluginAdminConsolePage))); $menuPage = $navigation->findOneBy('label', $pluginAdminConsolePage->getNavigationRootLabel()); } } if ($menuPage) { $subMenuPage->setParent($menuPage); } } $this->checkAclForNavigation($navigation); $view->navigation($navigation); }
public function routeShutdown(Zend_Controller_Request_Abstract $request) { $viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer'); $viewRenderer->initView(); $view = $viewRenderer->view; $container = new Zend_Navigation(Zend_Registry::get('configuration')->navigation); foreach ($container->getPages() as $page) { $uri = $page->getHref(); if ($uri === $request->getRequestUri()) { $page->setClass('active'); } } $view->navigation($container); }
function navbarRightMenu() { $config = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/configs/navbar.xml', 'nav'); $container = new Zend_Navigation(); $container->setPages($config->toArray()); /*$container->addPage( array( 'label' => Zend_Auth::getInstance()->getIdentity()->email, 'title' => 'Dashboard', 'uri' => '/admin/' ));*/ $view = new Zend_View(); echo $view->navigation($container)->menu()->setUlClass('dropdown-menu')->render(); }
public function indexAction() { // Force response to identify itself as XML, not sure it belongs in a controller $this->getResponse()->setHeader('Content-type', 'application/xml'); $this->_helper->layout->disableLayout(); $navigation = new Zend_Navigation(); /* This is going to be hugely dirty. If this still exists in a few months you have my sincere apologies I only have a day to write this sitemap and I fully intend to come back and neaten it up at some point */ // Home $page = new Zend_Navigation_Page_Uri(); $page->label = 'Home'; $page->uri = '/home'; $page->changefreq = 'daily'; $navigation->addPage($page); // Careers $page = new Zend_Navigation_Page_Uri(); $page->label = 'Careers'; $page->uri = '/careers'; $page->changefreq = 'daily'; $navigation->addPage($page); // News $page = new Zend_Navigation_Page_Uri(); $page->label = 'News'; $page->uri = '/news'; $page->changefreq = 'weekly'; $navigation->addPage($page); $page = new Zend_Navigation_Page_Uri(); $page->label = 'Tenants News'; $page->uri = '/tenants/news'; $page->changefreq = 'weekly'; $navigation->addPage($page); $page = new Zend_Navigation_Page_Uri(); $page->label = 'Landlords News'; $page->uri = '/landlords/news'; $page->changefreq = 'weekly'; $navigation->addPage($page); $page = new Zend_Navigation_Page_Uri(); $page->label = 'Agents News'; $page->uri = '/letting-agents/news'; $page->changefreq = 'weekly'; $navigation->addPage($page); $pageModel = new Datasource_Cms_Pages(); $cmsPages = $pageModel->getPageList(); foreach ($cmsPages as $cmsPage) { if (!in_array($cmsPage['url'], $this->_suppressCmsUrl)) { $page = new Zend_Navigation_Page_Uri(); $page->label = $cmsPage['title']; $page->uri = '/' . $cmsPage['url']; $page->changefreq = 'hourly'; $navigation->addPage($page); } } $this->view->navigation($navigation); }
/** * Testing that navigation order is done correctly * * @group ZF-8337 * @group ZF-8313 */ public function testNavigationArraySortsCorrectly() { $page1 = new Page\Uri(array('uri' => 'page1')); $page2 = new Page\Uri(array('uri' => 'page2')); $page3 = new Page\Uri(array('uri' => 'page3')); $this->_navigation->setPages(array($page1, $page2, $page3)); $page1->setOrder(1); $page3->setOrder(0); $page2->setOrder(2); $pages = $this->_navigation->toArray(); $this->assertSame(3, count($pages)); $this->assertEquals('page3', $pages[0]['uri'], var_export($pages, 1)); $this->assertEquals('page1', $pages[1]['uri']); $this->assertEquals('page2', $pages[2]['uri']); }
/** * Testing that navigation order is done correctly * * @group ZF-8337 * @group ZF-8313 */ public function testNavigationArraySortsCorrectly() { require_once 'Zend/Navigation/Page/Uri.php'; $page1 = new Zend_Navigation_Page_Uri(array('uri' => 'page1')); $page2 = new Zend_Navigation_Page_Uri(array('uri' => 'page2')); $page3 = new Zend_Navigation_Page_Uri(array('uri' => 'page3')); $this->_navigation->setPages(array($page1, $page2, $page3)); $page1->setOrder(1); $page3->setOrder(0); $page2->setOrder(2); $pages = $this->_navigation->toArray(); $this->assertSame(3, count($pages)); $this->assertEquals('page3', $pages[0]['uri']); $this->assertEquals('page1', $pages[1]['uri']); $this->assertEquals('page2', $pages[2]['uri']); }
public function indexAction() { $breadcrumbs = new Zend_Navigation(); $i = 0; $manufactureCategory = $this->getPageCategory(); $manufactureItem = $this->getPageItem(); if (!is_null($manufactureCategory)) { $breadcrumbs->addPage(array('type' => 'uri', 'label' => $manufactureCategory->getTitle(), 'uri' => !is_null($manufactureItem) ? '/manufacture/' . $manufactureCategory->getPath() . '/' : null, 'active' => !is_null($manufactureItem) ? false : true)); $i--; } if (!is_null($manufactureItem)) { $breadcrumbs->addPage(array('type' => 'uri', 'label' => $manufactureItem->getTitle(), 'active' => true)); $i--; } $breadcrumbs->addPage(new Zend_Navigation_Page_Uri(array('label' => 'Наше производство', 'uri' => '/manufacture/', 'order' => $i))); $breadcrumbs->addPage(new Zend_Navigation_Page_Uri(array('label' => 'Главная', 'uri' => '/', 'order' => $i - 1))); $this->view->breadcrumbs = $breadcrumbs; }
public function indexAction() { $breadcrumbs = new Zend_Navigation(); $i = 0; $pipelineCategory = $this->getPageCategory(); $pipelineItem = $this->getPageItem(); if (!is_null($pipelineCategory)) { $breadcrumbs->addPage(array('type' => 'uri', 'label' => $pipelineCategory->getTitle(), 'uri' => !is_null($pipelineItem) ? '/pipeline/' . $pipelineCategory->getPath() . '/' : null, 'active' => !is_null($pipelineItem) ? false : true)); $i--; } if (!is_null($pipelineItem)) { $breadcrumbs->addPage(array('type' => 'uri', 'label' => $pipelineItem->getTitle(), 'active' => true)); $i--; } $breadcrumbs->addPage(new Zend_Navigation_Page_Uri(array('label' => 'Детали трубопроводов', 'uri' => '/pipeline/', 'order' => $i))); $breadcrumbs->addPage(new Zend_Navigation_Page_Uri(array('label' => 'Главная', 'uri' => '/', 'order' => $i - 1))); $this->view->breadcrumbs = $breadcrumbs; }
public function indexAction() { $breadcrumbs = new Zend_Navigation(); $i = 0; $category = $this->getMediaCategory(); if (!is_null($this->getMediaCategory())) { $breadcrumbs->addPage(array('type' => 'uri', 'label' => $category->getName(), 'uri' => !$this->getMediaItem() ? null : '/media/' . $category->getPath() . '/', 'active' => !$this->getMediaItem() ? true : false)); $i--; } $mediaItem = $this->getMediaItem(); if (!is_null($mediaItem)) { $breadcrumbs->addPage(array('type' => 'uri', 'label' => $mediaItem->getName(), 'active' => true)); $i--; } $breadcrumbs->addPage(new Zend_Navigation_Page_Uri(array('label' => 'Пресса', 'uri' => '/media/', 'order' => $i))); $breadcrumbs->addPage(new Zend_Navigation_Page_Uri(array('label' => 'Главная', 'uri' => '/', 'order' => $i - 1))); $this->view->breadcrumbs = $breadcrumbs; }
/** * */ public function getSitemap() { if (is_null($this->_sitemap)) { $options = $this->getOptions(); $front = $this->getBootstrap()->getResource('FrontController'); $root = dirname($front->getModuleDirectory()); //modules directory $acl = $this->getBootstrap()->getResource('Acl'); $role = $this->getBootstrap()->getPluginResource('acl')->getRole(); try { $dir = new DirectoryIterator($root); } catch (Exception $e) { throw new Streamwide_Exception("Directory {$root} not readable"); } $this->_sitemap = new Zend_Navigation(); foreach ($dir as $file) { if ($file->isDot() || !$file->isDir()) { continue; } $module = $file->getFilename(); // Don't use SCCS directories as modules if (preg_match('/^[^a-z]/i', $module) || 'CVS' == $module) { continue; } $controllerPath = "{$root}/{$module}/controllers"; $controllers = $this->_getControllers($controllerPath); foreach ($controllers as $controller => $class) { $actions = $this->_getActions($class); foreach ($actions as $action) { $mca = new Streamwide_Web_Acl_Resource_Mca($module, strtolower($controller), strtolower($action)); $all = new Streamwide_Web_Acl_Resource_Mca('*', '*', '*'); if ($acl->has($mca) && !$acl->isAllowed($role, $mca)) { continue; } if (!$acl->has($mca) && !$acl->isAllowed($role, $all)) { continue; } $this->_sitemap->addPage(Zend_Navigation_Page::factory(array("label" => "{$module}/{$controller}/{$action}", "module" => $module, "controller" => $controller, "action" => $action))); } } } } return $this->_sitemap; }
/** * Устанавливает активную ветку на основе текущего раздела * * @return Phorm_Widget_Categories_Menu */ private function setActiveBranch() { if (isset($this->_params['categoryinfo']['categoryid']) && ($current = $this->_categories->findBy('id', $this->_params['categoryinfo']['categoryid']))) { $current->set('active', true); while ($current = $this->_categories->findBy('id', $current->get('cparent'))) { $current->set('active', true); } } return $this->_categories; }
public function navigationAction() { $bcn = new Zend_Navigation(); $categoriesModel = new Model_DbTable_Categories(); $category = $categoriesModel->find($this->getRequest()->getParam("category"))->current(); if (!$category) { return; } $i = 0; $bcn->addPage(array("action" => "index", "controller" => "categories", "module" => "catalog", 'order' => $i, "params" => array('category' => $category->id), 'label' => $category->name)); while ($category->parent_id) { $category = $category->findParentRow('Model_DbTable_Categories'); $bcn->addPage(array("action" => "index", "controller" => "categories", "module" => "catalog", 'order' => $i, "params" => array('category' => $category->id), 'label' => $category->name)); $i--; } $bcn->addPage(array("action" => "index", "controller" => "index", "module" => "catalog", 'label' => 'Каталог продукции', 'order' => $i)); $bcn->addPage(array("action" => "index", "controller" => "index", "module" => "default", 'label' => 'Главная', 'order' => $i - 1)); $this->view->navigation = $bcn; }
/** * Creates a new navigation container * * @param array|Zend_Config $pages [optional] pages to add * @throws Zend_Navigation_Exception if $pages is invalid */ public function __construct($pages = null) { if ($pages instanceof Zend_Config) { $pages = $pages->toArray(); } if (is_array($pages)) { array_walk($pages, array($this, '_makeMcaTypeDefaultForPages')); } parent::__construct($pages); }
private function createNavigation() { $this->moduleConf = Dfi_Auth_Acl::getMapModules(); $nav = new Zend_Navigation(); $modules = SysModuleQuery::create()->filterByTreeLevel(1)->orderByTreeLeft()->find(); foreach ($modules as $module) { /* @var $module SysModule */ $page = $this->createPage($module); $nav->addPage($page); if ($module->hasChildren()) { if ($module->countChildren() > 1) { $this->addChildren($page, $module); } else { $child = $module->getFirstChild(); //$page->set } } } $this->navigation = $nav; }
/** * This method tests the privileges required to see a given link * * @param string $propertyValue the value of the property for finding page * @param string $role the role to test against * @param bool $result expected result * @param string $propertyName if given method will try to find the given page * by this property instead of by label * * @dataProvider getAccessSampleData * * @return void */ public function testNavigationAccess($propertyValue, $role, $result, $propertyName = 'label') { $acl = $this->getNavigationAcl(); if (!$acl) { $this->markTestSkipped('You must override the getAcl method in order to use this test'); } $page = $this->_navigation->findBy($propertyName, $propertyValue); $this->assertNotNull($page, sprintf("A page with %s set to %s should exists in navigation", ucfirst($propertyName), $propertyValue)); $menu = new Zend_View_Helper_Navigation_Menu(); $menu->setRole($role)->setAcl($acl); $this->assertSame($result, $menu->accept($page), "Page with label {$page->label} is not accepted for role " . ($role instanceof Zend_Acl_Role_Interface ? $role->getRoleId() : $role)); }
/** * @param Zend_Navigation $sitemap * @param $itemsMapper Catalog_Model_Mapper_Categories | Catalog_Model_Mapper_Products | Manufacture_Model_Mapper_ManufactureCategories | Manufacture_Model_Mapper_Manufacture | Pages_Model_Mapper_Pages | Pipeline_Model_Mapper_PipelineCategories | Pipeline_Model_Mapper_Pipeline | Oil_Model_Mapper_OilCategories | Oil_Model_Mapper_Oil | Media_Model_Mapper_MediaCategories | Media_Model_Mapper_Media * @return Zend_Navigation * @throws Zend_Navigation_Exception */ protected function _addPagesSitemap(Zend_Navigation $sitemap, $itemsMapper) { $colsTable = $itemsMapper->getDbTable()->info('cols'); //Zend_Debug::dump($colsTable); $baseUri = strtolower($this->_getNameModule($itemsMapper)); $sectionUri = $baseUri != 'page' ? '/' . $baseUri . '/' : '/'; $cache = Zend_Registry::get('cache'); $cacheName = $this->_getNameSpace($itemsMapper) . '_All_Filter_deleted_active'; if (!($items = $cache->load($cacheName))) { $select = $itemsMapper->getDbTable()->select(); $select->where('deleted != ?', 1)->where('active != ?', 0)->order('sorting ASC'); $items = $itemsMapper->fetchAll($select); $cache->save($items, $cacheName, array($this->_getNameModule($itemsMapper), $this->_getNameSpace($itemsMapper))); } if (!empty($items)) { foreach ($items as $item) { $uri = in_array('full_path', $colsTable) ? $item->getFullPath() : $item->getPath(); if ($uri != '') { $sitemap->addPage(array('type' => 'uri', 'uri' => $sectionUri . $uri . '/')); } } } return $sitemap; }
/** * Creates a new navigation container * * @see Zend_Navigation::__construct() * @param string|array|Zend_Config $pages [optional] pages to add * @param string $environment [optional] environment in pages * @throws Zend_Navigation_Exception if $pages is invalid */ public function __construct($pages = null, $environment = 'navigation') { if (is_string($pages) && is_file($pages)) { $file = $pages; switch (strtolower(pathinfo($file, PATHINFO_EXTENSION))) { case 'ini': $pages = new Zend_Config_Ini($file, $environment); break; case 'xml': $pages = new Zend_Config_Xml($file, $environment); break; case 'json': $pages = new Zend_Config_Json($file, $environment); break; case 'yaml': case 'yml': $pages = new Zend_Config_Yaml($file, $environment); break; default: throw new ZtChart_Model_Navigation_Exception('Invalid configuration file provided; unknown config type'); } } parent::__construct($pages); }
public function genBreadcrumbs() { $breadcrumbs = new Zend_Navigation(); $categoriesMapper = new Catalog_Model_Mapper_Categories(); $category = $this->getCategoryId() ? $categoriesMapper->find($this->getCategoryId(), new Catalog_Model_Categories()) : null; $i = 0; if (isset($category) && is_null($this->getProductId())) { $breadcrumbs->addPage(array('type' => 'uri', 'label' => $category->getName(), 'active' => true)); } $parentCategories = $categoriesMapper->fetchTreeParentCategories($category->getParentId()); if (!is_null($this->getProductId())) { $parentCategories = $categoriesMapper->fetchTreeParentCategories($this->getCategoryId()); } if (!empty($parentCategories)) { foreach ($parentCategories as $parentCategory) { $breadcrumbs->addPage(array("action" => "index", "controller" => "categories", "module" => "catalog", 'order' => $i, 'route' => 'catalog', "params" => array('fullPath' => $parentCategory->id != 0 ? $parentCategory->full_path : null), 'reset_params' => true, 'encode_url' => false, 'label' => $parentCategory->name)); $i--; } } $breadcrumbs->addPage(new Zend_Navigation_Page_Uri(array('label' => 'Каталог', 'uri' => '/catalog/', 'order' => $i))); $breadcrumbs->addPage(new Zend_Navigation_Page_Uri(array('label' => 'Главная', 'uri' => '/', 'order' => $i - 1))); return $breadcrumbs; }
public function __construct($pages = null) { parent::__construct($pages); $this->options = array('active' => 0, 'collapsible' => false, 'disabled' => false, 'event' => 'click', 'heightStyle' => 'content', 'hide' => null, 'show' => null); }
/** * @param $activeDocument * @param null $navigationRootDocument * @param null $htmlMenuIdPrefix * @param null $pageCallback * @param bool|string $cache * @return mixed|\Zend_Navigation * @throws \Exception * @throws \Zend_Navigation_Exception */ public function getNavigation($activeDocument, $navigationRootDocument = null, $htmlMenuIdPrefix = null, $pageCallback = null, $cache = true) { $cacheEnabled = (bool) $cache; $this->_htmlMenuIdPrefix = $htmlMenuIdPrefix; if (!$navigationRootDocument) { $navigationRootDocument = Document::getById(1); } $siteSuffix = ""; if (Site::isSiteRequest()) { $site = Site::getCurrentSite(); $siteSuffix = "__site_" . $site->getId(); } $cacheId = $navigationRootDocument->getId(); if (is_string($cache)) { $cacheId .= "_" . $cache; } $cacheKey = "navigation_" . $cacheId . $siteSuffix; $navigation = CacheManager::load($cacheKey); if (!$navigation || !$cacheEnabled) { $navigation = new \Zend_Navigation(); if ($navigationRootDocument->hasChilds()) { $rootPage = $this->buildNextLevel($navigationRootDocument, true, $pageCallback); $navigation->addPages($rootPage); } // we need to force caching here, otherwise the active classes and other settings will be set and later // also written into cache (pass-by-reference) ... when serializing the data directly here, we don't have this problem if ($cacheEnabled) { CacheManager::save($navigation, $cacheKey, ["output", "navigation"], null, 999, true); } } // set active path $activePage = $navigation->findOneBy("realFullPath", $activeDocument->getRealFullPath()); if (!$activePage) { // find by link target $activePage = $navigation->findOneBy("uri", $activeDocument->getRealFullPath()); } if ($activePage) { // we found an active document, so we can build the active trail by getting respectively the parent $this->addActiveCssClasses($activePage, true); } else { // we don't have an active document, so we try to build the trail on our own $allPages = $navigation->findAllBy("uri", "/.*/", true); foreach ($allPages as $page) { $activeTrail = false; if (strpos($activeDocument->getRealFullPath(), $page->getRealFullPath() . "/") === 0) { $activeTrail = true; } if ($page->getDocumentType() == "link") { if (strpos($activeDocument->getFullPath(), $page->getUri() . "/") === 0) { $activeTrail = true; } } if ($activeTrail) { $page->setActive(true); $page->setClass($page->getClass() . " active active-trail"); } } } return $navigation; }
public function testRemovePageRecursively() { $container = new Zend_Navigation(array(array('route' => 'foo', 'pages' => array(array('route' => 'bar', 'pages' => array(array('route' => 'baz'))))))); $container->removePage($container->findOneBy('route', 'baz'), true); $this->assertNull($container->findOneBy('route', 'baz')); $container->removePage($container->findOneBy('route', 'bar'), true); $this->assertNull($container->findOneBy('route', 'bar')); }