You are here

function phone_token_info in Phone 7.2

Implements hook_token_info().

File

./phone.tokens.inc, line 14
Provides token integration for the phone module.

Code

function phone_token_info($type = 'all') {
  $types = array(
    'phone' => array(
      'name' => t('Phone field values'),
      'description' => t('Phone field in the default format.'),
      'needs-data' => 'phone',
    ),
  );
  $tokens = array();
  $tokens['component-countrycode'] = array(
    'name' => t('Component: Country code'),
    'description' => t('The two digit ISO country code for this number.'),
  );
  $tokens['component-callingcode'] = array(
    'name' => t('Component: Calling code'),
    'description' => t('The international calling code for this number.'),
  );
  $tokens['component-countryname'] = array(
    'name' => t('Component: Country name'),
    'description' => t('The name of the country for this number.'),
  );
  $tokens['component-extension'] = array(
    'name' => t('Component: Extension'),
    'description' => t('The extension for this number.'),
  );
  $tokens['component-number'] = array(
    'name' => t('Component: Number'),
    'description' => t('The un-altered number as entered.'),
  );
  $tokens['component-numbertypelabel'] = array(
    'name' => t('Component: Number type Label'),
    'description' => t('The number type of this number.'),
  );
  $tokens['component-numbertype'] = array(
    'name' => t('Component: Number type'),
    'description' => t('The number type id of the number type for this number.'),
  );

  // Create some formatted tokens that include useful options.
  // We don't make one for the tel: link, as this can be done
  // quite easily with the existing tokens using the rfc3966 formatter.
  $formatters = phone_field_formatter_info();
  foreach ($formatters as $name => $info) {
    $name = str_replace('_', '-', $name);
    $tokens['formatter-' . $name] = array(
      'name' => t('Formatted name: %formatter', array(
        '%formatter' => $info['label'],
      )),
      'description' => $info['description'],
    );
    $tokens['formatter-no-ext-' . $name] = array(
      'name' => t('Formatted name (without extension): %formatter', array(
        '%formatter' => $info['label'],
      )),
      'description' => $info['description'],
    );
    $tokens['formatter-alpha-' . $name] = array(
      'name' => t('Formatted name (keep alpha components): %formatter', array(
        '%formatter' => $info['label'],
      )),
      'description' => $info['description'],
    );
    $tokens['formatter-alpha-no-ext-' . $name] = array(
      'name' => t('Formatted name (keep alpha components, without extension): %formatter', array(
        '%formatter' => $info['label'],
      )),
      'description' => $info['description'],
    );
  }
  $token_info = array(
    'types' => $types,
    'tokens' => array(
      'phone' => $tokens,
    ),
  );
  foreach (phone_token_types_chained(NULL, TRUE) as $token_type => $tokens) {
    $token_info['tokens'][$token_type] = $tokens;
  }
  return $token_info;
}