You are here

function messaging_template_tokens_get_list in Messaging 6.4

Get list of tokens for text replacement

Parameters

$group: Message group to get tokens for

$tokens:

1 call to messaging_template_tokens_get_list()
messaging_template_admin_message_form in messaging_template/messaging_template.admin.inc
Edit message formats

File

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

Code

function messaging_template_tokens_get_list($group) {

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

  // 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[$token] = $list[$type][$token];
    }
    elseif ($list = token_get_list($type)) {
      foreach ($list as $category => $tokens) {
        foreach ($tokens as $token => $description) {
          $return[$token] = $description;
        }
      }
    }
  }
  return $return;
}