function RulesTokenEvaluator::help

Create documentation about the available replacement patterns.

Parameters

array $var_info: Array with the available variables.

Return value

array Renderable array with the replacement pattern documentation.

Overrides RulesDataInputEvaluator::help

File

modules/system.eval.inc, line 251

Class

RulesTokenEvaluator
A class implementing a rules input evaluator processing tokens.

Code

public static function help($var_info) {
    $render = array(
        '#type' => 'fieldset',
        '#title' => t('Replacement patterns'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#description' => t('Note that token replacements containing chained objects – such as [node:author:uid] – are not listed here, but are still available. The <em>data selection</em> input mode may help you find more complex replacement patterns. See <a href="@url">the online documentation</a> for more information about complex replacement patterns.', array(
            '@url' => rules_external_help('chained-tokens'),
        )),
    );
    $token_info = token_info();
    foreach ($var_info as $name => $info) {
        $token_types[$name] = _rules_system_token_map_type($info['type']);
    }
    foreach ($token_types as $name => $token_type) {
        if (isset($token_info['types'][$token_type])) {
            $render[$name] = array(
                '#theme' => 'table',
                '#header' => array(
                    t('Token'),
                    t('Label'),
                    t('Description'),
                ),
                '#prefix' => '<h3>' . t('Replacement patterns for %label', array(
                    '%label' => $var_info[$name]['label'],
                )) . '</h3>',
            );
            foreach ($token_info['tokens'][$token_type] as $token => $info) {
                $token = '[' . str_replace('_', '-', $name) . ':' . $token . ']';
                $render[$name]['#rows'][$token] = array(
                    check_plain($token),
                    check_plain($info['name']),
                    check_plain($info['description']),
                );
            }
        }
    }
    return $render;
}