You are here

function messaging_text_replace in Messaging 6.2

Same name and namespace in other branches
  1. 6 messaging.module \messaging_text_replace()
  2. 6.3 messaging.module \messaging_text_replace()

Do token replacement.

Uses token_logic if enabled, standard token replacement otherwise

File

./messaging.module, line 891

Code

function messaging_text_replace($text, $objects) {

  // Add some token types
  $objects['global'] = NULL;

  // Use token_logic if available, http://code.developmentseed.org/token_logic
  // Otherwise use standard contrib token module, http://drupal.org/project/token
  $function = 'token_replace_multiple';
  $param_arr = array(
    $text,
    $objects,
  );
  if (module_exists('token_logic')) {
    $function = 'token_logic_replace_multiple';
  }
  if (is_array($text)) {
    foreach ($text as $part => $line) {
      $param_arr[0] = $line;
      $text[$part] = call_user_func_array($function, $param_arr);
    }
  }
  else {
    $text = call_user_func_array($function, $param_arr);
  }
  return $text;
}