You are here

function advanced_help_index_page in Advanced Help 6

Same name and namespace in other branches
  1. 5 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
Implements hook_menu().

File

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

Code

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

  // 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(t('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 * FROM {system}");
    while ($info = db_fetch_object($result)) {
      $module_info = unserialize($info->info);
      $modules[$info->name] = $module_info['name'];
    }
    asort($modules);
    $items = array();
    foreach ($modules as $module => $module_name) {
      if (!empty($topics[$module]) && empty($settings[$module]['hide'])) {
        if (isset($settings[$module]['index name'])) {
          $name = $settings[$module]['index name'];
        }
        elseif (isset($settings[$module]['name'])) {
          $name = $settings[$module]['name'];
        }
        else {
          $name = t($module_name);
        }
        $items[] = advanced_help_l($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) {

    // 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', $output);
    return;
  }
  $breadcrumb = array_merge(drupal_get_breadcrumb(), array_reverse($breadcrumb));
  drupal_set_breadcrumb($breadcrumb);
  return $output;
}