You are here

function flag_token_values in Flag 5

Same name and namespace in other branches
  1. 6.2 includes/flag.token.inc \flag_token_values()
  2. 6 includes/flag.token.inc \flag_token_values()

Implementation of hook_token_values().

File

includes/flag.token.inc, line 39
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));
    }
  }
  return $values;
}