function views_menu_inline_items in Views (for Drupal 7) 5
1 call to views_menu_inline_items()
- views_menu in ./
views.module - Implementation of hook_menu()
File
- ./
views.module, line 77
Code
function views_menu_inline_items(&$items) {
// I don't think we gain anything by caching these, there should never
// be all that many, and caching == a database hit.
$tokens = module_invoke_all('views_url_tokens');
$args = explode('/', $_GET['q']);
$urls = views_get_all_urls();
foreach ($urls as $view_name => $url) {
if ($url[0] != '$' && strpos($url, '/$') === FALSE) {
if (module_exists('views_ui') && user_access('administer views')) {
$view_args = $args;
foreach (explode('/', $url) as $num => $element) {
if ($element != $args[$num]) {
continue 2;
}
unset($view_args[$num]);
}
views_menu_admin_items($items, $view_name, $view_args, $args);
}
}
else {
// Do substitution on args.
$use_view = $use_menu = FALSE;
$menu_args = $view_args = $menu_path = array();
foreach (explode('/', $url) as $num => $element) {
if ($element[0] == '$') {
// If we pass the token check, this view is definitely being used.
list($token, $argument) = explode('-', $element);
if ($tokens[$token] && function_exists($tokens[$token])) {
if (!($use_view = $use_menu = $tokens[$token]($element, $argument, arg($num)))) {
break;
}
}
$menu_path[] = $view_args[] = arg($num);
}
else {
unset($menu_args[$num]);
$menu_path[] = $element;
if ($element != arg($num)) {
$use_menu = FALSE;
}
}
// we are only using views that match our URL, up to the
// point where we hit an inline arg.
if (!$use_view && $element != arg($num)) {
break;
}
}
if ($use_view) {
$path = implode('/', $menu_path);
$view = views_get_view($view_name);
$view->args = $view_args;
_views_create_menu_item($items, $view, $path, MENU_CALLBACK, $view_args);
}
if (module_exists('views_ui') && user_access('administer views') && $use_menu) {
views_menu_admin_items($items, $view_name, $menu_args, $args);
}
}
}
}