drupal/core/modules/email/email.module

53 lines
1.4 KiB
Plaintext

<?php
/**
* @file
* Defines a simple e-mail field type.
*/
/**
* Implements hook_help().
*/
function email_help($path, $arg) {
switch ($path) {
case 'admin/help#email':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The E-mail module defines a field for storing e-mail addresses, for use with the Field module. E-mail addresses are validated to ensure they match the expected format. See the <a href="@field-help">Field module help page</a> for more information about fields.', array('@field-help' => url('admin/help/field'))) . '</p>';
return $output;
}
}
/**
* Implements hook_field_info().
*/
function email_field_info() {
return array(
'email' => array(
'label' => t('E-mail'),
'description' => t('This field stores an e-mail address in the database.'),
'default_widget' => 'email_default',
'default_formatter' => 'email_mailto',
'class' => 'Drupal\Core\Entity\Plugin\DataType\EmailItem',
),
);
}
/**
* Implements hook_field_info_alter().
*/
function email_field_info_alter(&$info) {
if (module_exists('text')) {
$info['email']['default_formatter'] = 'text_plain';
}
}
/**
* Implements hook_field_formatter_info_alter().
*/
function email_field_formatter_info_alter(&$info) {
if (isset($info['text_plain'])) {
$info['text_plain']['field_types'][] = 'email';
}
}