| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @file 5 * Implementations of token module hooks for the core taxonomy module. 6 * 7 * The token module requires specific hooks to be added to modules 8 * so that those modules can return data about their objects to the 9 * token API. Until and unless token becomes a part of core, the 10 * implementations of the token hooks for core modules are provided 11 * in the token module itself. 12 * 13 * @ingroup token 14 */ 15 16 /** 17 * Implements hook_token_list(). 18 */ 19 function taxonomy_token_list($type = 'all') { 20 $tokens = array(); 21 22 // Taxonomy term tokens. 23 if ($type == 'taxonomy' || $type == 'all') { 24 $tokens['taxonomy']['tid'] = t('The unique ID of the taxonomy term.'); 25 $tokens['taxonomy']['cat'] = t('The name of the taxonomy term.'); 26 $tokens['taxonomy']['cat-raw'] = t('The name of the taxonomy term.'); 27 $tokens['taxonomy']['cat-description'] = t('The optional description of the taxonomy term.'); 28 $tokens['taxonomy']['vid'] = t("The unique ID of the taxonomy vocabulary the taxonomy term belongs to."); 29 $tokens['taxonomy']['vocab'] = t("The name of the taxonomy vocabulary the taxonomy term belongs to."); 30 $tokens['taxonomy']['vocab-raw'] = t("The name of the taxonomy vocabulary the taxonomy term belongs to."); 31 $tokens['taxonomy']['vocab-description'] = t('The optional description of the taxonomy vocabulary the taxonomy term belongs to.'); 32 $tokens['taxonomy']['vocab-description-raw'] = t('The optional description of the taxonomy vocabulary the taxonomy term belongs to.'); 33 } 34 35 // Vocabulary tokens. 36 if ($type == 'vocabulary' || $type == 'all') { 37 $tokens['vocabulary']['vocabulary-vid'] = t('The unique ID of the taxonomy vocabulary.'); 38 $tokens['vocabulary']['vocabulary-name'] = t('The name of the taxonomy vocabulary.'); 39 $tokens['vocabulary']['vocabulary-name-raw'] = t('The name of the taxonomy vocabulary.'); 40 $tokens['vocabulary']['vocabulary-description'] = t('The optional description of the taxonomy vocabulary.'); 41 $tokens['vocabulary']['vocabulary-description-raw'] = t('The optional description of the taxonomy vocabulary.'); 42 } 43 44 return $tokens; 45 } 46 47 /** 48 * Implements hook_token_values(). 49 */ 50 function taxonomy_token_values($type, $object = NULL, $options = array()) { 51 $values = array(); 52 53 // Taxonomy term tokens. 54 if ($type == 'taxonomy' && !empty($object)) { 55 $term = $object; 56 $vocabulary = taxonomy_vocabulary_load($term->vid); 57 58 $values['tid'] = $term->tid; 59 $values['cat'] = check_plain($term->name); 60 $values['cat-raw'] = $term->name; 61 $values['cat-description'] = filter_xss($term->description); 62 $values['vid'] = $term->vid; 63 $values['vocab'] = check_plain($vocabulary->name); 64 $values['vocab-raw'] = $vocabulary->name; 65 $values['vocab-description'] = filter_xss($vocabulary->description); 66 $values['vocab-description-raw'] = $vocabulary->description; 67 } 68 69 // Vocabulary tokens. 70 if ($type == 'vocabulary' && !empty($object)) { 71 $vocabulary = $object; 72 73 $values['vocabulary-vid'] = $vocabulary->vid; 74 $values['vocabulary-name'] = check_plain($vocabulary->name); 75 $values['vocabulary-name-raw'] = $vocabulary->name; 76 $values['vocabulary-description'] = filter_xss($vocabulary->description); 77 $values['vocabulary-description-raw'] = $vocabulary->description; 78 } 79 80 return $values; 81 }
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 |