$value) { if ((!in_array($name, self::$_filter)) && (!($name == 'task' && !array_key_exists('view', $request)))) { // Remove the variables we want to ignore. unset($request[$name]); } } ksort($request); return 'index.php?' . http_build_query($request, '', '&'); } /** * Get the menu list for create a menu module * * @return array The menu array list * * @since 1.6 */ public static function getMenuTypes() { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.menutype') ->from('#__menu_types AS a'); $db->setQuery($query); return $db->loadColumn(); } /** * Get a list of menu links for one or all menus. * * @param string $menuType An option menu to filter the list on, otherwise all menu links are returned as a grouped array. * @param integer $parentId An optional parent ID to pivot results around. * @param integer $mode An optional mode. If parent ID is set and mode=2, the parent and children are excluded from the list. * @param array $published An optional array of states * @param array $languages Optional array of specify which languages we want to filter * * @return array * * @since 1.6 */ public static function getMenuLinks($menuType = null, $parentId = 0, $mode = 0, $published = array(), $languages = array()) { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.id AS value, a.title AS text, a.alias, a.level, a.menutype, a.type, a.template_style_id, a.checked_out') ->from('#__menu AS a') ->join('LEFT', $db->quoteName('#__menu') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt'); // Filter by the type if ($menuType) { $query->where('(a.menutype = ' . $db->quote($menuType) . ' OR a.parent_id = 0)'); } if ($parentId) { if ($mode == 2) { // Prevent the parent and children from showing. $query->join('LEFT', '#__menu AS p ON p.id = ' . (int) $parentId) ->where('(a.lft <= p.lft OR a.rgt >= p.rgt)'); } } if (!empty($languages)) { if (is_array($languages)) { $languages = '(' . implode(',', array_map(array($db, 'quote'), $languages)) . ')'; } $query->where('a.language IN ' . $languages); } if (!empty($published)) { if (is_array($published)) { $published = '(' . implode(',', $published) . ')'; } $query->where('a.published IN ' . $published); } $query->where('a.published != -2') ->group('a.id, a.title, a.alias, a.level, a.menutype, a.type, a.template_style_id, a.checked_out, a.lft') ->order('a.lft ASC'); // Get the options. $db->setQuery($query); try { $links = $db->loadObjectList(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); return false; } if (empty($menuType)) { // If the menutype is empty, group the items by menutype. $query->clear() ->select('*') ->from('#__menu_types') ->where('menutype <> ' . $db->quote('')) ->order('title, menutype'); $db->setQuery($query); try { $menuTypes = $db->loadObjectList(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); return false; } // Create a reverse lookup and aggregate the links. $rlu = array(); foreach ($menuTypes as &$type) { $rlu[$type->menutype] = & $type; $type->links = array(); } // Loop through the list of menu links. foreach ($links as &$link) { if (isset($rlu[$link->menutype])) { $rlu[$link->menutype]->links[] = & $link; // Cleanup garbage. unset($link->menutype); } } return $menuTypes; } else { return $links; } } /** * Get the items associations * * @param integer $pk Menu item id * * @return array * * @since 3.0 */ public static function getAssociations($pk) { $associations = array(); $db = JFactory::getDbo(); $query = $db->getQuery(true) ->from('#__menu as m') ->join('INNER', '#__associations as a ON a.id=m.id AND a.context=' . $db->quote('com_menus.item')) ->join('INNER', '#__associations as a2 ON a.key=a2.key') ->join('INNER', '#__menu as m2 ON a2.id=m2.id') ->where('m.id=' . (int) $pk) ->select('m2.language, m2.id'); $db->setQuery($query); try { $menuitems = $db->loadObjectList('language'); } catch (RuntimeException $e) { throw new Exception($e->getMessage(), 500); } foreach ($menuitems as $tag => $item) { // Do not return itself as result if ((int) $item->id != $pk) { $associations[$tag] = $item->id; } } return $associations; } }