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;
 }
Exemple #2
0
 public function getNavigation($name, array $options = array(), $activeItem = null)
 {
     $pages = $this->getMenuParams($name, $options, $activeItem);
     $navigation = new Zend_Navigation();
     $navigation->addPages($pages);
     return $navigation;
 }
Exemple #3
0
 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 indexAction()
 {
     // Disable Layout
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     // Output XML than HTML
     $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=utf-8');
     $cache = Zend_Registry::get('cache');
     $hostHttp = new Zend_Controller_Request_Http();
     $host = $hostHttp->getServer('HTTP_HOST');
     $cacheName = 'sitemap_' . str_replace(array('.', '-'), '_', $host);
     //Zend_Debug::dump($cacheName);
     if (!($sitemap = $cache->load($cacheName))) {
         $sitemap = new Zend_Navigation();
         $pageMapper = new Default_Model_Mapper_Pages();
         $select = $pageMapper->getDbTable()->select();
         $pages = $pageMapper->fetchAll($select);
         if (!empty($pages)) {
             foreach ($pages as $page) {
                 if ($page->getPath() != '') {
                     $url = $page->getPath() != 'home' ? $page->getPath() . '/' : '';
                     $sitemap->addPage(array('type' => 'uri', 'uri' => '/' . $url));
                 }
             }
         }
         $sitemap->addPages(array(array('type' => 'uri', 'uri' => '/search/')));
         $catalogCategoriesMapper = new Catalog_Model_Mapper_Categories();
         $this->_addPagesSitemap($sitemap, $catalogCategoriesMapper);
         $catalogProductsMapper = new Catalog_Model_Mapper_Products();
         $this->_addPagesSitemap($sitemap, $catalogProductsMapper);
         $manufactureCategoriesMapper = new Manufacture_Model_Mapper_ManufactureCategories();
         $this->_addPagesSitemap($sitemap, $manufactureCategoriesMapper);
         $manufactureMapper = new Manufacture_Model_Mapper_Manufacture();
         $this->_addPagesSitemap($sitemap, $manufactureMapper);
         $oilMapper = new Oil_Model_Mapper_Oil();
         $this->_addPagesSitemap($sitemap, $oilMapper);
         $sitemap->addPages(array(array('type' => 'uri', 'uri' => '/forum/question/'), array('type' => 'uri', 'uri' => '/forum/review/'), array('type' => 'uri', 'uri' => '/forum/gravamen/')));
         $mediaCategoriesMapper = new Media_Model_Mapper_MediaCategories();
         $this->_addPagesSitemap($sitemap, $mediaCategoriesMapper);
         $mediaMapper = new Media_Model_Mapper_Media();
         $this->_addPagesSitemap($sitemap, $mediaMapper);
         $cache->save($sitemap, $cacheName, array('sitemap'));
     }
     $this->view->navigation($sitemap);
     // Output the data.
     echo $this->view->navigation()->sitemap();
 }
 /**
  * @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;
 }
Exemple #6
0
 public function testSettingPages()
 {
     $nav = new Zend_Navigation();
     $nav->addPages(array(array('label' => 'Page 1', 'uri' => '#'), array('label' => 'Page 2', 'uri' => '#')));
     $nav->setPages(array(array('label' => 'Page 3', 'uri' => '#')));
     $this->assertEquals(1, count($nav), 'Expected 1 page, found ' . count($nav));
 }
 /**
  * @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);
     }
     $cacheKeys = [];
     if (Site::isSiteRequest()) {
         $site = Site::getCurrentSite();
         $cacheKeys[] = "site__" . $site->getId();
     }
     $cacheKeys[] = "root_id__" . $navigationRootDocument->getId();
     if (is_string($cache)) {
         $cacheKeys[] = "custom__" . $cache;
     }
     if ($pageCallback instanceof \Closure) {
         $cacheKeys[] = "pageCallback_" . closureHash($pageCallback);
     }
     $cacheKey = "nav_" . md5(serialize($cacheKeys));
     $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
     $front = \Zend_Controller_Front::getInstance();
     $request = $front->getRequest();
     // try to find a page matching exactly the request uri
     $activePages = $navigation->findAllBy("uri", $request->getRequestUri());
     if (empty($activePages)) {
         // try to find a page matching the path info
         $activePages = $navigation->findAllBy("uri", $request->getPathInfo());
     }
     if (empty($activePages)) {
         // use the provided pimcore document
         $activePages = $navigation->findAllBy("realFullPath", $activeDocument->getRealFullPath());
     }
     if (empty($activePages)) {
         // find by link target
         $activePages = $navigation->findAllBy("uri", $activeDocument->getFullPath());
     }
     // cleanup active pages from links
     // pages have priority, if we don't find any active page, we use all we found
     $tmpPages = [];
     foreach ($activePages as $page) {
         if ($page instanceof Uri && $page->getDocumentType() != "link") {
             $tmpPages[] = $page;
         }
     }
     if (count($tmpPages)) {
         $activePages = $tmpPages;
     }
     if (!empty($activePages)) {
         // we found an active document, so we can build the active trail by getting respectively the parent
         foreach ($activePages as $activePage) {
             $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 ($page->getUri() && strpos($activeDocument->getRealFullPath(), $page->getUri() . "/") === 0) {
                 $activeTrail = true;
             }
             if ($page instanceof Uri) {
                 if ($page->getDocumentType() == "link") {
                     if ($page->getUri() && strpos($activeDocument->getFullPath(), $page->getUri() . "/") === 0) {
                         $activeTrail = true;
                     }
                 }
             }
             if ($activeTrail) {
                 $page->setActive(true);
                 $page->setClass($page->getClass() . " active active-trail");
             }
         }
     }
     return $navigation;
 }
Exemple #8
0
 public function getNavigation()
 {
     $this->view->navigation = $navigation = new Zend_Navigation();
     $navigation->addPage(array('label' => 'Browse Videos', 'route' => 'video_general', 'action' => 'browse', 'controller' => 'index', 'module' => 'video'));
     if (Engine_Api::_()->user()->getViewer()->getIdentity()) {
         $navigation->addPages(array(array('label' => 'My Videos', 'route' => 'video_general', 'action' => 'manage', 'controller' => 'index', 'module' => 'video'), array('label' => 'Post New Video', 'route' => 'video_general', 'action' => 'create', 'controller' => 'index', 'module' => 'video')));
     }
     return $navigation;
 }
Exemple #9
0
 public function getNavigation($filter = false)
 {
     $this->view->navigation = $navigation = new Zend_Navigation();
     $navigation->addPages(array(array('label' => "Upcoming Events", 'route' => 'event_general'), array('label' => "Past Events", 'route' => 'event_past')));
     $viewer = Engine_Api::_()->user()->getViewer();
     if ($viewer->getIdentity()) {
         $navigation->addPages(array(array('label' => 'My Events', 'route' => 'event_general', 'action' => 'manage', 'controller' => 'index', 'module' => 'event'), array('label' => 'Create New Event', 'route' => 'event_general', 'action' => 'create', 'controller' => 'index', 'module' => 'event')));
     }
     return $navigation;
 }