You are here

function _token_token_tree_format_row in Token 7

Same name and namespace in other branches
  1. 6 token.pages.inc \_token_token_tree_format_row()

Build a row in the token tree.

2 calls to _token_token_tree_format_row()
theme_token_tree in ./token.pages.inc
Provide a 'tree' display of nested tokens.
token_devel_token_object in ./token.pages.inc
Menu callback; prints the available tokens and values for an object.

File

./token.pages.inc, line 184
User page callbacks for the token module.

Code

function _token_token_tree_format_row($token, array $token_info, $is_group = FALSE) {

  // Build a statically cached array of default values. This is around four
  // times as efficient as building the base array from scratch each time this
  // function is called.
  static $defaults = array(
    'id' => '',
    'class' => array(),
    'data' => array(
      'name' => '',
      'token' => '',
      'value' => '',
      'description' => '',
    ),
  );
  $row = $defaults;
  $row['id'] = _token_clean_css_identifier($token);
  $row['data']['name'] = $token_info['name'];
  $row['data']['description'] = isset($token_info['description']) ? $token_info['description'] : '';
  if ($is_group) {

    // This is a token type/group.
    $row['class'][] = 'token-group';
  }
  else {

    // This is a token.
    $row['data']['token'] = array();
    $row['data']['token']['data'] = $token;
    $row['data']['token']['class'][] = 'token-key';
    if (isset($token_info['value'])) {
      $row['data']['value'] = $token_info['value'];
    }
    if (!empty($token_info['parent'])) {
      $row['parent'] = _token_clean_css_identifier($token_info['parent']);
    }
  }
  return $row;
}