You are here

function advanced_help_topic_page in Advanced Help 5

Same name and namespace in other branches
  1. 6 advanced_help.module \advanced_help_topic_page()
  2. 7 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
Implementation of hook_menu().

File

./advanced_help.module, line 317
advanced_help.module

Code

function advanced_help_topic_page($module, $topic) {
  $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/advanced_help/{$pmodule}");
  $breadcrumb[] = advanced_help_l(t('Help'), "admin/advanced_help");
  $output = advanced_help_view_topic($module, $topic, $popup);
  if (empty($output)) {
    $output = t('Missing help topic.');
  }
  if ($popup) {
    $GLOBALS['devel_shutdown'] = FALSE;

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

    //print theme('page', $output);
    return;
  }
  drupal_add_css(drupal_get_path('module', 'advanced_help') . '/help.css');
  $breadcrumb[] = l('Home', '');
  drupal_set_breadcrumb(array_reverse($breadcrumb));
  return $output;
}