function theme_webform_token_help in Webform 7.3
Same name and namespace in other branches
- 5.2 webform.module \theme_webform_token_help()
- 6.3 webform.module \theme_webform_token_help()
- 6.2 webform.module \theme_webform_token_help()
- 7.4 webform.module \theme_webform_token_help()
12 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().
File
- ./
webform.module, line 3257 - This module provides a simple way to create forms and questionnaires.
Code
function theme_webform_token_help($variables) {
$groups = $variables['groups'];
$groups = empty($groups) ? array(
'basic',
'node',
'special',
) : $groups;
static $tokens = array();
if (empty($tokens)) {
$tokens['basic'] = array(
'title' => t('Basic tokens'),
'tokens' => array(
'%username' => t('The name of the user if logged in. Blank for anonymous users.'),
'%useremail' => t('The e-mail address of the user if logged in. Blank for anonymous users.'),
'%ip_address' => t('The IP address of the user.'),
'%site' => t('The name of the site (i.e. %site_name)', array(
'%site_name' => variable_get('site_name', ''),
)),
'%date' => t('The current date, formatted according to the site settings.'),
),
);
$tokens['node'] = array(
'title' => t('Node tokens'),
'tokens' => array(
'%nid' => t('The node ID.'),
'%title' => t('The node title.'),
),
);
$tokens['special'] = array(
'title' => t('Special tokens'),
'tokens' => array(
'%profile[' . t('key') . ']' => t('Any user profile field or value, such as %profile[name] or %profile[profile_first_name]'),
'%get[' . t('key') . ']' => t('Tokens may be populated from the URL by creating URLs of the form http://example.com/my-form?foo=bar. Using the token %get[foo] would print "bar".'),
'%post[' . t('key') . ']' => t('Tokens may also be populated from POST values that are submitted by forms.'),
),
'description' => t('In addition to %get and %post, the following super tokens may be used, though only with logged-in users: %server, %cookie, and %request. For example %server[HTTP_USER_AGENT] or %session[id].'),
);
$tokens['email'] = array(
'title' => t('E-mail tokens'),
'tokens' => array(
'%email_values' => t('All included components in a hierarchical structure.'),
'%email[' . t('key') . '] ' => t('A formatted value and field label. Elements may be accessed such as <em>%email[fieldset_a][key_b]</em>. Do not include quotes.'),
'%submission_url' => t('The URL for viewing the completed submission.'),
),
);
$tokens['submission'] = array(
'title' => t('Submission tokens'),
'tokens' => array(
'%sid' => t('The unique submission ID.'),
'%value[key]' => t('A value without additional formatting. Elements may be accessed such as <em>%value[fieldset_a][key_b]</em>. Do not include quotes.'),
),
);
}
$output = '';
$output .= '<p>' . t('You may use special tokens in this field that will be replaced with dynamic values.') . '</p>';
foreach ($tokens as $group_name => $group) {
if (!is_array($groups) || in_array($group_name, $groups)) {
$items = array();
foreach ($group['tokens'] as $token => $token_description) {
$items[] = $token . ' - ' . $token_description;
}
$output .= theme('item_list', array(
'items' => $items,
'title' => $group['title'],
));
$output .= isset($group['description']) ? '<p>' . $group['description'] . '</p>' : '';
}
}
$fieldset = array(
'#title' => t('Token values'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#children' => '<div>' . $output . '</div>',
'#attributes' => array(
'class' => array(
'collapsible',
'collapsed',
),
),
);
return theme('fieldset', array(
'element' => $fieldset,
));
}