You are here

function _commerce_bpc_show_tokens in Commerce Bulk Product Creation 7

Same name and namespace in other branches
  1. 7.2 commerce_bpc.module \_commerce_bpc_show_tokens()

Displays tokens in a table.

Parameters

string $type: The type of the tokens to be displayed, as defined in hook_token_info().

array $avail_tokens: The tokens available for the current replacement.

Return value

array A renderable array displaying the tokens.

2 calls to _commerce_bpc_show_tokens()
commerce_bpc_display_node_settings_form in ./commerce_bpc.admin.inc
Form constructor for the commerce_bpc display node settings page.
commerce_bpc_pattern_settings_form in ./commerce_bpc.admin.inc
Form constructor for the commerce_bpc settings pages.

File

./commerce_bpc.module, line 541

Code

function _commerce_bpc_show_tokens($type, $avail_tokens = array()) {
  $rows = array();
  foreach ($avail_tokens as $token_name => $info) {
    $rows[] = array(
      '[' . $type . ':' . $token_name . ']',
      $info['name'],
      $info['description'],
    );
  }
  $tokens = array(
    '#type' => 'fieldset',
    '#title' => t('Tokens'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $tokens_table = array(
    'header' => array(
      t('Token'),
      t('Label'),
      t('Desription'),
    ),
    'rows' => $rows,
    'attributes' => array(),
    'caption' => t('Available Tokens'),
    'colgroups' => array(),
    'sticky' => FALSE,
    'empty' => '',
  );
  $tokens['available_tokens'] = array(
    '#type' => 'item',
    '#title' => t('You may use the following tokens:'),
    '#markup' => theme_table($tokens_table),
  );
  return $tokens;
}