You are here

function search_api_ajax_menu in Search API ajax 7

Implementation of hook_menu().

File

./search_api_ajax.module, line 114
AJAXifies the Search API search pages, links, ranges, sorts and forms.

Code

function search_api_ajax_menu() {
  $items = array();

  // administration link
  $items['admin/config/search/search_api_ajax'] = array(
    'title' => 'Search API Ajax',
    'description' => 'Page visibility options for Search API Ajax.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'search_api_ajax_settings',
    ),
    'access callback' => 'user_access',
    'access arguments' => array(
      'administer site configuration',
    ),
    'file' => 'search_api_ajax.admin.inc',
  );

  // during uninstallation, this would lead to a fatal error otherwise.
  if (module_exists('search_api_page')) {
    foreach (search_api_page_load_multiple(FALSE, array(
      'enabled' => TRUE,
    )) as $page) {
      $items['search_api_ajax/' . $page->path] = array(
        'title' => $page->name,
        'description' => $page->description ? $page->description : '',
        'page callback' => 'search_api_ajax_proxy',
        'page arguments' => array(
          (string) $page->id,
        ),
        'access arguments' => array(
          'access search_api_page',
        ),
        'type' => MENU_CALLBACK,
        'file' => 'search_api_ajax.pages.inc',
      );
    }
  }

  // similarly, walk through search_api_views with a path (pages)
  if (module_exists('search_api_views') && function_exists('views_get_enabled_views')) {
    foreach (views_get_enabled_views() as $view) {
      if (strpos($view->base_table, 'search_api_index') !== FALSE) {
        foreach ($view->display as $display_name => $display) {
          if (isset($display->display_options['path']) && !empty($display->display_options['path'])) {
            $items['search_api_ajax/' . $display->display_options['path']] = array(
              'title' => isset($display->display_title) ? $display->display_title : '',
              'description' => (string) $view->human_name,
              'page callback' => 'search_api_ajax_proxy_views',
              'page arguments' => array(
                (string) $view->name,
                (string) $display_name,
              ),
              'access arguments' => array(
                'access content',
              ),
              'type' => MENU_CALLBACK,
              'file' => 'search_api_ajax.pages.inc',
            );
          }

          // if i18_page_views module is used for multiple i18n paths
          if (module_exists('i18n_page_views')) {
            $enabled_languages = language_list('enabled');
            foreach ($enabled_languages[1] as $lang_code => $lang_object) {
              if (isset($display->display_options['path_' . $lang_code]) && !empty($display->display_options['path_' . $lang_code])) {
                $items['search_api_ajax/' . $display->display_options['path_' . $lang_code]] = array(
                  'title' => isset($display->display_title) ? $display->display_title : '',
                  'description' => (string) $view->human_name,
                  'page callback' => 'search_api_ajax_proxy_views',
                  'page arguments' => array(
                    (string) $view->name,
                    (string) $display_name,
                  ),
                  'access arguments' => array(
                    'access content',
                  ),
                  'type' => MENU_CALLBACK,
                  'file' => 'search_api_ajax.pages.inc',
                );
              }
            }
          }
        }
      }
    }
  }
  return $items;
}