private function retrieveChildItems($parentId, $extranet = false) { $tmp_menu = array(); $menuItemObject = new MenuItem(); $select = $menuItemObject->select()->setIntegrityCheck(false)->from('MenuItemData')->joinInner('MenuItemIndex', 'MID_ID = MII_MenuItemDataID')->where('MID_MenuID = ?', $this->_id)->where('MID_ParentID = ?', $parentId)->order('MID_Position'); if ($extranet) { $select->where('MII_LanguageID = ?', Cible_Controller_Action::getDefaultEditLanguage()); } else { $select->where('MII_LanguageID = ?', Zend_Registry::get('languageID')); } if (Zend_Registry::isRegistered('user')) { $user = Zend_Registry::get('user'); if (!$user) { $select->where('MID_Secured = ?', 0); } } $menuItems = $menuItemObject->fetchAll($select)->toArray(); foreach ($menuItems as $item) { $menu_item = array('ID' => $item['MID_ID'], 'MID_Show' => $item['MID_Show'], 'Title' => $item['MII_Title'], 'Link' => $item['MII_Link'], 'PageID' => $item['MII_PageID'], 'Style' => $item['MID_Style'], 'menuImage' => $item['MID_Image'], 'loadImage' => $item['MID_loadImage'], 'menuImgAndTitle' => $item['MID_ImgAndTitle'], 'Placeholder' => $item['MII_Placeholder']); if (preg_match('/useCatalog/', $item['MID_Style'])) { $menu_item['Placeholder'] = 2; $collections = new SubCategoriesObject(); // $menuCatalog = $this->getMenuItemByPageId( null, 'collections'); $catalogMenu = $collections->buildCatalogMenu($menu_item, array('nesting' => 1)); $submenu = $catalogMenu['child']; // $first = $this->populate($menuCatalog['MID_ID']); // $childCombined = array(); // $childCombined = array_merge($catalogMenu['child'], $first); // $catalog['child'] = $childCombined; } else { $submenu = $this->retrieveChildItems($item['MID_ID'], $extranet); } if ($submenu) { $menu_item['child'] = $submenu; } array_push($tmp_menu, $menu_item); } return $tmp_menu; }
/** * 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 subMenu($options = array()) { if (isset($options['addEnclosure'])) { $this->_addEnclosure = $options['addEnclosure']; } 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); } } $oPages = new PagesObject(); $pageData = $oPages->pageIdByController($this->_selectedPage); $this->_selectedPageId = $pageData['P_ID']; $menuData = $oPages->getRelatedMenu($this->_selectedPageId); $parentId = 0; if (!$menuData) { $parentId = $oPages->getParentRelatedID($this->_selectedPageId); $parentName = $oPages->getParentRelatedName($parentId); $menuData = $oPages->getRelatedMenu($parentId); $this->_selectedPageId = $parentId; $parentId = $menuData['MID_ParentID']; $this->view->assign('selectedPage', $parentName); //echo $parentName; } $_menu = new MenuObject($menuData['MID_MenuId']); if ($menuData['MID_ParentID'] == 0) { $parentId = $menuData['MID_ID']; } else { $menuItem = $_menu->getMenuItemByPageId($this->_selectedPageId); if ($menuItem) { $this->_getParentsMenuId($menuItem, $_menu); } if ($parentId == 0) { $parentId = $this->_parentsMenuId[0]; } } if (!empty($options['parentId'])) { $parentId = $options['parentId']; } if (preg_match('/useCatalog/', $menuData['MID_Style'])) { $menu_item['Placeholder'] = 2; $collections = new SubCategoriesObject(); // $menuCatalog = $this->getMenuItemByPageId( null, 'collections'); $catalogMenu = $collections->buildCatalogMenu($menu_item, array('nesting' => 1)); $tree = $catalogMenu['child']; // $first = $this->populate($menuCatalog['MID_ID']); // $childCombined = array(); // $childCombined = array_merge($catalogMenu['child'], $first); // $catalog['child'] = $childCombined; } elseif (!empty($parentId)) { $tree = $_menu->populate($parentId); } $tree['MID_MenuID'] = $menuData['MID_MenuId']; $tree['MID_ParentId'] = $parentId; return $tree; }