telephone.module 2.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * @file
  4. * Defines a simple telephone number field type.
  5. */
  6. use Drupal\Core\Url;
  7. use Drupal\Core\Routing\RouteMatchInterface;
  8. /**
  9. * Implements hook_help().
  10. */
  11. function telephone_help($route_name, RouteMatchInterface $route_match) {
  12. switch ($route_name) {
  13. case 'help.page.telephone':
  14. $output = '';
  15. $output .= '<h3>' . t('About') . '</h3>';
  16. $output .= '<p>' . t('The Telephone module allows you to create fields that contain telephone numbers. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":telephone_documentation">online documentation for the Telephone module</a>.', [':field' => Url::fromRoute('help.page', ['name' => 'field'])->toString(), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? Url::fromRoute('help.page', ['name' => 'field_ui'])->toString() : '#', ':telephone_documentation' => 'https://www.drupal.org/documentation/modules/telephone']) . '</p>';
  17. $output .= '<h3>' . t('Uses') . '</h3>';
  18. $output .= '<dl>';
  19. $output .= '<dt>' . t('Managing and displaying telephone fields') . '</dt>';
  20. $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the telephone field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? Url::fromRoute('help.page', ['name' => 'field_ui'])->toString() : '#']) . '</dd>';
  21. $output .= '<dt>' . t('Displaying telephone numbers as links') . '</dt>';
  22. $output .= '<dd>' . t('Telephone numbers can be displayed as links with the scheme name <em>tel:</em> by choosing the <em>Telephone</em> display format on the <em>Manage display</em> page. Any spaces will be stripped out of the link text. This semantic markup improves the user experience on mobile and assistive technology devices.') . '</dd>';
  23. $output .= '</dl>';
  24. return $output;
  25. }
  26. }
  27. /**
  28. * Implements hook_field_formatter_info_alter().
  29. */
  30. function telephone_field_formatter_info_alter(&$info) {
  31. $info['string']['field_types'][] = 'telephone';
  32. }