function biblio_tokens in Bibliography Module 7.2
Same name and namespace in other branches
- 7 biblio.tokens.inc \biblio_tokens()
Implements hook_tokens().
File
- ./
biblio.module, line 2270
Code
function biblio_tokens($type, $tokens, $data = array(), $options = array()) {
$replacements = array();
if ($type == 'node' && !empty($data['node']) && $data['node']->type == 'biblio') {
$node = $data['node'];
foreach ($tokens as $name => $original) {
switch ($name) {
// Simple key values on the node.
case 'biblio_year':
$replacements[$original] = check_plain($node->biblio_year);
break;
case 'biblio_authors':
$replacements[$original] = check_plain($node->biblio_contributors[0]['lastname']);
break;
case 'biblio_type_id':
$replacements[$original] = check_plain($node->biblio_type);
break;
case 'biblio_citekey':
$replacements[$original] = check_plain($node->biblio_citekey);
break;
case 'biblio_type':
$type = db_query('SELECT name FROM {biblio_types} as t WHERE t.tid = :tid', array(
':tid' => $node->biblio_type,
))
->fetchField();
$replacements[$original] = check_plain($type);
break;
}
}
}
return $replacements;
}