Пример #1
0
 /**
  * this function loads the current menu and is run automatically by the constructor
  *
  */
 protected function _load()
 {
     $cache = Zend_Registry::get('cache');
     $children = $cache->load(self::CACHE_ID);
     $mdlMenu = new Model_Menu();
     if ($children === false) {
         $children = $mdlMenu->getChildren($this->_parentId);
         $cache->save($children, self::CACHE_ID);
     }
     if ($children != null && $children->count() > 0) {
         foreach ($children as $child) {
             $this->pages[] = new Digitalus_Menu_Item(null, $child);
         }
         $container = new Zend_Navigation($this->pages);
         // set container, acl and role for view helper
         $acl = new Digitalus_Acl();
         $this->view->navigation($container);
         $this->view->navigation()->setAcl($acl);
         $this->view->navigation()->setRole($this->_identity->role);
     }
     // write Zend_Navigation into registry
     Zend_Registry::set('Zend_Navigation', $container);
 }
Пример #2
0
 /**
  * Get Page data as array
  *
  * @return  array  Returns an array of the page data, otherwise an empty array
  */
 protected function _getPageAsArray($item = null)
 {
     if (empty($item)) {
         $item = $this->getItem();
     }
     $baseUrl = $this->view->baseUrl();
     $mdlMenu = new Model_Menu();
     $page = array('active' => $this->isActive(false), 'class' => 'menuItem', 'id' => $item->id, 'label' => Digitalus_Toolbox_Page::getLabel($item), 'name' => $item->name, 'resource' => strtolower(Digitalus_Toolbox_String::replaceEmptySpace($item->name)), 'title' => Digitalus_Toolbox_Page::getLabel($item), 'uri' => $baseUrl . '/' . Digitalus_Toolbox_String::replaceEmptySpace(Digitalus_Toolbox_Page::getUrl($item)), 'visible' => $this->isVisible($item));
     $subPages = array();
     if ($mdlMenu->hasChildren($this->id)) {
         $children = $mdlMenu->getChildren($this->id);
         foreach ($children as $child) {
             $subPages[] = new Digitalus_Menu_Item(null, $child);
         }
         $page['pages'] = $subPages;
     }
     return $page;
 }