cck_phone.token.inc 952 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @file
  4. * Token hook implementations. Included if token.module is installed.
  5. */
  6. /**
  7. * Implementation of hook_token_list().
  8. *
  9. * Provide a user readable list of Phone Number tokens.
  10. */
  11. function cck_phone_token_list($type = 'all') {
  12. if ($type == 'field' || $type == 'all') {
  13. $tokens = array();
  14. $tokens['cck_phone']['number'] = t('Phone number');
  15. $tokens['cck_phone']['country_codes'] = t('Country code');
  16. $tokens['cck_phone']['extension'] = t('Extension');
  17. return $tokens;
  18. }
  19. }
  20. /**
  21. * Implementation of hook_token_values().
  22. */
  23. function cck_phone_token_values($type, $object = NULL, $options = array()) {
  24. $tokens = array();
  25. if ($type == 'field' && isset($object[0]['number'])) {
  26. $item = $object[0];
  27. $tokens['number'] = $item['number'];
  28. $tokens['country_codes'] = $item['country_codes'];
  29. $tokens['extension'] = isset($item['extension']) ? $item['extension'] : '';
  30. }
  31. return $tokens;
  32. }