| 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 |
}
|