本文整理汇总了PHP中PFApplicationHelper::routes方法的典型用法代码示例。如果您正苦于以下问题:PHP PFApplicationHelper::routes方法的具体用法?PHP PFApplicationHelper::routes怎么用?PHP PFApplicationHelper::routes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PFApplicationHelper
的用法示例。
在下文中一共展示了PFApplicationHelper::routes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: itemRoute
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;
}