You are here

function safeword_tokens in Safeword 7

Same name and namespace in other branches
  1. 8 safeword.tokens.inc \safeword_tokens()

Implements hook_tokens().

File

./safeword.tokens.inc, line 30

Code

function safeword_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  $sanitize = !empty($options['sanitize']);
  $language_code = isset($options['language']) ? $options['language']->language : NULL;
  if ($type == 'safeword-field') {
    $item = $data['item'];
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'human':
        case 'machine':
          $replacements[$original] = $sanitize ? check_plain($item[$name]) : $item[$name];
          break;
      }
    }
  }
  return $replacements;
}