diff --git a/web/themes/contrib/civictheme/includes/paragraphs.inc b/web/themes/contrib/civictheme/includes/paragraphs.inc index c08f441d8..349f08740 100644 --- a/web/themes/contrib/civictheme/includes/paragraphs.inc +++ b/web/themes/contrib/civictheme/includes/paragraphs.inc @@ -13,6 +13,7 @@ declare(strict_types=1); use Drupal\civictheme\CivicthemeConstants; +use Drupal\Component\Utility\Unicode; /** * Pre-process for With background paragraph field. @@ -210,6 +211,8 @@ function _civictheme_preprocess_paragraph__paragraph_field__links(array &$variab /** * Pre-process for Summary paragraph field. + * + * @SuppressWarnings(PHPMD.StaticAccess) */ function _civictheme_preprocess_paragraph__paragraph_field__summary(array &$variables): void { $summary = civictheme_get_field_value($variables['paragraph'], 'field_c_p_summary', TRUE); @@ -221,12 +224,20 @@ function _civictheme_preprocess_paragraph__paragraph_field__summary(array &$vari $length = civictheme_get_theme_config_manager()->loadForComponent($component_name, 'summary_length', CivicthemeConstants::COMPONENT_SUMMARY_DEFAULT_LENGTH); } - $variables['summary'] = text_summary($summary, NULL, $length); + $summary_trimmed = text_summary($summary); + + if (!_civictheme_feature_is_optedout('process', CivicthemeConstants::OPTOUT_SUMMARY_HIDE_ELLIPSIS)) { + $summary_trimmed = Unicode::truncate($summary_trimmed, $length, TRUE, TRUE); + } + + $variables['summary'] = $summary_trimmed; } } /** * Pre-process for Summary node field. + * + * @SuppressWarnings(PHPMD.StaticAccess) */ function _civictheme_preprocess_paragraph__node_field__summary(array &$variables, string $bundle = NULL): void { $node = $variables['node'] ?? civictheme_get_field_value($variables['paragraph'], 'field_c_p_reference', TRUE); @@ -240,7 +251,13 @@ function _civictheme_preprocess_paragraph__node_field__summary(array &$variables $length = civictheme_get_theme_config_manager()->loadForComponent($component_name, 'summary_length', CivicthemeConstants::COMPONENT_SUMMARY_DEFAULT_LENGTH); } - $variables['summary'] = text_summary($summary, NULL, $length); + $summary_trimmed = text_summary($summary); + + if (!_civictheme_feature_is_optedout('process', CivicthemeConstants::OPTOUT_SUMMARY_HIDE_ELLIPSIS)) { + $summary_trimmed = Unicode::truncate($summary_trimmed, $length, TRUE, TRUE); + } + + $variables['summary'] = $summary_trimmed; } } } diff --git a/web/themes/contrib/civictheme/includes/utilities.inc b/web/themes/contrib/civictheme/includes/utilities.inc index f1b40965f..5e527f70e 100644 --- a/web/themes/contrib/civictheme/includes/utilities.inc +++ b/web/themes/contrib/civictheme/includes/utilities.inc @@ -888,8 +888,10 @@ function _civictheme_feature_is_optedout(string $type, string $name, mixed $cont * Array of opt-out flags. */ function _civictheme_feature_optout_flags(): array { - return [ + $flags = [ 'components.link' => t('Links processing'), 'components.link.email' => t('Email links processing'), ]; + $flags[CivicthemeConstants::OPTOUT_SUMMARY_HIDE_ELLIPSIS] = t('Hide card summary ellipsis'); + return $flags; } diff --git a/web/themes/contrib/civictheme/src/CivicthemeConstants.php b/web/themes/contrib/civictheme/src/CivicthemeConstants.php index 68c1ba28d..72488337e 100644 --- a/web/themes/contrib/civictheme/src/CivicthemeConstants.php +++ b/web/themes/contrib/civictheme/src/CivicthemeConstants.php @@ -186,4 +186,9 @@ final class CivicthemeConstants { */ const OPTOUT_VIEWS_STYLE_TABLE = 'CivicThemeOptoutViewsStyleTable'; + /** + * Defines an optout string for card summary ellipsis. + */ + const OPTOUT_SUMMARY_HIDE_ELLIPSIS = 'CivicThemeOptoutSummaryHideEllipsis'; + }