Class TruncateHelper
Responsibility - truncate plain text or text with html tags to max. chars.
- No html tags are truncated, only text content in html code is truncated.
- Possibility to setup custom chars for three dots, html entity …
by default, for plain text ...
by default.
- Possibility to set default truncating method, if third param to define is not set.
- MvcCore\Ext\Views\Helpers\AbstractHelper implements MvcCore\Ext\Views\Helpers\IHelper
-
MvcCore\Ext\Views\Helpers\TruncateHelper
Located at ext-view-helper-truncate/src/MvcCore/Ext/Views/Helpers/TruncateHelper.php
public
|
#
SetThreeDotsText( string $threeDotsText = '…', boolean $forHtmlText = TRUE )
Set three dots custom chars - |
public
|
#
SetAlwaysHtmlMode( boolean $alwaysHtmlMode = TRUE )
Setup helper to use always html mode truncating if there is not set third param to use force html or text mode. |
public
string
|
#
Truncate( string $text, integer $maxChars = 200, boolean|null $isHtml = NULL )
Truncate text with any HTML tags inside, keep all tags and truncate text content only
or truncate simple text without any HTML tags.
Clean all possible punctuation and brackets before three dots: |
protected
string
|
#
truncateHtml( string & $text, integer $maxChars )
Truncate text with any HTML tags inside, keep all tags and truncate text content only.
Clean all possible punctuation and brackets before three dots: |
protected
|
#
truncateText( string & $text, integer $maxChars )
Truncate simple text without any HTML tags.
Clean all possible punctuation and brackets before three dots: |
GetInstance(),
SetView()
|
public
|
VERSION
|
protected static
|
$instance
If this static property is set - helper is possible
to configure as singleton before it's used for first time.
Example:
|
|
protected
string[]|NULL[]
|
$threeDotsTexts
Custom substrings to set three dost after truncated text.
If not set by |
#
[NULL, NULL]
|
protected
boolean|null
|
$alwaysHtmlMode
If |
#
NULL
|
$controller,
$request,
$response,
$view
|