You are here

function system_token_info in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/system.tokens.inc \system_token_info()

Implements hook_token_info().

File

core/modules/system/system.tokens.inc, line 16
Builds placeholder replacement tokens system-wide data.

Code

function system_token_info() {
  $types['site'] = array(
    'name' => t("Site information"),
    'description' => t("Tokens for site-wide settings and other global information."),
  );
  $types['date'] = array(
    'name' => t("Dates"),
    'description' => t("Tokens related to times and dates."),
  );

  // Site-wide global tokens.
  $site['name'] = array(
    'name' => t("Name"),
    'description' => t("The name of the site."),
  );
  $site['slogan'] = array(
    'name' => t("Slogan"),
    'description' => t("The slogan of the site."),
  );
  $site['mail'] = array(
    'name' => t("Email"),
    'description' => t("The administrative email address for the site."),
  );
  $site['url'] = array(
    'name' => t("URL"),
    'description' => t("The URL of the site's front page."),
  );
  $site['url-brief'] = array(
    'name' => t("URL (brief)"),
    'description' => t("The URL of the site's front page without the protocol."),
  );
  $site['login-url'] = array(
    'name' => t("Login page"),
    'description' => t("The URL of the site's login page."),
  );

  // Date related tokens.
  $date['short'] = array(
    'name' => t("Short format"),
    'description' => t("A date in 'short' format. (%date)", array(
      '%date' => format_date(REQUEST_TIME, 'short'),
    )),
  );
  $date['medium'] = array(
    'name' => t("Medium format"),
    'description' => t("A date in 'medium' format. (%date)", array(
      '%date' => format_date(REQUEST_TIME, 'medium'),
    )),
  );
  $date['long'] = array(
    'name' => t("Long format"),
    'description' => t("A date in 'long' format. (%date)", array(
      '%date' => format_date(REQUEST_TIME, 'long'),
    )),
  );
  $date['custom'] = array(
    'name' => t("Custom format"),
    'description' => t('A date in a custom format. See <a href="http://php.net/manual/function.date.php">the PHP documentation</a> for details.'),
  );
  $date['since'] = array(
    'name' => t("Time-since"),
    'description' => t("A date in 'time-since' format. (%date)", array(
      '%date' => \Drupal::service('date.formatter')
        ->formatTimeDiffSince(REQUEST_TIME - 360),
    )),
  );
  $date['raw'] = array(
    'name' => t("Raw timestamp"),
    'description' => t("A date in UNIX timestamp format (%date)", array(
      '%date' => REQUEST_TIME,
    )),
  );
  return array(
    'types' => $types,
    'tokens' => array(
      'site' => $site,
      'date' => $date,
    ),
  );
}