| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @file 5 * Hooks provided by the token module. 6 */ 7 8 /** 9 * @addtogroup hooks 10 * @{ 11 */ 12 13 /** 14 * Provide metadata about available placeholder tokens and token types. 15 * 16 * @param $type 17 * The type of tokens to list (e.g. 'global', 'node', or 'user'). To list all 18 * tokens, use 'all'. 19 * 20 * @return 21 * An associative array of available tokens. The base array is keys of token 22 * types and an array of its tokens. The token arrays are keys containing the 23 * raw name of the token and values containing its user-friendly name. 24 */ 25 function hook_token_list($type = 'all') { 26 $tokens = array(); 27 28 if ($type == 'global' || $type == 'all') { 29 $tokens['global']['random-number'] = t('A randomly generated number.'); 30 31 } 32 if ($type == 'node' || $type == 'all') { 33 $tokens['node']['node-random-nid'] = t("A randomly generated number between one and the node's unique ID."); 34 } 35 36 return $tokens; 37 } 38 39 /** 40 * Provide replacement values for placeholder tokens. 41 * 42 * @param $type 43 * The type of token being replaced (e.g. 'global', 'node', or 'user'). 44 * @param $data 45 * (optional) An object to be used when generating replacement values. 46 * @param $options 47 * (optional) A associative array of options to control the token replacement 48 * process. 49 * 50 * @return 51 * An associative array of replacement values, keyed by the original 'raw' 52 * tokens that were found in the source text. For example: 53 * $values['title-raw'] = 'My new node'; 54 */ 55 function hook_token_values($type, $object = NULL, $options = array()) { 56 $values = array(); 57 58 if ($type == 'global') { 59 $values['random-number'] = mt_rand(); 60 } 61 62 if ($type == 'node' && !empty($object)) { 63 $values['node-random-nid'] = mt_rand(1, $object->nid); 64 } 65 66 return $values; 67 } 68 69 /** 70 * @} End of "addtogroup hooks". 71 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |