Advertisement
NFL

Untitled

NFL
Jul 3rd, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * @author S.Serdyuk
  5.  * @copyright (c) 2013, WebAkula
  6.  *
  7.  */
  8. class App_View_Helper_SiteMenu extends Zend_View_Helper_Abstract {
  9.  
  10.     protected $_viewScriptExt = 'phtml';
  11.     protected $_path;
  12.     protected $_view;
  13.  
  14.     public function siteMenu() {
  15.         $this->_path = MENU_VIEWSCRIPT_PATH;
  16.         $this->_view = new Zend_View;
  17.         return $this;
  18.     }
  19.  
  20.     public function __get($name) {
  21.         $container = $this->getContainer($name);
  22.         $this->_view->navigation()->setContainer($container);
  23.         return $this->_view->navigation()->menu($container)->renderMenu();
  24.     }
  25.  
  26.     public function getContainer($name) {
  27.         $model = new Menu_Model_Table;
  28.         $menu = $model->get($name);
  29.         /* $file = $name . '.' . $this->_viewScriptExt;
  30.           $path = $this->_path . $file;
  31.           if (!file_exists($path)) {
  32.           throw new Exception("Viewscript file '$file' not found in the following path(s): '$this->_path'");
  33.           } */
  34.         //var_dump($menu);
  35.         //return;
  36.         $langId = null;
  37.         if(APP_MULTILINGUAL) {
  38.             $langs = new Core_Model_Languages();
  39.             $langId = $langs->getLanguageId(Zend_Registry::get('LANGUAGE'));
  40.         }
  41.         $items = new Menu_Model_Items;
  42.         $list = $items->getMenu($menu['id'], $langId);
  43.         $entries = array();
  44.         foreach ($list as $row) {
  45.             $entry['id'] = $row['id'];
  46.             $entry['parent_id'] = $row['parent_id'];
  47.             $entry['title'] = $row['title'];
  48.             $entry['label'] = $row['title'];
  49.             $entry['external_url'] = $row['link'];
  50.             $entry['uri'] = $row['link'];
  51.             $entry['class'] = 'nav-item';
  52.            // $entry['active'] = true;
  53.             $entries[] = $entry;
  54.         }
  55.         $entries = Core_Helper_Tree::build($entries);
  56.         $container = new Zend_Navigation();
  57.         $container->setPages($entries);
  58.         return $container;
  59.     }
  60.  
  61.     public function breadcrumbs($name) {
  62.         return $this->_view->navigation()->breadcrumbs($this->getContainer($name));
  63.     }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement