function flag_token_values in Flag 6.2
Same name and namespace in other branches
- 5 includes/flag.token.inc \flag_token_values()
- 6 includes/flag.token.inc \flag_token_values()
Implementation of hook_token_values().
File
- includes/
flag.token.inc, line 40 - Flag module tokens support.
Code
function flag_token_values($type, $object = NULL) {
$values = array();
if ($type == 'flag') {
$values['flag-name'] = check_plain($object->name);
$values['flag-title'] = check_plain($object
->get_title());
}
elseif ($type == 'flag-action') {
$values['flag-action'] = $object->action;
$values['flag-content-url'] = check_url($object->content_url);
$values['flag-content-title'] = check_plain($object->content_title);
$values['flag-content-type'] = $object->content_type;
$values['flag-content-id'] = $object->content_id;
$values['flag-count'] = $object->count;
}
if (in_array($type, flag_get_types())) {
$flags = flag_get_flags($type);
foreach ($flags as $flag) {
$values['flag-' . str_replace('_', '-', $flag->name) . '-count'] = $flag
->get_count($flag
->get_content_id($object));
$values['flag-' . str_replace('_', '-', $flag->name) . '-link'] = flag_create_link($flag->name, $flag
->get_content_id($object));
}
}
return $values;
}