diff --git a/core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkFormatter.php b/core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkFormatter.php index 123ededdc658d246154afad0c38eb876727c21d7..70406e87fff0459cd77d0572bbd8ffd8a5871946 100644 --- a/core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkFormatter.php +++ b/core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkFormatter.php @@ -150,17 +150,17 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { $settings = $this->getSettings(); foreach ($items as $delta => $item) { - // By default use the full URL as the link title. + // By default use the full URL as the link text. $link_title = $item['url']; - // If the title field value is available, use it for the link title. + // If the title field value is available, use it for the link text. if (empty($settings['url_only']) && !empty($item['title'])) { // Unsanitizied token replacement here because $options['html'] is FALSE // by default in theme_link(). $link_title = \Drupal::token()->replace($item['title'], array($entity->entityType() => $entity), array('sanitize' => FALSE, 'clear' => TRUE)); } - // Trim the link title to the desired length. + // Trim the link text to the desired length. if (!empty($settings['trim_length'])) { $link_title = truncate_utf8($link_title, $settings['trim_length'], FALSE, TRUE); } diff --git a/core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkSeparateFormatter.php b/core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkSeparateFormatter.php index b2d3882420a661314ea11baabed155f109602b23..93826f10521c814560bad3d44560a5224d797666 100644 --- a/core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkSeparateFormatter.php +++ b/core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkSeparateFormatter.php @@ -23,7 +23,7 @@ * @Plugin( * id = "link_separate", * module = "link", - * label = @Translation("Separate title and URL"), + * label = @Translation("Separate link text and URL"), * field_types = { * "link" * }, @@ -44,20 +44,20 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { $settings = $this->getSettings(); foreach ($items as $delta => $item) { - // By default use the full URL as the link title. + // By default use the full URL as the link text. $link_title = $item['url']; - // If the title field value is available, use it for the link title. + // If the link text field value is available, use it for the text. if (empty($settings['url_only']) && !empty($item['title'])) { // Unsanitized token replacement here because $options['html'] is FALSE // by default in theme_link(). $link_title = \Drupal::token()->replace($item['title'], array($entity->entityType() => $entity), array('sanitize' => FALSE, 'clear' => TRUE)); } - // The link_separate formatter has two titles; the link title (as in the - // field values) and the URL itself. If there is no title value, + // The link_separate formatter has two titles; the link text (as in the + // field values) and the URL itself. If there is no link text value, // $link_title defaults to the URL, so it needs to be unset. - // The URL title may need to be trimmed as well. + // The URL version may need to be trimmed as well. if (empty($item['title'])) { $link_title = NULL; } diff --git a/core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php b/core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php index 8a1aebbc09b986a28f7e68b02514bc9c4249d272..0784cae27de33292d74026f1f9426123faa8f873 100644 --- a/core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php +++ b/core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php @@ -45,7 +45,7 @@ public function formElement(array $items, $delta, array $element, $langcode, arr ); $element['title'] = array( '#type' => 'textfield', - '#title' => t('Title'), + '#title' => t('Link text'), '#placeholder' => $this->getSetting('placeholder_title'), '#default_value' => isset($items[$delta]['title']) ? $items[$delta]['title'] : NULL, '#maxlength' => 255, @@ -93,7 +93,7 @@ public function settingsForm(array $form, array &$form_state) { ); $elements['placeholder_title'] = array( '#type' => 'textfield', - '#title' => t('Placeholder for link title'), + '#title' => t('Placeholder for link text'), '#default_value' => $this->getSetting('placeholder_title'), '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), '#states' => array( diff --git a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php index 1ec4ec4ab8c85f6f8d62fb1924bfbd5b669b3b16..57489709d0e920cb4945851014fadd0c37a602a7 100644 --- a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php +++ b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php @@ -111,7 +111,7 @@ function testURLValidation() { } /** - * Tests the title settings of a link field. + * Tests the link title settings of a link field. */ function testLinkTitle() { // Create a field with settings to validate. @@ -135,7 +135,7 @@ function testLinkTitle() { 'type' => 'link_default', 'settings' => array( 'placeholder_url' => 'http://example.com', - 'placeholder_title' => 'Enter a title for this link', + 'placeholder_title' => 'Enter the text for this link', ), )) ->save(); @@ -148,9 +148,9 @@ function testLinkTitle() { $langcode = Language::LANGCODE_NOT_SPECIFIED; - // Verify that the title field works according to the field setting. + // Verify that the link text field works according to the field setting. foreach (array(DRUPAL_DISABLED, DRUPAL_REQUIRED, DRUPAL_OPTIONAL) as $title_setting) { - // Update the title field setting. + // Update the link title field setting. $this->instance['settings']['title'] = $title_setting; field_update_instance($this->instance); @@ -162,41 +162,41 @@ function testLinkTitle() { $this->assertRaw('placeholder="http://example.com"'); if ($title_setting === DRUPAL_DISABLED) { - $this->assertNoFieldByName("{$this->field['field_name']}[$langcode][0][title]", '', 'Title field not found.'); - $this->assertNoRaw('placeholder="Enter a title for this link"'); + $this->assertNoFieldByName("{$this->field['field_name']}[$langcode][0][title]", '', 'Link text field not found.'); + $this->assertNoRaw('placeholder="Enter the text for this link"'); } else { - $this->assertRaw('placeholder="Enter a title for this link"'); + $this->assertRaw('placeholder="Enter the text for this link"'); - $this->assertFieldByName("{$this->field['field_name']}[$langcode][0][title]", '', 'Title field found.'); + $this->assertFieldByName("{$this->field['field_name']}[$langcode][0][title]", '', 'Link text field found.'); if ($title_setting === DRUPAL_REQUIRED) { - // Verify that the title is required, if the URL is non-empty. + // Verify that the link text is required, if the URL is non-empty. $edit = array( "{$this->field['field_name']}[$langcode][0][url]" => 'http://www.example.com', ); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertText(t('!name field is required.', array('!name' => t('Title')))); + $this->assertText(t('!name field is required.', array('!name' => t('Link text')))); - // Verify that the title is not required, if the URL is empty. + // Verify that the link text is not required, if the URL is empty. $edit = array( "{$this->field['field_name']}[$langcode][0][url]" => '', ); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertNoText(t('!name field is required.', array('!name' => t('Title')))); + $this->assertNoText(t('!name field is required.', array('!name' => t('Link text')))); - // Verify that a URL and title meets requirements. + // Verify that a URL and link text meets requirements. $this->drupalGet('test-entity/add/test_bundle'); $edit = array( "{$this->field['field_name']}[$langcode][0][url]" => 'http://www.example.com', "{$this->field['field_name']}[$langcode][0][title]" => 'Example', ); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertNoText(t('!name field is required.', array('!name' => t('Title')))); + $this->assertNoText(t('!name field is required.', array('!name' => t('Link text')))); } } } - // Verify that a link without title is rendered using the URL as link text. + // Verify that a link without link text is rendered using the URL as text. $value = 'http://www.example.com/'; $edit = array( "{$this->field['field_name']}[$langcode][0][url]" => $value, @@ -211,7 +211,7 @@ function testLinkTitle() { $expected_link = l($value, $value); $this->assertRaw($expected_link); - // Verify that a link with title is rendered using the title as link text. + // Verify that a link with text is rendered using the link text. $title = $this->randomName(); $edit = array( "{$this->field['field_name']}[$langcode][0][title]" => $title, @@ -262,7 +262,7 @@ function testLinkFormatter() { // Create an entity with two link field values: // - The first field item uses a URL only. - // - The second field item uses a URL and title. + // - The second field item uses a URL and link text. // For consistency in assertion code below, the URL is assigned to the title // variable for the first field. $this->drupalGet('test-entity/add/test_bundle'); @@ -402,7 +402,7 @@ function testLinkSeparateFormatter() { // Create an entity with two link field values: // - The first field item uses a URL only. - // - The second field item uses a URL and title. + // - The second field item uses a URL and link text. // For consistency in assertion code below, the URL is assigned to the title // variable for the first field. $this->drupalGet('test-entity/add/test_bundle'); diff --git a/core/modules/link/lib/Drupal/link/Type/LinkItem.php b/core/modules/link/lib/Drupal/link/Type/LinkItem.php index ad2040085b73ba52715cb2a6882e821f3462519b..913a8f2780473a857d6e5d0850cc5600a0ecd652 100644 --- a/core/modules/link/lib/Drupal/link/Type/LinkItem.php +++ b/core/modules/link/lib/Drupal/link/Type/LinkItem.php @@ -35,7 +35,7 @@ public function getPropertyDefinitions() { ); self::$propertyDefinitions['title'] = array( 'type' => 'string', - 'label' => t('Title'), + 'label' => t('Link text'), ); self::$propertyDefinitions['attributes'] = array( 'type' => 'map', diff --git a/core/modules/link/link.module b/core/modules/link/link.module index 9f0fa1e75780397bbdb65f945cf9b2774ae23200..16091f129552e47f0ce7c4cb70d42b924ef79b20 100644 --- a/core/modules/link/link.module +++ b/core/modules/link/link.module @@ -15,7 +15,7 @@ function link_help($path, $arg) { case 'admin/help#link': $output = ''; $output .= '
' . t('The Link module defines a simple link field type for the Field module. Links are external URLs, can have an optional title for each link, and they can be formatted when displayed. See the Field module help page for more information about fields.', array('@field-help' => url('admin/help/field'))) . '
'; + $output .= '' . t('The Link module defines a simple link field type for the Field module. Links are external URLs, can have an optional link text for each link, and they can be formatted when displayed. See the Field module help page for more information about fields.', array('@field-help' => url('admin/help/field'))) . '
'; return $output; } } @@ -26,7 +26,7 @@ function link_help($path, $arg) { function link_field_info() { $types['link'] = array( 'label' => t('Link'), - 'description' => t('Stores a URL string, optional varchar title, and optional blob of attributes to assemble a link.'), + 'description' => t('Stores a URL string, optional varchar link text, and optional blob of attributes to assemble a link.'), 'instance_settings' => array( 'title' => DRUPAL_OPTIONAL, ), @@ -43,7 +43,7 @@ function link_field_info() { function link_field_instance_settings_form($field, $instance) { $form['title'] = array( '#type' => 'radios', - '#title' => t('Allow link title'), + '#title' => t('Allow link text'), '#default_value' => isset($instance['settings']['title']) ? $instance['settings']['title'] : DRUPAL_OPTIONAL, '#options' => array( DRUPAL_DISABLED => t('Disabled'), @@ -84,7 +84,7 @@ function link_field_is_empty($item, $field) { */ function link_field_presave(EntityInterface $entity, $field, $instance, $langcode, &$items) { foreach ($items as $delta => &$item) { - // Trim any spaces around the URL and title. + // Trim any spaces around the URL and link text. $item['url'] = trim($item['url']); $item['title'] = trim($item['title']); @@ -105,7 +105,7 @@ function link_theme() { } /** - * Formats a link as separate title and URL elements. + * Formats a link as separate link title and URL elements. */ function theme_link_formatter_link_separate($vars) { $output = '';