You are here

function theme_webform_token_help in Webform 7.4

Same name and namespace in other branches
  1. 5.2 webform.module \theme_webform_token_help()
  2. 6.3 webform.module \theme_webform_token_help()
  3. 6.2 webform.module \theme_webform_token_help()
  4. 7.3 webform.module \theme_webform_token_help()

Output the contents of token help used throughout Webform.

In earlier versions of Token, a fieldset is used to show all the tokens. Later versions now use a modal dialog that is accessed through a link. If Token module is not available, a message should be displayed.

13 theme calls to theme_webform_token_help()
webform_component_edit_form in includes/webform.components.inc
Form to configure a webform component.
webform_configure_form in includes/webform.pages.inc
Main configuration form for editing a webform node.
webform_email_edit_form in includes/webform.emails.inc
Form for configuring an e-mail setting and template.
_webform_edit_component in ./webform.api.php
Generate the form for editing a component.
_webform_edit_email in components/email.inc
Implements _webform_edit_component().

... See full list

File

./webform.module, line 4489
This module provides a simple way to create forms and questionnaires.

Code

function theme_webform_token_help($variables) {
  if (!webform_variable_get('webform_token_access')) {
    return '';
  }
  $groups = $variables['groups'];

  // Assume dialogs are not supported, show as a fieldset.
  $help = array(
    '#title' => t('Token values'),
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#attributes' => array(
      'class' => array(
        'collapsible',
        'collapsed',
      ),
    ),
    'help' => array(
      '#markup' => '<p>' . t('This field supports dynamic token values. Common values might be [current-user:mail] or [node:title].') . '</p>',
    ),
    'token_tree' => array(
      '#theme' => 'token_tree',
      '#token_types' => $groups,
    ),
  );
  if (!module_exists('token')) {

    // No token module at all. Display a simple suggestion to enable it.
    $help['help']['#markup'] .= '<p>' . t('A full listing of tokens may be listed here by installing the <a href="http://drupal.org/project/token">Token module</a>.') . '</p>';
    unset($help['token_tree']);
  }
  else {
    module_load_include('inc', 'token', 'token.pages');
    if (function_exists('token_page_output_tree')) {

      // Token supports dialogs: display simply as a link.
      $help = $help['token_tree'];
      $help['#dialog'] = TRUE;
    }
  }
  return render($help);
}