You are here

function views_ui_truncate in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views_ui/views_ui.module \views_ui_truncate()
  2. 9 core/modules/views_ui/views_ui.module \views_ui_truncate()

Truncate strings to a set length and provide a '...' if they truncated.

This is often used in the UI to ensure long strings fit.

9 calls to views_ui_truncate()
Block::optionsSummary in core/modules/views/src/Plugin/views/display/Block.php
Provide the summary for page options in the views UI.
DisplayExtenderTest::optionsSummary in core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php
Provide the default summary for options in the views UI.
DisplayTest::optionsSummary in core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php
DisplayTest::testDisplayTitleInButtonsXss in core/modules/views_ui/tests/src/Functional/DisplayTest.php
Ensures that no XSS is possible for buttons.
Page::optionsSummary in core/modules/views/src/Plugin/views/display/Page.php
Provides the default summary for options in the views UI.

... See full list

File

core/modules/views_ui/views_ui.module, line 341
Provide structure for the administrative interface to Views.

Code

function views_ui_truncate($string, $length) {
  if (mb_strlen($string) > $length) {
    $string = mb_substr($string, 0, $length);
    $string .= '...';
  }
  return $string;
}