You are here

function search_api_page_menu in Search API Pages 7

Implements hook_menu().

File

./search_api_page.module, line 10
Generate search pages using Search API indexes.

Code

function search_api_page_menu() {
  $pre = 'admin/config/search/search_api/page';
  $items[$pre] = array(
    'title' => 'Search pages',
    'description' => 'Create and configure search pages.',
    'page callback' => 'search_api_page_admin_overview',
    'access arguments' => array(
      'administer search_api',
    ),
    'file' => 'search_api_page.admin.inc',
    'type' => MENU_LOCAL_TASK,
  );
  $items[$pre . '/add'] = array(
    'title' => 'Add search page',
    'description' => 'Add a new search page.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'search_api_page_admin_add',
    ),
    'access arguments' => array(
      'administer search_api',
    ),
    'file' => 'search_api_page.admin.inc',
    'type' => MENU_LOCAL_ACTION,
  );
  $items[$pre . '/%search_api_page'] = array(
    'title' => 'Edit search page',
    'description' => 'Configure or delete a search page.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'search_api_page_admin_edit',
      5,
    ),
    'access arguments' => array(
      'administer search_api',
    ),
    'file' => 'search_api_page.admin.inc',
  );
  $items[$pre . '/%search_api_page/edit'] = array(
    'title' => 'Edit search page',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'context' => MENU_CONTEXT_INLINE,
  );

  // 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[$page->path] = array(
        'title' => $page->name,
        'description' => $page->description ? $page->description : '',
        'page callback' => 'search_api_page_view',
        'page arguments' => array(
          (string) $page->machine_name,
        ),
        'access callback' => 'search_api_page_access',
        'access arguments' => array(
          (string) $page->machine_name,
        ),
        'file' => 'search_api_page.pages.inc',
        'type' => MENU_SUGGESTED_ITEM,
      );
    }
  }
  return $items;
}