You are here

function biblio_token_info in Bibliography Module 7

Same name and namespace in other branches
  1. 7.2 biblio.module \biblio_token_info()

Return value

multitype:string NULL

File

./biblio.tokens.inc, line 10

Code

function biblio_token_info() {
  $schema = drupal_get_schema('biblio');
  $fields = array_diff_key($schema['fields'], array(
    'nid' => '',
    'vid' => '',
    'biblio_formats' => '',
  ));
  $node_token['biblio'] = array(
    'name' => t('Biblio'),
    'description' => t('Tokens related to the Biblio content type.'),
    'type' => 'biblio',
  );
  foreach ($fields as $key => $value) {
    $name = str_replace('biblio_', '', $key);
    $name = str_replace('_', ' ', $name);
    $name = ucwords($name);
    $biblio_tokens[$key] = array(
      'name' => t($name),
      'description' => isset($value['description']) ? t("!desc", array(
        '!desc' => $value['description'],
      )) : '',
    );
  }
  $biblio_tokens['biblio_first_author'] = array(
    'name' => t("Author - First"),
    'description' => 'First author of the publication',
  );
  $biblio_tokens['biblio_type_name'] = array(
    'name' => t("Type Name"),
    'description' => t('The name of the publication type (i.e. Journal, Book, etc.'),
  );
  $types['biblio'] = array(
    'name' => t('Biblio'),
    'description' => t('Tokens related to Biblio node type.'),
    'needs-data' => 'node',
  );

  /*
    $types['biblio-authors'] = array(
    'name' => t('Biblio Authors'),
    'description' => t('Tokens related to Biblio node type.'),
    'needs-data' => 'node',
    );
    $types['biblio-keywords'] = array(
    'name' => t('Biblio Keywords'),
    'description' => t('Tokens related to Biblio node type.'),
    'needs-data' => 'node',
    );
  */
  return array(
    'types' => $types,
    'tokens' => array(
      'biblio' => $biblio_tokens,
      'node' => $node_token,
    ),
  );
}