function translateList($rows, $reference_table, $language, $tableArray) { MambelFish::warnAdmin(); return $rows; }
function loadMenuItems($sourceValues = array()) { global $mosConfig_shownoauth; global $mosConfig_lang, $mosConfig_mbf_content; $Itemid = $this->getItemidParameter(); $option = $this->getOptionParameter(); $database = $this->getDatabase(); $menutype = $this->menutype; $activeMenuId = $this->activeMenuId; $openActiveOnly = $this->openActiveOnly; $loadActiveOnly = $this->loadActiveOnly; $maxDepth = $this->maxDepth; $minExpand = $this->minExpand; $sql = 'SELECT m.* FROM #__menu AS m' . ' WHERE menutype=' . $this->getSqlQuote($menutype) . ' AND published = 1'; if ($this->exactAccessLevel) { $sql .= ' AND access = ' . $this->getUserAccessId(); } else { if (!$mosConfig_shownoauth) { $sql .= ' AND access <= ' . $this->getUserAccessId(); } } if ($this->loadFirstLevelOnly) { $sql .= ' AND parent = 0'; } $sql .= ' ORDER BY ordering'; $sqlKey = $sql; $cacheVariableName = '_EXTENDED_MENU_CACHE'; $cacheVariableName2 = '_EXTENDED_MENU_CACHE_TREE'; $rows = NULL; $mainRows = NULL; if ($this->cacheEnabled) { if (isset($GLOBALS[$cacheVariableName]) && isset($GLOBALS[$cacheVariableName2])) { if (isset($GLOBALS[$cacheVariableName][$sqlKey]) && isset($GLOBALS[$cacheVariableName2][$sqlKey])) { $rows =& $GLOBALS[$cacheVariableName][$sqlKey]; $mainRows =& $GLOBALS[$cacheVariableName2][$sqlKey]; } } else { $GLOBALS[$cacheVariableName] = array(); $GLOBALS[$cacheVariableName2] = array(); } } if (is_null($rows) || is_null($mainRows)) { $database->setQuery($sql); if ($mosConfig_mbf_content && class_exists('MambelFish') && !class_exists('JoomFish')) { $objectList = $database->loadObjectList('id'); $rows = array(); if (!$this->checkDatabaseError()) { foreach (array_keys($objectList) as $id) { $rows[$id] = MambelFish::translate($objectList[$id], 'menu', $mosConfig_lang); } } } else { $rows = $database->loadObjectList('id'); if (!$this->checkDatabaseError()) { } else { $rows = array(); } } $mainRows = array(); $orphanedIds = array(); foreach (array_keys($rows) as $id) { $row =& $rows[$id]; $parentId = $row->parent; if ($parentId > 0 && isset($rows[$parentId])) { $parentRow =& $rows[$parentId]; $row->_parentRow =& $parentRow; if (!isset($parentRow->_children)) { $parentRow->_children = array(); } $parentRow->_children[] =& $row; } else { if ($parentId > 0) { // orphaned sub menu item $this->showDebug('orphaned sub menu item: ' . $row->name . ' (id=' . $id . ')'); $orphanedIds[] = $id; } else { // main level item $mainRows[] =& $row; } } } $i = 0; while ($i < count($orphanedIds)) { // do not use foreach here because we may add items to the array $id = $orphanedIds[$i++]; $row =& $rows[$id]; if (isset($row->_children)) { foreach (array_keys($row->_children) as $key) { $child =& $row->_children[$key]; $this->showDebug('child of orphaned menu item: ' . $child->name . ' (id=' . $id . ')'); $orphanedIds[] = $child->id; } } } foreach ($orphanedIds as $id) { unset($rows[$id]); // we need to remove all orphaned menu items } if ($this->cacheEnabled) { if (isset($GLOBALS[$cacheVariableName][$sqlKey])) { // the cache may be useful for splitted menus $GLOBALS[$cacheVariableName][$sqlKey] =& $rows; $GLOBALS[$cacheVariableName2][$sqlKey] =& $mainRows; } } } $menuNodeByIdMap = array(); $menuNodeByNameMap = array(); $activeIds = array(); $parseAccessKeys = $this->parseAccessKey; // find current menu item $keys = array_keys($rows); $homeItemid = FALSE; if ($menutype == 'mainmenu' && count($keys) > 0) { $homeItemid = $rows[$keys[0]]->id; } if ($this->ignoreItemidEnabled || $this->smartItemidEnabled && !isset($rows[$activeMenuId]) || $this->smartItemidEnabled && $Itemid == $homeItemid) { $currentUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; if ($currentUrl == '') { // REQUEST_URI is usually not set on the IIS $currentUrl = $_SERVER['SCRIPT_NAME']; if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') { $currentUrl .= '?' . $_SERVER['QUERY_STRING']; } } $currentUrlArray = array(); if ($currentUrl != '') { $siteHelper =& $this->getSiteHelper(); if (substr($currentUrl, 0, 1) != '/' && strpos($currentUrl, ':') === FALSE) { $currentUrl = '/' . $currentUrl; } $i = strpos($currentUrl, '&Itemid='); if ($i === FALSE) { $i = strpos($currentUrl, '?Itemid='); } if (substr($currentUrl, 0, 1) == '/') { $relativeUri = substr($currentUrl, 1); $currentUrlArray[] = $relativeUri; $currentUrlArray[] = $siteHelper->getUri($relativeUri); } else { $currentUrlArray[] = $currentUrl; } if ($i !== FALSE) { if (substr($currentUrl, 0, 1) == '/') { $relativeUri = substr(substr($currentUrl, 0, $i), 1); $currentUrlArray[] = $relativeUri; $currentUrlArray[] = $siteHelper->getUri($relativeUri); } else { $currentUrlArray[] = substr($currentUrl, 0, $i); } } } $contentItemRow = NULL; $categoryRow = NULL; $sectionRow = NULL; $sectionRow = NULL; $linkRow = NULL; $componentRow = NULL; foreach (array_keys($rows) as $id) { $row =& $rows[$id]; $type = $this->getLinkTypeByMenuNode($row); switch ($type) { case 'content_item_link': if (is_null($contentItemRow) && $this->isActiveContentItem($this->getIdByUrl($row->link))) { $contentItemRow =& $row; break; } break; case 'content_category': case 'content_blog_category': case 'content_archive_category': if (is_null($categoryRow) && $this->isActiveCategory($this->getCategoryIdsByMenuRow($row))) { $categoryRow =& $row; } break; case 'content_section': case 'content_blog_section': case 'content_archive_section': if (is_null($sectionRow) && $this->isActiveSection($this->getSectionIdsByMenuRow($row))) { $sectionRow =& $row; } break; default: if ($row->link != '' && in_array($row->link, $currentUrlArray)) { $linkRow =& $row; } else { if ($row->type == 'components' && $option == $this->getRawUrlParameter($row->link, 'option')) { $componentRow =& $row; } } } if (!is_null($contentItemRow)) { break; // we found already the most valuable menu item } } if (!is_null($contentItemRow)) { $activeMenuId = $contentItemRow->id; } else { if (!is_null($categoryRow)) { $activeMenuId = $categoryRow->id; } else { if (!is_null($sectionRow)) { $activeMenuId = $sectionRow->id; } else { if (!is_null($linkRow)) { $activeMenuId = $linkRow->id; } else { if (!is_null($componentRow) && $option != 'com_wrapper') { // the com_wrapper requires the correct Itemid $activeMenuId = $componentRow->id; } } } } } } if (isset($rows[$activeMenuId])) { $id = $activeMenuId; while ($id > 0 && isset($rows[$id])) { $activeRow =& $rows[$id]; if ($id == $activeMenuId) { $activeRow->current = TRUE; // we assume that we do not have a field called 'current' } $activeRow->active = TRUE; // we assume that we do not have a field called 'active' $activeIds[] = $id; $id = $activeRow->parent; } } if (count($sourceValues) > 0) { $filteredMenuRows = array(); foreach (array_keys($mainRows) as $key) { $menuRow =& $mainRows[$key]; if ($menuRow->id > 0 && in_array($menuRow->id, $sourceValues) || $menuRow->name != '' && in_array($menuRow->name, $sourceValues)) { $filteredMenuRows[] =& $menuRow; } } $mainRows =& $filteredMenuRows; } $this->menuNodeByIdMap =& $menuNodeByIdMap; $this->menuNodeByNameMap =& $menuNodeByNameMap; $this->activeIds =& $activeIds; $rootMenuNode =& $this->getRootMenuNode(); $this->addMenuItemMenuNodes($rootMenuNode, $mainRows, $minExpand, $openActiveOnly); return TRUE; }
function mygosu_menu_items($database, $mygid, &$params, $parentID, $level, $cssRepeatNum) { /** /* Function Desc- loads mygosu menu items (calls recursively) */ if (!$parentID) { $parentID = 0; } // necessary for root sections if (!$level) { $level = 0; } // necessary for root sections $query = "SELECT * FROM #__menu " . "\n WHERE menutype = '" . $params->get('menu') . "' " . "\n AND access <= {$mygid} " . "\n AND published = '1' " . "\n AND parent = '{$parentID}'" . "\n ORDER BY '" . $params->get('order') . "' ASC "; $cssNumMenus = $params->get('css_num_menus'); // max number of css repeat val if ($cssRepeatNum == 0 || $cssRepeatNum > $cssNumMenus) { $cssRepeatNum = 1; } $database->setQuery($query); $menus = $database->loadObjectList(); $numRows = 0; foreach ($menus as $row) { // MambelFish Support - Converts menu items if necessary $numRows++; if (isset($GLOBALS['mosConfig_mbf_content']) && $GLOBALS['$mosConfig_mbf_content']) { // FIX by Eric Benzacar 2005/07/05 ~ bug reported by Kevin McNally 2005/06/30 $row = MambelFish::translate($row, 'menu', $GLOBALS['$mosConfig_lang']); } $name = htmlentities($row->name, ENT_QUOTES); // remove ilegal characters $link = $row->link ? $row->link : NULL; $currentID = $row->id; /** /* Does this menu item have sub menu items? */ $subMenus = mygosu_menus::checkSubMenus($currentID, $mygid, $params, $database); /** * Adds Itemid if link is not a url */ if ($row->type != 'url') { $link .= '&Itemid=' . $row->id; } /** * Controls the page the link will be opened in */ if ($row->browserNav) { $target = "'_blank'"; } else { $target = "'_self'"; } if ($numRows == 1) { //open menu $this->menuObject->StartMenu($level); } // create new menu item $this->menuObject->NewItem($level, $params, $row, $subMenus, $name, $cssRepeatNum, $target, $link); // recurrsive call $this->mygosu_menu_items($database, $mygid, &$params, $currentID, $level + 2, $cssRepeatNum + 1); // close menu item $this->menuObject->CloseItem($level); // close list after recurrsive call to get subsections } if ($numRows > 0) { // close section of menu $this->menuObject->CloseMenuSection($level); } }