You are here

function advanced_help_index_page in Advanced Help 7

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

Page callback to view the advanced help topic index.

Parameters

string $module: Name of the module.

Return value

array Returns module index.

1 call to advanced_help_index_page()
advanced_help_topic_page in ./advanced_help.module
Page callback to view a help topic.
1 string reference to 'advanced_help_index_page'
advanced_help_menu in ./advanced_help.module
Implements hook_menu().

File

./advanced_help.module, line 242
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();
  $output = array();

  // Print a search widget.
  $output['advanced_help_search'] = module_exists('search') ? drupal_get_form('advanced_help_search_form') : array(
    '#markup' => 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('Advanced help'), 'admin/help/ah');
    drupal_set_title(t('@module help index', array(
      '@module' => advanced_help_get_module_name($module),
    )));
    $output['items-module'] = array(
      '#theme' => 'item_list',
      '#items' => $items,
    );
  }
  else {

    // Print a module index.
    $modules = array();
    $result = db_query('SELECT * FROM {system}');
    foreach ($result as $info) {
      $module_info = unserialize($info->info);
      $modules[$info->name] = isset($module_info['name']) ? $module_info['name'] : $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/help/ah/{$module}");
      }
    }
    drupal_set_title(t('Advanced help'));
    $output['items-nomodule'] = array(
      '#theme' => 'item_list',
      '#items' => $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', array(
      'content' => $output,
    ));
    return;
  }
  $breadcrumb = array_merge(drupal_get_breadcrumb(), array_reverse($breadcrumb));
  drupal_set_breadcrumb($breadcrumb);
  return $output;
}