You are here

function views_plugin_display_i18n_page::execute_hook_menu in i18n page views 7

Same name and namespace in other branches
  1. 6 views_plugin_display_i18n_page.inc \views_plugin_display_i18n_page::execute_hook_menu()
  2. 6.0 views_plugin_display_i18n_page.inc \views_plugin_display_i18n_page::execute_hook_menu()

Add this display's path information to Drupal's menu system.

File

./views_plugin_display_i18n_page.inc, line 34
Contains the i18n page display plugin.

Class

views_plugin_display_i18n_page
The plugin that handles a full page.

Code

function execute_hook_menu($callbacks) {
  $items = array();

  // Replace % with the link to our standard views argument loader
  // views_arg_load -- which lives in views.module
  $languages = locale_language_list();
  foreach ($languages as $langcode => $langname) {
    $bits = explode('/', $this
      ->get_option('path_' . $langcode));
    $page_arguments = array(
      $this->view->name,
      $this->display->id,
    );

    // Replace % with %views_arg for menu autoloading and add to the
    // page arguments so the argument actually comes through.
    foreach ($bits as $pos => $bit) {
      if ($bit == '%') {
        $bits[$pos] = '%views_arg';
        $page_arguments[] = $pos;
      }
    }
    $path = implode('/', $bits);
    $access_plugin = $this
      ->get_plugin('access');
    if (!isset($access_plugin)) {
      $access_plugin = views_get_plugin('access', 'none');
    }
    if ($path) {
      $items[$path] = array(
        // default views page entry
        'page callback' => 'views_page',
        'page arguments' => $page_arguments,
        // Default access check (per display)
        'access callback' => 'views_access',
        'access arguments' => array(
          $access_plugin
            ->get_access_callback(),
        ),
        // Identify URL embedded arguments and correlate them to a handler
        'load arguments' => array(
          $this->view->name,
          $this->display->id,
          '%index',
        ),
      );
      $menu = array(
        'type' => 'none',
      );
      $items[$path]['type'] = MENU_CALLBACK;
    }
  }
  return $items;
}