예제 #1
0
 public function indexAction()
 {
     $tmp = array();
     $arrayData = array();
     $groupMenu = '';
     $layoutFile = Cible_FunctionsPages::getLayoutPath($this->view->currentPageID);
     foreach ($this->_menusLayout as $key => $value) {
         if (preg_match('/' . $key . '/', $layoutFile)) {
             $groupMenu = $key;
         }
     }
     $menusList = MenuObject::getAllMenuList($groupMenu, true);
     $this->_menusLayout[$groupMenu] = $menusList;
     foreach ($this->_menusLayout[$groupMenu] as $menuId) {
         $oMenu = new MenuObject($menuId);
         if (!empty($tmp)) {
             $arrayData = $this->appendIfNotFound($oMenu->populate(), $tmp, $arrayData);
         } else {
             $arrayData = $oMenu->populate();
         }
         $tmp = $this->verifyChildren($arrayData);
     }
     $this->view->assign('menus', $arrayData);
 }
예제 #2
0
 public function buildCatalogMenu($options = array())
 {
     $menuCatalogId = 0;
     $defaultCat = '';
     if (isset($options['menu'])) {
         $oMenu = new MenuObject($options['menu']);
         $menuCatalog = $oMenu->getMenuItemByPageId(null, 'catalog');
         //            if ($this->view->currentPageID)
         //            {
         //                $parentPage = Cible_FunctionsPages::findParentPageID($this->view->currentPageID);
         //                while ($parentPage['P_ParentID'] != 0 )
         //                {
         //                   $parentPage = Cible_FunctionsPages::findParentPageID($parentPage['P_ParentID']);
         //                }
         //
         //                $pageId      = $parentPage['P_ID'];
         //                $menuCatalog = $oMenu->getMenuItemByPageId($pageId);
         //            }
         //            else
         //            {
         //                $menuCatalog = $oMenu->getMenuItemByPageId();
         $parentPage = Cible_FunctionsPages::findParentPageID($menuCatalog['MII_PageID']);
         //            }
     }
     if ($this->view->controller != $parentPage['PI_PageIndex']) {
         $link = $parentPage['PI_PageIndex'] . "/";
     } else {
         $link = $this->view->selectedPage . "/";
     }
     $tree = array();
     $langId = Zend_Registry::get('languageID');
     $oCategories = new CatalogCategoriesObject();
     if (Zend_Registry::isRegistered('defaultCategory') && !is_null(Zend_Registry::get('defaultCategory'))) {
         $defaultCatId = Zend_Registry::get('defaultCategory');
         $tmpCat = $oCategories->populate($defaultCatId, $langId);
         if (empty($tmpCat['CI_ValUrl'])) {
             $tmpCat['CI_ValUrl'] = "";
         }
         $defaultCat = $tmpCat['CI_ValUrl'];
     }
     $categories = $oCategories->getAll($langId);
     $oSubCategories = new SubCategoriesObject();
     $catalog = array('ID' => $menuCatalog['MID_ID'], 'Title' => $menuCatalog['MII_Title'], 'PageID' => '', 'Link' => $link . $defaultCat, 'Placeholder' => 0, 'child' => array());
     foreach ($categories as $category) {
         $childs = array();
         $id = $category['C_ID'];
         $name = Cible_FunctionsGeneral::formatValueForUrl($category['CI_Name']);
         $linkCat = $link . $name;
         $menu['ID'] = $category['C_ID'];
         $menu['Title'] = $category['CI_Name'];
         $menu['PageID'] = '';
         $menu['Link'] = $linkCat;
         $menu['Placeholder'] = '2';
         $subCategories = $oSubCategories->getSubCatByCategory($id, true, $langId);
         if ($options['nesting'] > 1) {
             foreach ($subCategories as $subCat) {
                 $name = "/" . Cible_FunctionsGeneral::formatValueForUrl($subCat['SCI_Name']);
                 $linkSubCat = $linkCat . $name;
                 $child['ID'] = $subCat['SC_ID'];
                 $child['Title'] = $subCat['SCI_Name'];
                 $child['PageID'] = '';
                 $child['Link'] = $linkSubCat;
                 $child['Placeholder'] = '2';
                 $childs[] = $child;
                 $name = '';
             }
         }
         $menu['child'] = $childs;
         $catalog['child'][] = $menu;
     }
     $oMenu = new MenuObject($options['menu']);
     $first = $oMenu->populate($menuCatalog['MID_ID']);
     $childCombined = array();
     if (isset($options['merge']) && $options['merge']) {
         $childCombined = array_merge($catalog['child'], $first);
         $catalog['child'] = $childCombined;
     }
     $tree[] = $catalog;
     return $tree;
 }
예제 #3
0
 function menuAction()
 {
     $this->view->headScript()->appendFile("{$this->view->baseUrl()}/js/cible.form.element.pagepicker.js");
     $allMenuTitles = MenuObject::getAllMenuTitles();
     $menus = array();
     foreach ($allMenuTitles as $menu) {
         $_menu = new MenuObject($menu['Title']);
         array_push($menus, array('ID' => $menu['ID'], 'Title' => $menu['Title'], 'Type' => $menu['Type'], 'BgColor' => $menu['BgColor'], 'Menu' => $_menu->populate(0, true)));
     }
     $this->view->headScript()->appendFile("{$this->view->baseUrl()}/js/manage.categories.js");
     $this->view->assign('menus', $menus);
 }
예제 #4
0
파일: Menu.php 프로젝트: anunay/stentors
 /**
  * Set default values and the first level container (ul)
  *
  * @param Mixed $menu    If String: Fecth menu data according its name.<br/>
  *                       If Array: It must contain the menu tree.
  *
  * @param array $options Options to manage menu behaviour<br />
  *                       Ex: disable_nesting => true, parentAltId => (string)
  *
  * @return string html code to display the menu and is children
  */
 public function menu($menu, $options = array())
 {
     $this->_addSeparator = "";
     $menuItem = array();
     $_menu = "";
     if (isset($options['addEnclosure'])) {
         $this->_addEnclosure = $options['addEnclosure'];
     }
     if (isset($options['class']) && $options['class'] == 'sitemap') {
         $this->_isSiteMap = true;
     } else {
         $this->_isSiteMap = false;
     }
     if ($this->view->selectedPage) {
         $this->_selectedPage = $this->view->selectedPage;
     } elseif (Zend_Registry::isRegistered('selectedPage')) {
         $this->_selectedPage = Zend_Registry::get('selectedPage');
     } else {
         $params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
         $this->_selectedPage = $params['controller'];
         if ($params['controller'] == 'index') {
             $this->_selectedPage = Cible_FunctionsPages::getPageNameByID(1);
         }
     }
     if (isset($options['addSeparator'])) {
         $this->_addSeparator = $options['addSeparator'];
     }
     $oPages = new PagesObject();
     $pageData = $oPages->pageIdByController($this->_selectedPage);
     $this->_selectedPageId = $pageData['P_ID'];
     if (!is_array($menu)) {
         $_menu = new MenuObject($menu);
         $parentId = isset($options['parentId']) ? $options['parentId'] : 0;
         $tree = $_menu->populate($parentId);
     } elseif (count($menu) > 1 && empty($menu['MID_MenuID'])) {
         $tree = $menu;
     } else {
         $_menu = new MenuObject($menu['MID_MenuID']);
         unset($menu['MID_MenuID'], $menu['MID_ParentId']);
         $tree = $menu;
         if (Zend_Registry::isRegistered('selectedCatalogPage')) {
             $currentUrl = preg_replace('#\\/page\\/[0-9]*#', '', substr($this->view->request->getPathInfo(), 1));
             if (strrpos($currentUrl, '/') == 1) {
                 $currentUrl = substr($currentUrl, -1);
             }
             $nbParts = substr_count($currentUrl, '/');
             if ($nbParts >= 3) {
                 $lastPos = strrpos($currentUrl, '/');
                 $currentUrl = substr($this->view->request->getPathInfo(), 1, $lastPos);
             } elseif ($nbParts == 0) {
                 $currentUrl = $tree[0]['Link'];
             }
             $this->_selectedPage = $currentUrl;
         }
     }
     if (is_object($_menu) && $_menu->getId()) {
         $menuItem = $_menu->getMenuItemByPageId($this->_selectedPageId);
     }
     if ($menuItem) {
         $this->_getParentsMenuId($menuItem, $_menu);
         $this->view->assign('menuId', $menuItem['MID_MenuID']);
     }
     if (is_array($options)) {
         $parentId = isset($options['parentId']) ? $options['parentId'] : 0;
         $this->_parent_alt_id = isset($options['parentIdAlt']) ? $options['parentIdAlt'] : "parentid-";
     }
     if (!empty($options['startLevel'])) {
         $this->_startLevel = $options['startLevel'];
     }
     $this->_disable_nesting = isset($options['disable_nesting']) && $options['disable_nesting'] == true ? true : false;
     parent::tree($tree, $options);
     // var_dump($tree);
     if ($tree) {
         return "<ul id='{$this->_ul_id}' class='{$this->_class}' {$this->_attribs}>" . $this->generateList($tree, true) . "</ul>";
     }
 }