You are here

function token_filter_replacetoken in Token Filter 5

Same name and namespace in other branches
  1. 6.2 token_filter.module \token_filter_replacetoken()
  2. 6 token_filter.module \token_filter_replacetoken()
1 string reference to 'token_filter_replacetoken'
token_filter_filter in ./token_filter.module

File

./token_filter.module, line 34

Code

function token_filter_replacetoken($matches) {
  global $user;
  $type = $matches[1];
  $token = $matches[2];
  switch ($type) {
    case 'global':
      $object = NULL;
      break;
    case 'user':
      $object = $user;
      break;
    default:
      drupal_set_message("Filter Error: token_filter doesn't yet handle objects of type {$type}", 'error');

      // Return the provided token so at least you can see which one is giving the error in the text
      return "%{$token}";
  }
  $output = token_replace($token, $type, $object = NULL, $leading = '', $trailing = '');
  return $output;
}