You are here

function flag_node::replace_tokens in Flag 7.2

Same name and namespace in other branches
  1. 5 flag.inc \flag_node::replace_tokens()
  2. 6.2 flag.inc \flag_node::replace_tokens()
  3. 6 flag.inc \flag_node::replace_tokens()
  4. 7.3 includes/flag/flag_node.inc \flag_node::replace_tokens()

Replaces tokens.

Overrides flag_entity::replace_tokens

File

./flag.inc, line 1624
Implements various flags. Uses object oriented style inspired by that of Views 2.

Class

flag_node
Implements a node flag.

Code

function replace_tokens($label, $contexts, $options, $content_id) {
  if (is_numeric($content_id) && ($node = $this
    ->fetch_content($content_id))) {
    $contexts['node'] = $node;
  }
  elseif (!empty($content_id) && ($type = node_type_get_type($content_id))) {
    $content_id = NULL;
    $contexts['node'] = (object) array(
      'nid' => NULL,
      'type' => $type->type,
      'title' => '',
    );
  }
  return parent::replace_tokens($label, $contexts, $options, $content_id);
}