1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Implements hook_exit(). |
---|
5 | */ |
---|
6 | function token_test_exit() { |
---|
7 | if ($debug = variable_get('token_page_tokens', array())) { |
---|
8 | $debug += array('tokens' => array(), 'data' => array(), 'options' => array()); |
---|
9 | foreach (array_keys($debug['tokens']) as $token) { |
---|
10 | $debug['values'][$token] = token_replace_multiple($token, $debug['data'], TOKEN_PREFIX, TOKEN_SUFFIX, $debug['options']); |
---|
11 | } |
---|
12 | variable_set('token_page_tokens', $debug); |
---|
13 | } |
---|
14 | } |
---|
15 | |
---|
16 | /** |
---|
17 | * Implements hook_token_list(). |
---|
18 | */ |
---|
19 | function token_test_token_list($type = 'all') { |
---|
20 | $tokens = array(); |
---|
21 | |
---|
22 | if ($type == 'all' || $type == 'global') { |
---|
23 | // Provide some wildcard tokens |
---|
24 | $tokens['token_test']['alpha'] = t("Token test Alpha."); |
---|
25 | $tokens['token_test']['beta-N'] = t("Token test Beta with wildcard."); |
---|
26 | $tokens['token_test']['gamma_?'] = t("Token test Gamme with wildcard."); |
---|
27 | $tokens['token_test']['delta-?'] = t("Token test Delta with wildcard."); |
---|
28 | $tokens['token_test']['epsilon-zeta-????'] = t("Token test Epsilon-Zeta with wildcard."); |
---|
29 | |
---|
30 | // Provide a token that returns a different value to test $options caching. |
---|
31 | $tokens['token_test']['option-foo'] = t('A token with various values.'); |
---|
32 | } |
---|
33 | |
---|
34 | return $tokens; |
---|
35 | } |
---|
36 | |
---|
37 | /** |
---|
38 | * Implements hook_token_values(). |
---|
39 | */ |
---|
40 | function token_test_token_values($type, $object = NULL, $options = array()) { |
---|
41 | $tokens = array(); |
---|
42 | |
---|
43 | if ($type == 'global') { |
---|
44 | // Provide some wildcard token values |
---|
45 | $tokens['alpha'] = 'Alpha'; |
---|
46 | $tokens['beta-1'] = 'Beta plus 1'; |
---|
47 | $tokens['beta-2'] = 'Beta plus 2'; |
---|
48 | $tokens['gamma_A'] = 'Gamma plus A'; |
---|
49 | $tokens['delta-extra'] = 'Delta plus extra'; |
---|
50 | $tokens['epsilon-zeta-A'] = 'Epsilon-Zeta plus A'; |
---|
51 | |
---|
52 | $tokens['option-foo'] = !empty($options['foo']) ? $options['foo'] : ''; |
---|
53 | } |
---|
54 | |
---|
55 | return $tokens; |
---|
56 | } |
---|