Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
b85ec521
Commit
b85ec521
authored
Apr 12, 2015
by
alexpott
Browse files
Issue
#2463579
by tstoeckler: Add an ellipsis to truncated comment titles
parent
822835f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/comment/src/CommentForm.php
View file @
b85ec521
...
...
@@ -301,7 +301,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
// 2) Strip out all HTML tags
// 3) Convert entities back to plain-text.
$comment_text
=
$comment
->
comment_body
->
processed
;
$comment
->
setSubject
(
Unicode
::
truncate
(
trim
(
Html
::
decodeEntities
(
strip_tags
(
$comment_text
))),
29
,
TRUE
));
$comment
->
setSubject
(
Unicode
::
truncate
(
trim
(
Html
::
decodeEntities
(
strip_tags
(
$comment_text
))),
29
,
TRUE
,
TRUE
));
// Edge cases where the comment body is populated only by HTML tags will
// require a default subject.
if
(
$comment
->
getSubject
()
==
''
)
{
...
...
core/modules/comment/src/Tests/CommentInterfaceTest.php
View file @
b85ec521
...
...
@@ -220,12 +220,12 @@ public function testAutoFilledSubject() {
$body_text
=
'Lorem ipsum Lorem ipsum Loreming ipsum Lorem ipsum'
;
$comment1
=
$this
->
postComment
(
NULL
,
$body_text
,
''
,
TRUE
);
$this
->
assertTrue
(
$this
->
commentExists
(
$comment1
),
'Form comment found.'
);
$this
->
assertEqual
(
'Lorem ipsum Lorem ipsum'
,
$comment1
->
getSubject
());
$this
->
assertEqual
(
'Lorem ipsum Lorem ipsum
…
'
,
$comment1
->
getSubject
());
// Break at 29 characters where there's no boundary before that.
$body_text2
=
'LoremipsumloremipsumLoremingipsumLoremipsum'
;
$comment2
=
$this
->
postComment
(
NULL
,
$body_text2
,
''
,
TRUE
);
$this
->
assertEqual
(
'LoremipsumloremipsumLoreming
i
'
,
$comment2
->
getSubject
());
$this
->
assertEqual
(
'LoremipsumloremipsumLoreming
…
'
,
$comment2
->
getSubject
());
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment