function biblio_tokens in Bibliography Module 7
Same name and namespace in other branches
- 7.2 biblio.module \biblio_tokens()
Parameters
$type:
$tokens:
$data:
$options:
Return value
array
File
- ./
biblio.tokens.inc, line 73
Code
function biblio_tokens($type, $tokens, $data = array(), $options = array()) {
$replacements = array();
if ($type == 'node' && !empty($data['node']) && $data['node']->type == 'biblio') {
$sanitize = !empty($options['sanitize']);
$node = $data['node'];
foreach (token_find_with_prefix($tokens, 'biblio') as $name => $original) {
switch ($name) {
case 'biblio_first_author':
$replacements[$original] = $sanitize ? check_plain($node->biblio_contributors[0]['lastname']) : $node->biblio_contributors[0]['lastname'];
break;
case 'biblio_type_name':
$type = db_query('SELECT name FROM {biblio_types} as t WHERE t.tid = :tid', array(
':tid' => $node->biblio_type,
))
->fetchField();
$replacements[$original] = $sanitize ? check_plain($type) : $type;
break;
default:
$replacements[$original] = $sanitize ? check_plain($node->{$name}) : $node->{$name};
}
}
}
return $replacements;
}