You are here

function theme_advanced_help_topic in Advanced Help 7

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

Display a help icon with a link to view the topic in a popup.

Parameters

array $variables: An associative array containing:

  • module: The module that owns this help topic.
  • topic: The identifier for the topic
  • type
    • 'icon' to display the question mark icon
    • 'title' to display the topic's title
    • any other text to display the text. Be sure to t() it!
1 theme call to theme_advanced_help_topic()
help_example_index_page in help_example/help_example.module
Topic index callback.

File

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

Code

function theme_advanced_help_topic($variables) {
  $module = $variables['module'];
  $topic = $variables['topic'];
  $type = $variables['type'];
  if ('toc' == $topic) {
    $info = array(
      'title' => 'Index page',
      'popup width' => 500,
      'popup height' => 500,
    );
  }
  else {
    $info = advanced_help_get_topic($module, $topic);
    if (!$info) {
      return;
    }
  }
  switch ($type) {
    case 'icon':
      $text = '<span>' . t('Help') . '</span>';
      $class = 'advanced-help-link';
      break;
    case 'title':
      $text = $info['title'];
      $class = 'advanced-help-title';
      break;
    default:
      $class = 'advanced-help-title';
      $text = $type;
      break;
  }
  if (user_access('view advanced help popup')) {
    drupal_add_css(drupal_get_path('module', 'advanced_help') . '/help-icon.css');
    return l($text, "help/{$module}/{$topic}", array(
      'attributes' => array(
        'class' => $class,
        'onclick' => "var w=window.open(this.href, 'advanced_help_window', 'width=" . $info['popup width'] . ",height=" . $info['popup height'] . ",scrollbars,resizable'); w.focus(); return false;",
        'title' => $info['title'],
      ),
      'query' => array(
        'popup' => TRUE,
      ),
      'html' => TRUE,
    ));
  }
  elseif (user_access('view advanced help topic')) {
    return l($text, "help/{$module}/{$topic}", array(
      'attributes' => array(
        'class' => $class,
        'title' => $info['title'],
      ),
      'html' => TRUE,
    ));
  }
}