views_menu_inline_items

Versions
5
views_menu_inline_items(&$items)

Code

contributions/views/views.module, line 77

<?php
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);
      }
    }
  }
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.