You are here

function search_by_page_menu in Search by Page 8

Same name and namespace in other branches
  1. 6 search_by_page.module \search_by_page_menu()
  2. 7 search_by_page.module \search_by_page_menu()

Implements hook_menu().

File

./search_by_page.module, line 696
Main module file for Drupal module Search by Page.

Code

function search_by_page_menu() {
  $items = [];
  $items['admin/config/search/search_by_page'] = [
    'title' => 'Search by Page settings',
    'description' => 'Configure settings for Search by Page',
    //'page callback' => 'drupal_get_form',
    'page callback' => '\\Drupal::formBuilder()->getForm',
    'page arguments' => [
      'search_by_page_admin_overview',
    ],
    'access arguments' => [
      'administer search by page',
    ],
    'type' => MENU_NORMAL_ITEM,
  ];
  $items['admin/config/search/search_by_page/resetblank'] = [
    'title' => 'Search by Page reset blank',
    'description' => 'Reset unindexed pages for Search by Page',
    'page callback' => 'search_by_page_reset_blank',
    'access arguments' => [
      'administer search by page',
    ],
    'type' => MENU_CALLBACK,
  ];
  $items['admin/config/search/search_by_page/edit/%'] = [
    'title' => 'Search by Page environment settings',
    'description' => 'Configure settings for Search by Page environment',
    //'page callback' => 'drupal_get_form',
    'page callback' => '\\Drupal::formBuilder()->getForm',
    'page arguments' => [
      'search_by_page_admin_settings',
      5,
    ],
    'access arguments' => [
      'administer search by page',
    ],
    'type' => MENU_CALLBACK,
  ];
  $items['admin/config/search/search_by_page/edit/%/general'] = [
    'title' => 'General settings',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  ];
  $items['admin/config/search/search_by_page/add'] = [
    'title' => 'Add environment',
    'type' => MENU_CALLBACK,
    //'page callback' => 'drupal_get_form',
    'page callback' => '\\Drupal::formBuilder()->getForm',
    'page arguments' => [
      'search_by_page_admin_settings',
    ],
    'access arguments' => [
      'administer search by page',
    ],
  ];
  $items['admin/config/search/search_by_page/delete'] = [
    'title' => 'Delete path',
    'type' => MENU_CALLBACK,
    //'page callback' => 'drupal_get_form',
    'page callback' => '\\Drupal::formBuilder()->getForm',
    'page arguments' => [
      'search_by_page_delete_confirm',
    ],
    'access arguments' => [
      'administer search by page',
    ],
  ];
  $envs = search_by_page_list_environments();
  foreach ($envs as $envid) {
    $path = search_by_page_setting_get('page_path', $envid, 'search_pages');
    $title = search_by_page_setting_get('page_title', $envid, t('Search'));
    if (\Drupal::moduleHandler()
      ->moduleExists('i18n_string')) {
      $title = i18n_string_translate('search_by_page:search_form:page_title' . $envid, $title);
    }
    $items[$path] = [
      'title' => $title,
      'page callback' => '_search_by_page_view',
      // Note that 'env' . $envid is used here to avoid argument substitution.
      'page arguments' => [
        'env' . $envid,
      ],
      'access arguments' => [
        'search page environment ' . search_by_page_setting_get('environment_name', $envid, t('new')),
      ],
      'type' => MENU_SUGGESTED_ITEM,
    ];
  }
  return $items;
}