function subscriptions_taxonomy_tokens in Subscriptions 2.0.x
Same name and namespace in other branches
- 7 subscriptions_taxonomy.tokens.inc \subscriptions_taxonomy_tokens()
Implements hook_tokens().
Parameters
$type:
$tokens:
array $data:
array $options:
Return value
array
File
- subscriptions_taxonomy/
subscriptions_taxonomy.tokens.inc, line 37 - Token callbacks for the subscriptions_taxonomy module.
Code
function subscriptions_taxonomy_tokens($type, $tokens, array $data = array(), array $options = array()) {
$url_options = array(
'absolute' => TRUE,
);
if (isset($options['language'])) {
$url_options['language'] = $options['language'];
$language_code = $options['language']->language;
}
else {
$language_code = NULL;
}
$sanitize = !empty($options['sanitize']);
$replacements = array();
if ($type == 'subs' && !empty($data['subs']['category'])) {
$term = $data['subs']['category'];
foreach ($tokens as $name => $original) {
switch ($name) {
// Default values for the chained tokens handled below.
case 'category':
//$replacements[$original] = $sanitize ? filter_xss($term->name) : $term->name;
$replacements[$original] = render(taxonomy_term_view($term, 'full', $language_code));
break;
}
}
if ($term_tokens = token_find_with_prefix($tokens, 'category')) {
$replacements += token_generate('term', $term_tokens, array(
'term' => $term,
), $options);
}
}
return $replacements;
}