summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-06-06 10:39:13 (GMT)
committerAlex Pott2013-06-06 10:39:13 (GMT)
commite26a156ab008622294cead96f8099f866d5600fa (patch)
tree35645e44ae4e81d0fa210ecf8c9fc7c290761bdd
parent88e6a760b719f06d49376c0549f0a8c41c0dbcbe (diff)
Issue #1801268 by falcon03, mgifford, Risse, heddn, larowlan: Change link field 'title' field to 'link text'.
-rw-r--r--core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkFormatter.php6
-rw-r--r--core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkSeparateFormatter.php12
-rw-r--r--core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php4
-rw-r--r--core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php36
-rw-r--r--core/modules/link/lib/Drupal/link/Type/LinkItem.php2
-rw-r--r--core/modules/link/link.module10
6 files changed, 35 insertions, 35 deletions
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 123eded..70406e8 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 @@ class LinkFormatter extends FormatterBase {
$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 b2d3882..93826f1 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 @@ use Drupal\field\Plugin\Type\Formatter\FormatterBase;
* @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 @@ class LinkSeparateFormatter extends LinkFormatter {
$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 8a1aebb..0784cae 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 @@ class LinkWidget extends WidgetBase {
);
$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 @@ class LinkWidget extends WidgetBase {
);
$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 1ec4ec4..5748970 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 @@ class LinkFieldTest extends WebTestBase {
}
/**
- * 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 @@ class LinkFieldTest extends WebTestBase {
'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 @@ class LinkFieldTest extends WebTestBase {
$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 @@ class LinkFieldTest extends WebTestBase {
$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 @@ class LinkFieldTest extends WebTestBase {
$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 @@ class LinkFieldTest extends WebTestBase {
// 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 @@ class LinkFieldTest extends WebTestBase {
// 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 ad20400..913a8f2 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 @@ class LinkItem extends FieldItemBase {
);
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 9f0fa1e..16091f1 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 .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . 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 <a href="@field-help">Field module help page</a> for more information about fields.', array('@field-help' => url('admin/help/field'))) . '</p>';
+ $output .= '<p>' . 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 <a href="@field-help">Field module help page</a> for more information about fields.', array('@field-help' => url('admin/help/field'))) . '</p>';
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 = '';