Commit 77a45280 authored by alexpott's avatar alexpott

Issue #2279681 by mgifford, joshi.rohit100, thedavidmeister: Views' InOperator...

Issue #2279681 by mgifford, joshi.rohit100, thedavidmeister: Views' InOperator filter should use Unicode::truncate() in adminSummary().
parent 558ad0ce
...@@ -516,7 +516,7 @@ views_field: ...@@ -516,7 +516,7 @@ views_field:
label: 'Trim only on a word boundary' label: 'Trim only on a word boundary'
ellipsis: ellipsis:
type: boolean type: boolean
label: 'Add "..." at the end of trimmed text' label: 'Add "" at the end of trimmed text'
more_link: more_link:
type: boolean type: boolean
label: 'Add a read-more link if output is trimmed.' label: 'Add a read-more link if output is trimmed.'
......
...@@ -946,7 +946,7 @@ public function buildOptionsForm(&$form, &$form_state) { ...@@ -946,7 +946,7 @@ public function buildOptionsForm(&$form, &$form_state) {
$form['alter']['ellipsis'] = array( $form['alter']['ellipsis'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Add "..." at the end of trimmed text'), '#title' => t('Add "" at the end of trimmed text'),
'#default_value' => $this->options['alter']['ellipsis'], '#default_value' => $this->options['alter']['ellipsis'],
'#states' => array( '#states' => array(
'visible' => array( 'visible' => array(
...@@ -1655,7 +1655,7 @@ public function adminLabel($short = FALSE) { ...@@ -1655,7 +1655,7 @@ public function adminLabel($short = FALSE) {
* The alter array of options to use. * The alter array of options to use.
* - max_length: Maximum length of the string, the rest gets truncated. * - max_length: Maximum length of the string, the rest gets truncated.
* - word_boundary: Trim only on a word boundary. * - word_boundary: Trim only on a word boundary.
* - ellipsis: Show an ellipsis (...) at the end of the trimmed string. * - ellipsis: Show an ellipsis () at the end of the trimmed string.
* - html: Make sure that the html is correct. * - html: Make sure that the html is correct.
* *
* @param string $value * @param string $value
...@@ -1684,8 +1684,7 @@ public static function trimText($alter, $value) { ...@@ -1684,8 +1684,7 @@ public static function trimText($alter, $value) {
$value = rtrim(preg_replace('/(?:<(?!.+>)|&(?!.+;)).*$/us', '', $value)); $value = rtrim(preg_replace('/(?:<(?!.+>)|&(?!.+;)).*$/us', '', $value));
if (!empty($alter['ellipsis'])) { if (!empty($alter['ellipsis'])) {
// @todo: What about changing this to a real ellipsis? $value .= t('…');
$value .= t('...');
} }
} }
if (!empty($alter['html'])) { if (!empty($alter['html'])) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\filter; namespace Drupal\views\Plugin\views\filter;
use Drupal\Component\Utility\String as UtilityString; use Drupal\Component\Utility\String as UtilityString;
use Drupal\Component\Utility\Unicode;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
...@@ -356,7 +357,7 @@ public function adminSummary() { ...@@ -356,7 +357,7 @@ public function adminSummary() {
$values .= ', '; $values .= ', ';
} }
if (drupal_strlen($values) > 8) { if (drupal_strlen($values) > 8) {
$values .= '...'; $values = Unicode::truncate($values, 8, FALSE, TRUE);
break; break;
} }
if (isset($this->value_options[$value])) { if (isset($this->value_options[$value])) {
......
...@@ -559,10 +559,10 @@ public function testTextRendering() { ...@@ -559,10 +559,10 @@ public function testTextRendering() {
$row->views_test_data_name = $this->randomName(8); $row->views_test_data_name = $this->randomName(8);
$name_field->options['alter']['max_length'] = 5; $name_field->options['alter']['max_length'] = 5;
$output = $name_field->advancedRender($row); $output = $name_field->advancedRender($row);
$this->assertSubString($output, '...', 'An ellipsis should appear if the output is trimmed'); $this->assertSubString($output, '', 'An ellipsis should appear if the output is trimmed');
$name_field->options['alter']['max_length'] = 10; $name_field->options['alter']['max_length'] = 10;
$output = $name_field->advancedRender($row); $output = $name_field->advancedRender($row);
$this->assertNotSubString($output, '...', 'No ellipsis should appear if the output is not trimmed'); $this->assertNotSubString($output, '', 'No ellipsis should appear if the output is not trimmed');
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment