/[drupal]/contributions/modules/location/location.token.inc
ViewVC logotype

Contents of /contributions/modules/location/location.token.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Tue Oct 7 22:07:05 2008 UTC (13 months, 2 weeks ago) by bdragon
Branch: MAIN
CVS Tags: DRUPAL-6--3-0-RC2, DRUPAL-6--3-1-RC1, DRUPAL-6--3-0-UNSTABLE4, DRUPAL-6--3-0, HEAD
Branch point for: DRUPAL-6--3
Changes since 1.1: +5 -2 lines
File MIME type: text/x-php
#317998 by szy, mburak: Don't attempt to tokenize arrays.
1 <?php
2 // $Id: location.token.inc,v 1.1 2008/09/29 20:31:20 bdragon Exp $
3
4 /**
5 * @file
6 * Short description.
7 */
8
9
10 /**
11 * Implementation of hook_token_values().
12 */
13 function _location_token_values($type, $object = NULL) {
14 if ($type == 'node' || $type == 'user') {
15 if (!empty($object->locations)) {
16 // @@@ Strip virtual fields?
17 foreach ($object->locations as $key => $location) {
18 foreach ($location as $field => $value) {
19 if (!is_array($value)) {
20 $values["location-{$field}_{$key}"] = check_plain($value);
21 }
22 }
23 // Backwards compatibility.
24 $values["location-provincename_$key"] = $values["location-province_name_$key"];
25 $values["location-countryname_$key"] = $values["location-country_name_$key"];
26 }
27 return $values;
28 }
29 }
30 }
31
32 /**
33 * Implementation of hook_token_list().
34 */
35 function _location_token_list($type = 'all') {
36 if ($type == 'node' || $type == 'user' || $type == 'all') {
37 $tokens['location']['location-name_N'] = t('Location Name (If there are multiple locations per node, N is the iteration, starting with 0)');
38 $tokens['location']['location-street_N'] = t('Street (If there are multiple locations per node, N is the iteration, starting with 0)');
39 $tokens['location']['location-additional_N'] = t('Additional (If there are multiple locations per node, N is the iteration, starting with 0)');
40 $tokens['location']['location-city_N'] = t('City (If there are multiple locations per node, N is the iteration, starting with 0)');
41 $tokens['location']['location-province_N'] = t('State/Province (If there are multiple locations per node, N is the iteration, starting with 0)');
42 $tokens['location']['location-province_name_N'] = t('State/Province Name (If there are multiple locations per node, N is the iteration, starting with 0)');
43 $tokens['location']['location-postal_code_N'] = t('Postal Code (If there are multiple locations per node, N is the iteration, starting with 0)');
44 $tokens['location']['location-latitude_N'] = t('Latitude (If there are multiple locations per node, N is the iteration, starting with 0)');
45 $tokens['location']['location-longitude_N'] = t('Longitude (If there are multiple locations per node, N is the iteration, starting with 0)');
46 $tokens['location']['location-country_N'] = t('Country (If there are multiple locations per node, N is the iteration, starting with 0)');
47 $tokens['location']['location-country_name_N'] = t('Country Name (If there are multiple locations per node, N is the iteration, starting with 0)');
48 return $tokens;
49 }
50 }

  ViewVC Help
Powered by ViewVC 1.1.2