summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-04-19 08:16:41 (GMT)
committerAlex Pott2013-04-19 08:16:41 (GMT)
commit1ad0adedc541bfb27ab5808f9e0f8a3bce81ba5a (patch)
treeeb03c5dfe19e1f81b86dc58101d36bc123f9da8f
parent1ebed3a04c9d6fe5a3a4fab8a9d1db42c0bdea69 (diff)
Issue #1796316 by netsensei, swentel, jibran, zuuperman, amateescu: Convert Link/URL widgets / formatters to plugin system.
-rw-r--r--core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkFormatter.php187
-rw-r--r--core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkSeparateFormatter.php80
-rw-r--r--core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php121
-rw-r--r--core/modules/link/link.module317
4 files changed, 388 insertions, 317 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
new file mode 100644
index 0000000..b71f17e
--- /dev/null
+++ b/core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkFormatter.php
@@ -0,0 +1,187 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\link\Plugin\field\formatter\LinkFormatter.
+ */
+
+namespace Drupal\link\Plugin\field\formatter;
+
+use Drupal\Component\Annotation\Plugin;
+use Drupal\Core\Annotation\Translation;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\field\Plugin\Type\Formatter\FormatterBase;
+
+/**
+ * Plugin implementation of the 'link' formatter.
+ *
+ * @Plugin(
+ * id = "link",
+ * module = "link",
+ * label = @Translation("Link"),
+ * field_types = {
+ * "link"
+ * },
+ * settings = {
+ * "trim_length" = "80",
+ * "url_only" = "",
+ * "url_plain" = "",
+ * "rel" = "",
+ * "target" = ""
+ * }
+ * )
+ */
+class LinkFormatter extends FormatterBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function settingsForm(array $form, array &$form_state) {
+ $elements = parent::settingsForm($form, $form_state);
+
+ $elements['trim_length'] = array(
+ '#type' => 'number',
+ '#title' => t('Trim link text length'),
+ '#field_suffix' => t('characters'),
+ '#default_value' => $this->getSetting('trim_length'),
+ '#min' => 1,
+ '#description' => t('Leave blank to allow unlimited link text lengths.'),
+ );
+ $elements['url_only'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('URL only'),
+ '#default_value' => $this->getSetting('url_only'),
+ '#access' => $this->getPluginId() == 'link',
+ );
+ $elements['url_plain'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Show URL as plain text'),
+ '#default_value' => $this->getSetting('url_plain'),
+ '#access' => $this->getPluginId() == 'link',
+ '#states' => array(
+ 'visible' => array(
+ ':input[name*="url_only"]' => array('checked' => TRUE),
+ ),
+ ),
+ );
+ $elements['rel'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Add rel="nofollow" to links'),
+ '#return_value' => 'nofollow',
+ '#default_value' => $this->getSetting('rel'),
+ );
+ $elements['target'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Open link in new window'),
+ '#return_value' => '_blank',
+ '#default_value' => $this->getSetting('target'),
+ );
+
+ return $elements;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function settingsSummary() {
+ $summary = array();
+
+ $settings = $this->getSettings();
+
+ if (!empty($settings['trim_length'])) {
+ $summary[] = t('Link text trimmed to @limit characters', array('@limit' => $settings['trim_length']));
+ }
+ else {
+ $summary[] = t('Link text not trimmed');
+ }
+ if ($this->getPluginId() == 'link' && !empty($settings['url_only'])) {
+ if (!empty($settings['url_plain'])) {
+ $summary[] = t('Show URL only as plain-text');
+ }
+ else {
+ $summary[] = t('Show URL only');
+ }
+ }
+ if (!empty($settings['rel'])) {
+ $summary[] = t('Add rel="@rel"', array('@rel' => $settings['rel']));
+ }
+ if (!empty($settings['target'])) {
+ $summary[] = t('Open link in new window');
+ }
+
+ return implode('<br />', $summary);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function prepareView(array $entities, $langcode, array &$items) {
+ $settings = $this->getSettings();
+
+ foreach ($entities as $id => $entity) {
+ foreach ($items[$id] as $delta => &$item) {
+
+ // Split out the link into the parts required for url(): path and options.
+ $parsed = drupal_parse_url($item['url']);
+ $item['path'] = $parsed['path'];
+ $item['options'] = array(
+ 'query' => $parsed['query'],
+ 'fragment' => $parsed['fragment'],
+ 'attributes' => &$item['attributes'],
+ );
+
+ // Add optional 'rel' attribute to link options.
+ if (!empty($settings['rel'])) {
+ $item['options']['attributes']['rel'] = $settings['rel'];
+ }
+ // Add optional 'target' attribute to link options.
+ if (!empty($settings['target'])) {
+ $item['options']['attributes']['target'] = $settings['target'];
+ }
+ }
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function viewElements(EntityInterface $entity, $langcode, array $items) {
+ $element = array();
+ $settings = $this->getSettings();
+
+ foreach ($items as $delta => $item) {
+ // By default use the full URL as the link title.
+ $link_title = $item['url'];
+
+ // If the title field value is available, use it for the link title.
+ 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.
+ if (!empty($settings['trim_length'])) {
+ $link_title = truncate_utf8($link_title, $settings['trim_length'], FALSE, TRUE);
+ }
+
+ if (!empty($settings['url_only']) && !empty($settings['url_plain'])) {
+ $element[$delta] = array(
+ '#type' => 'markup',
+ '#markup' => check_plain($link_title),
+ );
+ }
+ else {
+ $element[$delta] = array(
+ '#type' => 'link',
+ '#title' => $link_title,
+ '#href' => $item['path'],
+ '#options' => $item['options'],
+ );
+ }
+ }
+
+ return $element;
+ }
+}
+
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
new file mode 100644
index 0000000..b2d3882
--- /dev/null
+++ b/core/modules/link/lib/Drupal/link/Plugin/field/formatter/LinkSeparateFormatter.php
@@ -0,0 +1,80 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\link\Plugin\field\formatter\LinkSeparateFormatter.
+ *
+ * @todo
+ * Merge into 'link' formatter once there is a #type like 'item' that
+ * can render a compound label and content outside of a form context.
+ * http://drupal.org/node/1829202
+ */
+
+namespace Drupal\link\Plugin\field\formatter;
+
+use Drupal\Component\Annotation\Plugin;
+use Drupal\Core\Annotation\Translation;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\field\Plugin\Type\Formatter\FormatterBase;
+
+/**
+ * Plugin implementation of the 'link_separate' formatter.
+ *
+ * @Plugin(
+ * id = "link_separate",
+ * module = "link",
+ * label = @Translation("Separate title and URL"),
+ * field_types = {
+ * "link"
+ * },
+ * settings = {
+ * "trim_length" = "80",
+ * "rel" = "",
+ * "target" = ""
+ * }
+ * )
+ */
+class LinkSeparateFormatter extends LinkFormatter {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function viewElements(EntityInterface $entity, $langcode, array $items) {
+ $element = array();
+ $settings = $this->getSettings();
+
+ foreach ($items as $delta => $item) {
+ // By default use the full URL as the link title.
+ $link_title = $item['url'];
+
+ // If the title field value is available, use it for the link title.
+ 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,
+ // $link_title defaults to the URL, so it needs to be unset.
+ // The URL title may need to be trimmed as well.
+ if (empty($item['title'])) {
+ $link_title = NULL;
+ }
+ $url_title = $item['url'];
+ if (!empty($settings['trim_length'])) {
+ $link_title = truncate_utf8($link_title, $settings['trim_length'], FALSE, TRUE);
+ $url_title = truncate_utf8($item['url'], $settings['trim_length'], FALSE, TRUE);
+ }
+ $element[$delta] = array(
+ '#theme' => 'link_formatter_link_separate',
+ '#title' => $link_title,
+ '#url_title' => $url_title,
+ '#href' => $item['path'],
+ '#options' => $item['options'],
+ );
+ }
+ return $element;
+ }
+}
+
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
new file mode 100644
index 0000000..8a1aebb
--- /dev/null
+++ b/core/modules/link/lib/Drupal/link/Plugin/field/widget/LinkWidget.php
@@ -0,0 +1,121 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\link\Plugin\field\widget\LinkWidget.
+ */
+
+namespace Drupal\link\Plugin\field\widget;
+
+use Drupal\Component\Annotation\Plugin;
+use Drupal\Core\Annotation\Translation;
+use Drupal\field\Plugin\Type\Widget\WidgetBase;
+
+/**
+ * Plugin implementation of the 'link' widget.
+ *
+ * @Plugin(
+ * id = "link_default",
+ * module = "link",
+ * label = @Translation("Link"),
+ * field_types = {
+ * "link"
+ * },
+ * settings = {
+ * "placeholder_url" = "",
+ * "placeholder_title" = ""
+ * }
+ * )
+ */
+class LinkWidget extends WidgetBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
+ $instance = $this->instance;
+
+ $element['url'] = array(
+ '#type' => 'url',
+ '#title' => t('URL'),
+ '#placeholder' => $this->getSetting('placeholder_url'),
+ '#default_value' => isset($items[$delta]['url']) ? $items[$delta]['url'] : NULL,
+ '#maxlength' => 2048,
+ '#required' => $element['#required'],
+ );
+ $element['title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title'),
+ '#placeholder' => $this->getSetting('placeholder_title'),
+ '#default_value' => isset($items[$delta]['title']) ? $items[$delta]['title'] : NULL,
+ '#maxlength' => 255,
+ '#access' => $instance['settings']['title'] != DRUPAL_DISABLED,
+ );
+ // Post-process the title field to make it conditionally required if URL is
+ // non-empty. Omit the validation on the field edit form, since the field
+ // settings cannot be saved otherwise.
+ $is_field_edit_form = ($element['#entity'] === NULL);
+ if (!$is_field_edit_form && $instance['settings']['title'] == DRUPAL_REQUIRED) {
+ $element['#element_validate'] = array(array($this, 'validateTitle'));
+ }
+
+ // Exposing the attributes array in the widget is left for alternate and more
+ // advanced field widgets.
+ $element['attributes'] = array(
+ '#type' => 'value',
+ '#tree' => TRUE,
+ '#value' => !empty($items[$delta]['attributes']) ? $items[$delta]['attributes'] : array(),
+ '#attributes' => array('class' => array('link-field-widget-attributes')),
+ );
+
+ // If cardinality is 1, ensure a label is output for the field by wrapping it
+ // in a details element.
+ if ($this->field['cardinality'] == 1) {
+ $element += array(
+ '#type' => 'fieldset',
+ );
+ }
+
+ return $element;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function settingsForm(array $form, array &$form_state) {
+ $elements = parent::settingsForm($form, $form_state);
+
+ $elements['placeholder_url'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Placeholder for URL'),
+ '#default_value' => $this->getSetting('placeholder_url'),
+ '#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.'),
+ );
+ $elements['placeholder_title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Placeholder for link title'),
+ '#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(
+ 'invisible' => array(
+ ':input[name="instance[settings][title]"]' => array('value' => DRUPAL_DISABLED),
+ ),
+ ),
+ );
+
+ return $elements;
+ }
+
+ /**
+ * Form element validation handler for link_field_widget_form().
+ *
+ * Conditionally requires the link title if a URL value was filled in.
+ */
+ function validateTitle(&$element, &$form_state, $form) {
+ if ($element['url']['#value'] !== '' && $element['title']['#value'] === '') {
+ $element['title']['#required'] = TRUE;
+ form_error($element['title'], t('!name field is required.', array('!name' => $element['title']['#title'])));
+ }
+ }
+}
+
diff --git a/core/modules/link/link.module b/core/modules/link/link.module
index 8282421..9f0fa1e 100644
--- a/core/modules/link/link.module
+++ b/core/modules/link/link.module
@@ -94,323 +94,6 @@ function link_field_presave(EntityInterface $entity, $field, $instance, $langcod
}
/**
- * Implements hook_field_widget_info().
- */
-function link_field_widget_info() {
- $widgets['link_default'] = array(
- 'label' => 'Link',
- 'field types' => array('link'),
- 'settings' => array(
- 'placeholder_title' => '',
- 'placeholder_url' => '',
- ),
- );
- return $widgets;
-}
-
-/**
- * Implements hook_field_widget_settings_form().
- */
-function link_field_widget_settings_form($field, $instance) {
- $widget = $instance['widget'];
- $settings = $widget['settings'];
-
- $form['placeholder_url'] = array(
- '#type' => 'textfield',
- '#title' => t('Placeholder for URL'),
- '#default_value' => $settings['placeholder_url'],
- '#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.'),
- );
- $form['placeholder_title'] = array(
- '#type' => 'textfield',
- '#title' => t('Placeholder for link title'),
- '#default_value' => $settings['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(
- 'invisible' => array(
- ':input[name="instance[settings][title]"]' => array('value' => DRUPAL_DISABLED),
- ),
- ),
- );
-
- return $form;
-}
-
-/**
- * Implements hook_field_widget_form().
- */
-function link_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
- $settings = $instance['settings'];
- $widget_settings = $instance['widget']['settings'];
-
- $element['url'] = array(
- '#type' => 'url',
- '#title' => t('URL'),
- '#placeholder' => isset($widget_settings['placeholder_url']) ? $widget_settings['placeholder_url'] : '',
- '#default_value' => isset($items[$delta]['url']) ? $items[$delta]['url'] : NULL,
- '#maxlength' => 2048,
- '#required' => $element['#required'],
- );
- $element['title'] = array(
- '#type' => 'textfield',
- '#title' => t('Title'),
- '#placeholder' => isset($widget_settings['placeholder_title']) ? $widget_settings['placeholder_title'] : '',
- '#default_value' => isset($items[$delta]['title']) ? $items[$delta]['title'] : NULL,
- '#maxlength' => 255,
- '#access' => $settings['title'] != DRUPAL_DISABLED,
- );
- // Post-process the title field to make it conditionally required if URL is
- // non-empty. Omit the validation on the field edit form, since the field
- // settings cannot be saved otherwise.
- $is_field_edit_form = ($element['#entity'] === NULL);
- if (!$is_field_edit_form && $settings['title'] == DRUPAL_REQUIRED) {
- $element['#element_validate'][] = 'link_field_widget_validate_title';
- }
-
- // Exposing the attributes array in the widget is left for alternate and more
- // advanced field widgets.
- $element['attributes'] = array(
- '#type' => 'value',
- '#tree' => TRUE,
- '#value' => !empty($items[$delta]['attributes']) ? $items[$delta]['attributes'] : array(),
- '#attributes' => array('class' => array('link-field-widget-attributes')),
- );
-
- // If cardinality is 1, ensure a label is output for the field by wrapping it
- // in a details element.
- if ($field['cardinality'] == 1) {
- $element += array(
- '#type' => 'fieldset',
- );
- }
-
- return $element;
-}
-
-/**
- * Form element validation handler for link_field_widget_form().
- *
- * Conditionally requires the link title if a URL value was filled in.
- */
-function link_field_widget_validate_title(&$element, &$form_state, $form) {
- if ($element['url']['#value'] !== '' && $element['title']['#value'] === '') {
- $element['title']['#required'] = TRUE;
- form_error($element['title'], t('!name field is required.', array('!name' => $element['title']['#title'])));
- }
-}
-
-/**
- * Implements hook_field_prepare_view().
- */
-function link_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
- foreach ($entities as $id => $entity) {
- foreach ($items[$id] as $delta => &$item) {
- // Split out the link into the parts required for url(): path and options.
- $parsed = drupal_parse_url($item['url']);
- $item['path'] = $parsed['path'];
- $item['options'] = array(
- 'query' => $parsed['query'],
- 'fragment' => $parsed['fragment'],
- 'attributes' => &$item['attributes'],
- );
- }
- }
-}
-
-/**
- * Implements hook_field_formatter_info().
- */
-function link_field_formatter_info() {
- $formatters['link'] = array(
- 'label' => t('Link'),
- 'field types' => array('link'),
- 'settings' => array(
- 'trim_length' => 80,
- 'rel' => NULL,
- 'target' => NULL,
- 'url_only' => FALSE,
- 'url_plain' => FALSE,
- ),
- );
- // @todo Merge into 'link' formatter once there is a #type like 'item' that
- // can render a compound label and content outside of a form context.
- $formatters['link_separate'] = array(
- 'label' => t('Separate title and URL'),
- 'field types' => array('link'),
- 'settings' => array(
- 'trim_length' => 80,
- 'rel' => NULL,
- 'target' => NULL,
- ),
- );
- return $formatters;
-}
-
-/**
- * Implements hook_field_formatter_settings_form().
- */
-function link_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
- $display = $instance['display'][$view_mode];
- $settings = $display['settings'];
-
- $element['trim_length'] = array(
- '#type' => 'number',
- '#title' => t('Trim link text length'),
- '#field_suffix' => t('characters'),
- '#default_value' => $settings['trim_length'],
- '#min' => 1,
- '#description' => t('Leave blank to allow unlimited link text lengths.'),
- );
- $element['url_only'] = array(
- '#type' => 'checkbox',
- '#title' => t('URL only'),
- '#default_value' => $settings['url_only'],
- '#access' => $display['type'] == 'link',
- );
- $element['url_plain'] = array(
- '#type' => 'checkbox',
- '#title' => t('Show URL as plain text'),
- '#default_value' => $settings['url_plain'],
- '#access' => $display['type'] == 'link',
- '#states' => array(
- 'visible' => array(
- ':input[name*="url_only"]' => array('checked' => TRUE),
- ),
- ),
- );
- $element['rel'] = array(
- '#type' => 'checkbox',
- '#title' => t('Add rel="nofollow" to links'),
- '#return_value' => 'nofollow',
- '#default_value' => $settings['nofollow'],
- );
- $element['target'] = array(
- '#type' => 'checkbox',
- '#title' => t('Open link in new window'),
- '#return_value' => '_blank',
- '#default_value' => $settings['target'],
- );
-
- return $element;
-}
-
-/**
- * Implements hook_field_formatter_settings_form().
- */
-function link_field_formatter_settings_summary($field, $instance, $view_mode) {
- $display = $instance['display'][$view_mode];
- $settings = $display['settings'];
-
- $summary = array();
-
- if (!empty($settings['trim_length'])) {
- $summary[] = t('Link text trimmed to @limit characters', array('@limit' => $settings['trim_length']));
- }
- else {
- $summary[] = t('Link text not trimmed');
- }
- if (!empty($settings['url_only'])) {
- if (!empty($settings['url_plain'])) {
- $summary[] = t('Show URL only as plain-text');
- }
- else {
- $summary[] = t('Show URL only');
- }
- }
- if (!empty($settings['rel'])) {
- $summary[] = t('Add rel="@rel"', array('@rel' => $settings['rel']));
- }
- if (!empty($settings['target'])) {
- $summary[] = t('Open link in new window');
- }
-
- return implode('<br />', $summary);
-}
-
-/**
- * Implements hook_field_formatter_prepare_view().
- */
-function link_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
- foreach ($entities as $id => $entity) {
- $settings = $displays[$id]['settings'];
-
- foreach ($items[$id] as $delta => &$item) {
- // Add optional 'rel' attribute to link options.
- if (!empty($settings['rel'])) {
- $item['options']['attributes']['rel'] = $settings['rel'];
- }
- // Add optional 'target' attribute to link options.
- if (!empty($settings['target'])) {
- $item['options']['attributes']['target'] = $settings['target'];
- }
- }
- }
-}
-
-/**
- * Implements hook_field_formatter_view().
- */
-function link_field_formatter_view(EntityInterface $entity, $field, $instance, $langcode, $items, $display) {
- $element = array();
- $settings = $display['settings'];
-
- foreach ($items as $delta => $item) {
- // By default use the full URL as the link title.
- $link_title = $item['url'];
-
- // If the title field value is available, use it for the link title.
- 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.
- if (!empty($settings['trim_length'])) {
- $link_title = truncate_utf8($link_title, $settings['trim_length'], FALSE, TRUE);
- }
-
- if ($display['type'] == 'link') {
- if (!empty($settings['url_only']) && !empty($settings['url_plain'])) {
- $element[$delta] = array(
- '#type' => 'markup',
- '#markup' => check_plain($link_title),
- );
- }
- else {
- $element[$delta] = array(
- '#type' => 'link',
- '#title' => $link_title,
- '#href' => $item['path'],
- '#options' => $item['options'],
- );
- }
- }
- elseif ($display['type'] == 'link_separate') {
- // 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,
- // $link_title defaults to the URL, so it needs to be unset.
- // The URL title may need to be trimmed as well.
- if (empty($item['title'])) {
- $link_title = NULL;
- }
- $url_title = $item['url'];
- if (!empty($settings['trim_length'])) {
- $url_title = truncate_utf8($item['url'], $settings['trim_length'], FALSE, TRUE);
- }
- $element[$delta] = array(
- '#theme' => 'link_formatter_link_separate',
- '#title' => $link_title,
- '#url_title' => $url_title,
- '#href' => $item['path'],
- '#options' => $item['options'],
- );
- }
- }
- return $element;
-}
-
-/**
* Implements hook_theme().
*/
function link_theme() {