You are here

public function AlphaPagination::buildTokenTree in Views Alpha Pagination 7.2

Builds a render array for displaying tokens.

Parameters

string $fieldset: The #fieldset name to assign.

Return value

array The render array for the token info.

File

src/AlphaPagination.php, line 80

Class

AlphaPagination
A base views handler for alpha pagination.

Code

public function buildTokenTree($fieldset = NULL) {
  static $build;
  if (!isset($build)) {
    if (module_exists('token')) {
      $build = [
        '#type' => 'container',
        '#title' => t('Browse available tokens'),
      ];
      $build['help'] = [
        '#theme' => 'token_tree_link',
        '#token_types' => [
          'alpha_pagination',
        ],
        '#global_types' => TRUE,
        '#dialog' => TRUE,
      ];
    }
    else {
      $build = [
        '#type' => 'fieldset',
        '#title' => 'Available tokens',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      ];
      $items = [];
      $token_info = alpha_pagination_token_info();
      foreach ($token_info['tokens'] as $_type => $_tokens) {
        foreach ($_tokens as $_token => $_data) {
          $items[] = "[{$_type}:{$_token}] - {$_data['description']}";
        }
      }
      $build['help'] = [
        '#theme' => 'item_list',
        '#items' => $items,
      ];
    }
  }
  return isset($fieldset) ? [
    '#fieldset' => $fieldset,
  ] + $build : $build;
}