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

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

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


Revision 1.2 - (show annotations) (download) (as text)
Mon Apr 27 04:56:51 2009 UTC (7 months ago) by kmonty
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-ALPHA8, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-6--1
Changes since 1.1: +16 -15 lines
File MIME type: text/x-php
Fixed a bug with the path-related tokens.
1 <?php
2 // $Id: node_gallery.token.inc,v 1.1 2009/04/21 17:01:05 kmonty Exp $
3
4 /**
5 * @file
6 * Token module support for the Node Gallery module.
7 */
8
9 /**
10 * Implementation of hook_token_list().
11 */
12 function node_gallery_token_list($type = 'all') {
13 $tokens = array();
14 if ($type == 'node' || $type == 'all') {
15 $tokens['node']['parent-node-gallery-path'] = t('The path of the parent Gallery.');
16 $tokens['node']['parent-node-gallery-path-raw'] = t('Unfiltered path of the parent Gallery. WARNING - raw user input.');
17 $tokens['node']['parent-node-gallery-title'] = t('The title of the parent Gallery.');
18 $tokens['node']['parent-node-gallery-title-raw'] = t('Unfiltered title of the parent Gallery. WARNING - raw user input.');
19 return $tokens;
20 }
21 }
22
23 /**
24 * Implementation of hook_token_values().
25 */
26 function node_gallery_token_values($type, $object = NULL, $options = array()) {
27 $tokens = array();
28 if ($type == 'node' && gallery_config_gateway::is_type('image', $object->type) == TRUE) {
29
30 if ($object->gid) {
31 $parent_path = 'node/'. $object->gid;
32 if (module_exists('path')) {
33 $parent_path = drupal_get_path_alias($parent_path);
34 }
35
36 // Load up the title of the parent
37 $parent_title = db_result(db_query("SELECT title FROM {node} WHERE nid = '". $object->gid ."'"));
38 $tokens['parent-node-gallery-path'] = decode_entities(check_plain($parent_path));
39 $tokens['parent-node-gallery-path-raw'] = $parent_path;
40 $tokens['parent-node-gallery-title'] = decode_entities(check_plain($parent_title));
41 $tokens['parent-node-gallery-title-raw'] = $parent_title;
42 }
43 return $tokens;
44 }
45 }

  ViewVC Help
Powered by ViewVC 1.1.2