You are here

function shoutbox_rules_tokens in Shoutbox 7.2

Same name and namespace in other branches
  1. 7 shoutbox_rules/shoutbox_rules.tokens.inc \shoutbox_rules_tokens()

Implements hook_tokens().

File

shoutbox_rules/shoutbox_rules.tokens.inc, line 40
Provides tokens by the shoutbox_message data type.

Code

function shoutbox_rules_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $url_options = array(
    'absolute' => TRUE,
  );
  if (isset($options['language'])) {
    $url_options['language'] = $options['language'];
    $language_code = $options['language']->language;
  }
  else {
    $language_code = NULL;
  }
  $sanitize = !empty($options['sanitize']);
  $replacements = array();
  if ($type == 'shoutbox_message' && !empty($data['shoutbox_message'])) {
    $shoutbox_message = $data['shoutbox_message'];
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'shoutbox-message-id':
          $replacements[$original] = check_plain($shoutbox_message->shout_id);
          break;
        case 'shoutbox-message-body':
          $replacements[$original] = check_plain($shoutbox_message->shout);
          break;
        case 'shoutbox-message-body-raw':
          $replacements[$original] = $shoutbox_message->shout;
          break;
      }
    }
  }
  return $replacements;
}