You are here

function _commerce_bpc_show_tokens in Commerce Bulk Product Creation 7.2

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

Displays a list of available tokens in a table.

Parameters

string $type: The type of the tokens, as specified in hook_token_info().

array $avail_tokens: An array of tokens available for the current replacement.

Return value

array A renderable array displaying the tokens.

2 calls to _commerce_bpc_show_tokens()
bpc_display_settings_form in modules/bpc_display/bpc_display.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 416

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;
}