public static function itemRoute($needles = null, $com_view = null) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); $com_name = $app->input->get('option'); $view_name = null; if ($com_view) { $parts = explode('.', $com_view); if (count($parts) == 2) { list($com_name, $view_name) = $parts; } else { $view_name = $com_view; } } // Prepare the reverse lookup array. if (!is_array(self::$routes)) { self::$routes = array(); } if (!isset(self::$routes[$com_name])) { self::$routes[$com_name] = array(); $component = JComponentHelper::getComponent($com_name); $items = $menus->getItems('component_id', $component->id); foreach ($items as $item) { if (isset($item->query) && isset($item->query['view'])) { $view = $item->query['view']; if (!isset(self::$routes[$com_name][$view])) { self::$routes[$com_name][$view] = array(); } if (isset($item->query['id'])) { self::$routes[$com_name][$view][$item->query['id']] = $item->id; } else { self::$routes[$com_name][$view][0] = $item->id; } } } } if ($needles) { foreach ($needles as $view => $ids) { if (isset(self::$routes[$com_name][$view])) { foreach ($ids as $id) { if (isset(self::$routes[$com_name][$view][(int) $id])) { return self::$routes[$com_name][$view][(int) $id]; } } } } } else { $active = $menus->getActive(); if ($active && $active->component == $com_name) { if ($com_view) { if (isset(self::$routes[$com_name][$view_name][0])) { return self::$routes[$com_name][$view_name][0]; } elseif ($com_view && isset($active->query['view']) && $active->query['view'] != $com_view) { return null; } } return $active->id; } else { if ($com_view) { if (isset(self::$routes[$com_name][$view_name][0])) { return self::$routes[$com_name][$view_name][0]; } } } } return null; }