You are here

function messaging_template_token_get_list in Messaging 6.3

Get list of tokens for text replacement

Parameters

$name: Message group to get tokens for

$tokens:

1 call to messaging_template_token_get_list()
messaging_template_edit_form in messaging_template/messaging_template.admin.inc
Edit message formats

File

messaging_template/messaging_template.admin.inc, line 360
Messaging Framework - Admin UI

Code

function messaging_template_token_get_list($name) {

  // First compile token types for this message group
  $type_list = module_invoke_all('messaging_template', 'tokens', $name);

  // Add known global tokens, will be always available
  $type_list[] = 'global';

  // Now get token list from token module for each type
  $return = array();
  foreach ($type_list as $type) {

    // This is a shortcut for single tokens for digests, with the form (token, description)
    if (is_array($type)) {
      list($type, $token) = $type;
      $list = token_get_list($type);
      $return[$type][$token] = $list[$type][$token];
    }
    elseif ($list = token_get_list($type)) {
      foreach ($list as $category => $tokens) {
        foreach ($tokens as $token => $description) {
          $return[$category][$token] = $description;
        }
      }
    }
  }
  return $return;
}