You are here

function advanced_help_search_view in Advanced Help 7

Same name and namespace in other branches
  1. 5 advanced_help.module \advanced_help_search_view()
  2. 6 advanced_help.module \advanced_help_search_view()

Page callback for advanced help search.

1 string reference to 'advanced_help_search_view'
advanced_help_menu in ./advanced_help.module
Implements hook_menu().

File

./advanced_help.module, line 187
Pluggable system to provide advanced help facilities for Drupal and modules.

Code

function advanced_help_search_view() {
  if (!module_exists('search')) {
    return drupal_not_found();
  }
  $breadcrumb[] = advanced_help_l(t('Advanced help'), 'admin/help/ah');
  if (!isset($_POST['form_id'])) {
    $keys = advanced_help_search_get_keys();

    // Only perform search if there is non-whitespace search term:
    $results = '';
    if (trim($keys)) {
      $search_results = search_data($keys, 'advanced_help');
      $search_results = drupal_render($search_results);

      // Collect the search results:
      $results = array(
        '#type' => 'markup',
        '#markup' => $search_results,
      );
    }

    // Construct the search form.
    $output['advanced_help_search_form'] = drupal_get_form('advanced_help_search_form', $keys);
    $output['results'] = $results;
  }
  else {
    $output = drupal_get_form('advanced_help_search_form', empty($keys) ? '' : $keys);
  }
  $popup = !empty($_GET['popup']) && user_access('view advanced help popup');
  if ($popup) {

    // Prevent devel module from spewing.
    $GLOBALS['devel_shutdown'] = FALSE;

    // Suppress admin_menu.
    module_invoke('admin_menu', 'suppress');
    drupal_set_breadcrumb(array_reverse($breadcrumb));
    print theme('advanced_help_popup', array(
      'content' => $output,
    ));
    return;
  }
  $breadcrumb = array_merge(drupal_get_breadcrumb(), array_reverse($breadcrumb));
  drupal_set_breadcrumb($breadcrumb);
  return $output;
}