token_test.module in Token 6
File
tests/token_test.module
View source
<?php
function token_test_exit() {
if ($debug = variable_get('token_page_tokens', array())) {
$debug += array(
'tokens' => array(),
'data' => array(),
'options' => array(),
);
foreach (array_keys($debug['tokens']) as $token) {
$debug['values'][$token] = token_replace_multiple($token, $debug['data'], TOKEN_PREFIX, TOKEN_SUFFIX, $debug['options']);
}
variable_set('token_page_tokens', $debug);
}
}
function token_test_token_list($type = 'all') {
$tokens = array();
if ($type == 'all' || $type == 'global') {
$tokens['token_test']['alpha'] = t("Token test Alpha.");
$tokens['token_test']['beta-N'] = t("Token test Beta with wildcard.");
$tokens['token_test']['gamma_?'] = t("Token test Gamme with wildcard.");
$tokens['token_test']['delta-?'] = t("Token test Delta with wildcard.");
$tokens['token_test']['epsilon-zeta-????'] = t("Token test Epsilon-Zeta with wildcard.");
$tokens['token_test']['option-foo'] = t('A token with various values.');
}
return $tokens;
}
function token_test_token_values($type, $object = NULL, $options = array()) {
$tokens = array();
if ($type == 'global') {
$tokens['alpha'] = 'Alpha';
$tokens['beta-1'] = 'Beta plus 1';
$tokens['beta-2'] = 'Beta plus 2';
$tokens['gamma_A'] = 'Gamma plus A';
$tokens['delta-extra'] = 'Delta plus extra';
$tokens['epsilon-zeta-A'] = 'Epsilon-Zeta plus A';
$tokens['option-foo'] = !empty($options['foo']) ? $options['foo'] : '';
}
return $tokens;
}