Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
smart_trim-2829817
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
smart_trim-2829817
Commits
675b75fb
Commit
675b75fb
authored
5 years ago
by
Mark Casias
Browse files
Options
Downloads
Patches
Plain Diff
Issue by ckaotik: Trimmed summary markup.
parent
deb4ef66
No related branches found
Branches containing commit
Tags
7.x-1.0-beta3
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.txt
+1
-0
1 addition, 0 deletions
CHANGELOG.txt
src/Plugin/Field/FieldFormatter/SmartTrimFormatter.php
+12
-15
12 additions, 15 deletions
src/Plugin/Field/FieldFormatter/SmartTrimFormatter.php
with
13 additions
and
15 deletions
CHANGELOG.txt
+
1
−
0
View file @
675b75fb
Smart Trim 8.x-1.2
------------------
Issue by ckaotik: Trimmed summary markup.
Issue #2995557 by jkaeser, slefevre@ccad.edu: Extra space characters after HTML stripping
Issue #3042672 by Phil Wolstenholme: Drupal 9 Deprecated Code Report
Issue #2169583 by danbohea, MegaChriz, thewilkybarkid: Trim certain punctuation from the end of truncated text output before appending suffix
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/Field/FieldFormatter/SmartTrimFormatter.php
+
12
−
15
View file @
675b75fb
...
...
@@ -198,10 +198,7 @@ class SmartTrimFormatter extends FormatterBase {
foreach
(
$items
as
$delta
=>
$item
)
{
if
(
$settings_summary_handler
!=
'ignore'
&&
!
empty
(
$item
->
summary
))
{
$output
=
$item
->
summary_processed
;
}
elseif
(
$item
->
processed
!=
NULL
)
{
$output
=
$item
->
processed
;
$output
=
$item
->
summary
;
}
else
{
$output
=
$item
->
value
;
...
...
@@ -251,28 +248,30 @@ class SmartTrimFormatter extends FormatterBase {
$output
=
$truncate
->
truncateChars
(
$output
,
$length
,
$ellipse
);
}
}
$element
[
$delta
]
=
[
'#type'
=>
'processed_text'
,
'#text'
=>
$output
,
'#format'
=>
$item
->
format
,
];
// Wrap content in container div.
if
(
$this
->
getSetting
(
'wrap_output'
))
{
$output
=
'<div class="'
.
$this
->
getSetting
(
'wrap_class'
)
.
'">'
.
$output
.
'</div>'
;
$element
[
$delta
][
'#prefix'
]
=
'<div class="'
.
$this
->
getSetting
(
'wrap_class'
)
.
'">'
;
$element
[
$delta
][
'#suffix'
]
=
'</div>'
;
}
// Add the link, if there is one!
$link
=
''
;
// The entity must have an id already. Content entities usually get their
// IDs by saving them. In some cases, eg: Inline Entity Form preview there
// is no ID until everything is saved.
// https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Entity.php/function/Entity%3A%3AtoUrl/8.2.x
if
(
$entity
->
id
())
{
$uri
=
$entity
->
hasLinkTemplate
(
'canonical'
)
?
$entity
->
toUrl
()
:
NULL
;
if
(
$this
->
getSetting
(
'more_link'
)
&&
$entity
->
id
()
&&
$entity
->
hasLinkTemplate
(
'canonical'
))
{
// But wait! Don't add a more link if the field ends in <!--break-->.
if
(
$uri
&&
$this
->
getSetting
(
'more_link'
)
&&
strpos
(
strrev
(
$output
),
strrev
(
'<!--break-->'
))
!==
0
)
{
if
(
strpos
(
strrev
(
$output
),
strrev
(
'<!--break-->'
))
!==
0
)
{
$more
=
$this
->
getSetting
(
'more_text'
);
$class
=
$this
->
getSetting
(
'more_class'
);
$project_link
=
Link
::
fromTextAndUrl
(
$more
,
$uri
);
$project_link
=
$project_link
->
toRenderable
();
$project_link
=
$entity
->
toLink
(
$more
)
->
toRenderable
();
$project_link
[
'#attributes'
]
=
[
'class'
=>
[
$class
,
...
...
@@ -280,11 +279,9 @@ class SmartTrimFormatter extends FormatterBase {
];
$project_link
[
'#prefix'
]
=
'<div class="'
.
$class
.
'">'
;
$project_link
[
'#suffix'
]
=
'</div>'
;
$link
=
render
(
$project_link
)
;
$
element
[
$delta
][
'more_
link
'
]
=
$project_link
;
}
}
$output
.
=
$link
;
$element
[
$delta
]
=
[
'#markup'
=>
$output
];
}
return
$element
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment