Commit 0ec15afa authored by yched's avatar yched

#1533506 followup by yched

parent 5367d989
......@@ -17,9 +17,7 @@ define('CONTENT_HANDLE_MODULE', 0x0002);
// We do not use hook_init(), since that hook is not fired in update.php, and we
// need token generation to be active within hook_update_N() (e.g. for
// node_save() calls.)
if (module_exists('token')) {
module_load_include('inc', 'content', 'includes/content.token');
}
require_once dirname(__FILE__) . '/includes/content.token.inc';
function content_help($path, $arg) {
switch ($path) {
......
......@@ -74,113 +74,3 @@ function content_token_list($type = 'all') {
return $list;
}
}
if (module_exists('nodereference')) {
function nodereference_token_list($type = 'all') {
if ($type == 'field' || $type == 'all') {
$tokens = array();
$tokens['node reference']['nid'] = t('Referenced node ID');
$tokens['node reference']['title'] = t('Referenced node title');
$tokens['node reference']['title-raw'] = t('Referenced node unfiltered title. WARNING - raw user input.');
$tokens['node reference']['link'] = t("Formatted html link to the referenced node.");
$tokens['node reference']['path'] = t("Relative path alias to the referenced node.");
$tokens['node reference']['url'] = t("Absolute path alias to the referenced node.");
return $tokens;
}
}
function nodereference_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
$item = $object[0];
$title = is_numeric($item['nid']) ? _nodereference_titles($item['nid']) : '';
$tokens['nid'] = $item['nid'];
$tokens['title'] = $title ? check_plain($title) : '';
$tokens['title-raw'] = $title;
$tokens['link'] = isset($item['view']) ? $item['view'] : '';
$tokens['path'] = is_numeric($item['nid']) ? url('node/' . $item['nid']) : '';
$tokens['url'] = is_numeric($item['nid']) ? url('node/' . $item['nid'], array('absolute' => TRUE)) : '';
return $tokens;
}
}
}
if (module_exists('number')) {
function number_token_list($type = 'all') {
if ($type == 'field' || $type == 'all') {
$tokens = array();
$tokens['number']['raw'] = t('Raw number value');
$tokens['number']['formatted'] = t('Formatted number value');
return $tokens;
}
}
function number_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
$item = $object[0];
$tokens['raw'] = $item['value'];
$tokens['formatted'] = isset($item['view']) ? $item['view'] : '';
return $tokens;
}
}
}
if (module_exists('text')) {
function text_token_list($type = 'all') {
if ($type == 'field' || $type == 'all') {
$tokens = array();
$tokens['text']['raw'] = t('Raw, unfiltered text');
$tokens['text']['formatted'] = t('Formatted and filtered text');
return $tokens;
}
}
function text_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
$item = $object[0];
$tokens['raw'] = $item['value'];
$tokens['formatted'] = isset($item['view']) ? $item['view'] : '';
return $tokens;
}
}
}
if (module_exists('userreference')) {
function userreference_token_list($type = 'all') {
if ($type == 'field' || $type == 'all') {
$tokens = array();
$tokens['user reference']['uid'] = t('Referenced user ID');
$tokens['user reference']['name'] = t('Referenced user name');
$tokens['user reference']['link'] = t('Formatted HTML link to referenced user');
$tokens['user reference']['path'] = t("Relative path alias to the referenced user.");
$tokens['user reference']['url'] = t("Absolute path alias to the referenced user.");
return $tokens;
}
}
function userreference_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
$item = $object[0];
$tokens['uid'] = $item['uid'];
$tokens['name'] = isset($item['view']) ? strip_tags($item['view']) : '';
$tokens['link'] = isset($item['view']) ? $item['view'] : '';
$tokens['path'] = is_numeric($item['uid']) ? url('user/' . $item['uid']) : '';
$tokens['url'] = is_numeric($item['uid']) ? url('user/' . $item['uid'], array('absolute' => TRUE)) : '';
return $tokens;
}
}
}
......@@ -5,6 +5,11 @@
* Defines a field type for referencing one node from another.
*/
// We do not use hook_init(), since that hook is not fired in update.php, and we
// need token generation to be active within hook_update_N() (e.g. for
// node_save() calls.)
require_once dirname(__FILE__) . '/nodereference.token.inc';
/**
* Implementation of hook_menu().
*/
......
<?php
/**
* @file
* Provides tokens for nodereference fields.
*/
/**
* Implementation of hook_token_list().
*/
function nodereference_token_list($type = 'all') {
if ($type == 'field' || $type == 'all') {
$tokens = array();
$tokens['node reference']['nid'] = t('Referenced node ID');
$tokens['node reference']['title'] = t('Referenced node title');
$tokens['node reference']['title-raw'] = t('Referenced node unfiltered title. WARNING - raw user input.');
$tokens['node reference']['link'] = t("Formatted html link to the referenced node.");
$tokens['node reference']['path'] = t("Relative path alias to the referenced node.");
$tokens['node reference']['url'] = t("Absolute path alias to the referenced node.");
return $tokens;
}
}
/**
* Implementation of hook_token_values().
*/
function nodereference_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
$item = $object[0];
$title = is_numeric($item['nid']) ? _nodereference_titles($item['nid']) : '';
$tokens['nid'] = $item['nid'];
$tokens['title'] = $title ? check_plain($title) : '';
$tokens['title-raw'] = $title;
$tokens['link'] = isset($item['view']) ? $item['view'] : '';
$tokens['path'] = is_numeric($item['nid']) ? url('node/' . $item['nid']) : '';
$tokens['url'] = is_numeric($item['nid']) ? url('node/' . $item['nid'], array('absolute' => TRUE)) : '';
return $tokens;
}
}
......@@ -5,6 +5,11 @@
* Defines numeric field types.
*/
// We do not use hook_init(), since that hook is not fired in update.php, and we
// need token generation to be active within hook_update_N() (e.g. for
// node_save() calls.)
require_once dirname(__FILE__) . '/number.token.inc';
/**
* Implementation of hook_theme().
*/
......
<?php
/**
* @file
* Provides tokens for number fields.
*/
/**
* Implementation of hook_token_list().
*/
function number_token_list($type = 'all') {
if ($type == 'field' || $type == 'all') {
$tokens = array();
$tokens['number']['raw'] = t('Raw number value');
$tokens['number']['formatted'] = t('Formatted number value');
return $tokens;
}
}
/**
* Implementation of hook_token_values().
*/
function number_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
$item = $object[0];
$tokens['raw'] = $item['value'];
$tokens['formatted'] = isset($item['view']) ? $item['view'] : '';
return $tokens;
}
}
......@@ -5,6 +5,11 @@
* Defines simple text field types.
*/
// We do not use hook_init(), since that hook is not fired in update.php, and we
// need token generation to be active within hook_update_N() (e.g. for
// node_save() calls.)
require_once dirname(__FILE__) . '/text.token.inc';
/**
* Implementation of hook_theme().
*/
......
<?php
/**
* @file
* Provides tokens for text fields.
*/
/**
* Implementation of hook_token_list().
*/
function text_token_list($type = 'all') {
if ($type == 'field' || $type == 'all') {
$tokens = array();
$tokens['text']['raw'] = t('Raw, unfiltered text');
$tokens['text']['formatted'] = t('Formatted and filtered text');
return $tokens;
}
}
/**
* Implementation of hook_token_values().
*/
function text_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
$item = $object[0];
$tokens['raw'] = $item['value'];
$tokens['formatted'] = isset($item['view']) ? $item['view'] : '';
return $tokens;
}
}
......@@ -5,6 +5,11 @@
* Defines a field type for referencing a user from a node.
*/
// We do not use hook_init(), since that hook is not fired in update.php, and we
// need token generation to be active within hook_update_N() (e.g. for
// node_save() calls.)
require_once dirname(__FILE__) . '/userreference.token.inc';
/**
* Implementation of hook_menu().
*/
......
<?php
/**
* @file
* Provides tokens for userreference fields.
*/
/**
* Implementation of hook_token_list().
*/
function userreference_token_list($type = 'all') {
if ($type == 'field' || $type == 'all') {
$tokens = array();
$tokens['user reference']['uid'] = t('Referenced user ID');
$tokens['user reference']['name'] = t('Referenced user name');
$tokens['user reference']['link'] = t('Formatted HTML link to referenced user');
$tokens['user reference']['path'] = t("Relative path alias to the referenced user.");
$tokens['user reference']['url'] = t("Absolute path alias to the referenced user.");
return $tokens;
}
}
/**
* Implementation of hook_token_values().
*/
function userreference_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
$item = $object[0];
$tokens['uid'] = $item['uid'];
$tokens['name'] = isset($item['view']) ? strip_tags($item['view']) : '';
$tokens['link'] = isset($item['view']) ? $item['view'] : '';
$tokens['path'] = is_numeric($item['uid']) ? url('user/' . $item['uid']) : '';
$tokens['url'] = is_numeric($item['uid']) ? url('user/' . $item['uid'], array('absolute' => TRUE)) : '';
return $tokens;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment