You are here

function advanced_help_index_page in Advanced Help 5

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

Page callback to view the advanced help topic index.

1 string reference to 'advanced_help_index_page'
advanced_help_menu in ./advanced_help.module
Implementation of hook_menu().

File

./advanced_help.module, line 145
advanced_help.module

Code

function advanced_help_index_page($module = '') {
  $topics = advanced_help_get_topics();

  // Print a search widget.
  $output = '';
  if (module_exists('search')) {
    $output .= drupal_get_form('advanced_help_search_form');
  }
  else {
    $output .= t('Enable the search module to search help.');
  }
  $breadcrumb = array();
  if ($module) {
    if (empty($topics[$module])) {
      return drupal_not_found();
    }
    advanced_help_get_topic_hierarchy($topics);
    $items = advanced_help_get_tree($topics, $topics[$module]['']['children']);
    $breadcrumb[] = advanced_help_l('Help', 'admin/advanced_help');
    drupal_set_title(t('@module help index', array(
      '@module' => advanced_help_get_module_name($module),
    )));
    $output .= theme('item_list', $items);
  }
  else {

    // Print a module index.
    $modules = array();
    $result = db_query("SELECT name FROM {system}");
    while ($info = db_fetch_object($result)) {
      $modules[] = $info->name;
    }
    asort($modules);
    $items = array();
    foreach ($modules as $module) {
      if (!empty($topics[$module])) {
        $module_name = advanced_help_get_module_name($module);
        $items[] = advanced_help_l($module_name, "admin/advanced_help/{$module}");
      }
    }
    drupal_set_title(t('Module help index'));
    $output .= theme('item_list', $items);
  }
  $popup = !empty($_GET['popup']) && user_access('view advanced help popup');
  if ($popup) {
    $GLOBALS['devel_shutdown'] = FALSE;

    // Prevent devel module from spewing.
    drupal_set_breadcrumb(array_reverse($breadcrumb));
    print theme('advanced_help_popup', $output);
    return;
  }
  $breadcrumb = array_merge(drupal_get_breadcrumb(), array_reverse($breadcrumb));
  drupal_set_breadcrumb($breadcrumb);
  return $output;
}