You are here

function advanced_help_topic_page in Advanced Help 7

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

Page callback to view a help topic.

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

File

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

Code

function advanced_help_topic_page($module, $topic) {
  if ('toc' == $topic) {
    return advanced_help_index_page($module);
  }
  $info = advanced_help_get_topic($module, $topic);
  if (!$info) {
    return drupal_not_found();
  }
  $popup = !empty($_GET['popup']) && user_access('view advanced help popup');
  drupal_set_title($info['title']);

  // Set up breadcrumb.
  $breadcrumb = array();
  $parent = $info;
  $pmodule = $module;

  // Loop checker.
  $checked = array();
  while (!empty($parent['parent'])) {
    if (strpos($parent['parent'], '%')) {
      list($pmodule, $ptopic) = explode('%', $parent['parent']);
    }
    else {
      $ptopic = $parent['parent'];
    }
    if (!empty($checked[$pmodule][$ptopic])) {
      break;
    }
    $checked[$pmodule][$ptopic] = TRUE;
    $parent = advanced_help_get_topic($pmodule, $ptopic);
    if (!$parent) {
      break;
    }
    $breadcrumb[] = advanced_help_l($parent['title'], "help/{$pmodule}/{$ptopic}");
  }
  $breadcrumb[] = advanced_help_l(advanced_help_get_module_name($pmodule), "admin/help/ah/{$pmodule}");
  $breadcrumb[] = advanced_help_l(t('Help'), "admin/help/ah");
  $output = advanced_help_view_topic($module, $topic, $popup);
  if (empty($output)) {
    $output = t('Missing help topic.');
  }
  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;
  }
  drupal_add_css(drupal_get_path('module', 'advanced_help') . '/help.css');
  $breadcrumb[] = l(t('Home'), '');
  drupal_set_breadcrumb(array_reverse($breadcrumb));
  return $output;
}