page_title.tokens.inc 840 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * @file
  4. * Builds placeholder replacement tokens for page titles.
  5. */
  6. /**
  7. * Implements hook_token_info().
  8. */
  9. function page_title_token_info() {
  10. $info['tokens']['current-page']['page-title'] = array(
  11. 'name' => t('Page Title'),
  12. 'description' => t('The title of the current page, as processed by the Page Title module.'),
  13. );
  14. return $info;
  15. }
  16. /**
  17. * Implements hook_token_values().
  18. */
  19. function page_title_tokens($type, $tokens, array $data = array(), array $options = array()) {
  20. $replacements = array();
  21. $sanitize = !empty($options['sanitize']);
  22. if ($type == 'current-page') {
  23. foreach ($tokens as $name => $original) {
  24. switch ($name) {
  25. case 'page-title':
  26. $replacements[$original] = page_title_get_title(!$sanitize);
  27. break;
  28. }
  29. }
  30. }
  31. return $replacements;
  32. }