source: sipes/modules_contrib/token/tests/token_test.module @ d5990f8

stableversion-3.0
Last change on this file since d5990f8 was d5990f8, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se actualizo el modulo

  • Propiedad mode establecida a 100755
File size: 1.8 KB
Línea 
1<?php
2
3/**
4 * Implements hook_exit().
5 */
6function 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 */
19function 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 */
40function 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}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.