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