function _social_comment_get_summary in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_comment/social_comment.tokens.inc \_social_comment_get_summary()
- 8.6 modules/social_features/social_comment/social_comment.tokens.inc \_social_comment_get_summary()
- 8.7 modules/social_features/social_comment/social_comment.tokens.inc \_social_comment_get_summary()
- 8.8 modules/social_features/social_comment/social_comment.tokens.inc \_social_comment_get_summary()
- 10.3.x modules/social_features/social_comment/social_comment.tokens.inc \_social_comment_get_summary()
- 10.0.x modules/social_features/social_comment/social_comment.tokens.inc \_social_comment_get_summary()
- 10.1.x modules/social_features/social_comment/social_comment.tokens.inc \_social_comment_get_summary()
Get first 280 characters of text.
Parameters
string $text: The text to check for.
Return value
string The processed text.
2 calls to _social_comment_get_summary()
- social_activity_tokens in modules/
social_features/ social_activity/ social_activity.tokens.inc - Implements hook_tokens().
- social_comment_tokens in modules/
social_features/ social_comment/ social_comment.tokens.inc - Implements hook_tokens().
File
- modules/
social_features/ social_comment/ social_comment.tokens.inc, line 261 - Builds placeholder replacement tokens for Social Comment module.
Code
function _social_comment_get_summary($text) {
$summary = html_entity_decode(strip_tags($text));
$summary = preg_replace('/\\n|\\r|\\t/m', ' ', $summary);
$max_length = 280;
if (mb_strlen($summary) > $max_length) {
$summary = FieldPluginBase::trimText([
'max_length' => $max_length,
'word_boundary' => TRUE,
'ellipsis' => TRUE,
], $summary);
}
return $summary;
}