Class LineBreaksHelper
Responsibility - given text content processing to escape whitespace before/after selected words. - Single syllable conjunctions to escape whitespace after (configurable). - Common language shortcuts containing whitespaces to escape whitespace inside (configurable). - Units to escape whitespace after number and before unit (configurable).
- MvcCore\Ext\Views\Helpers\AbstractHelper implements MvcCore\Ext\Views\Helpers\IHelper
-
MvcCore\Ext\Views\Helpers\LineBreaksHelper
Located at ext-view-helper-linebreaks/src/MvcCore/Ext/View/Helpers/LineBreaksHelper.php
public static
|
#
GetInstance( )
Create view helper instance as singleton.
To configure view helper instance, create it by this method
in your base controller in |
public
|
#
SetView(
Create view helper instance. To configure view helper instance, create it by this method in your $baseController->preDispatch(); method, after view instance inside controller is created, then you can configure anything you want. If Controller contains static property 'Lang', language for this view helper will be loaded from this property. |
public
|
#
SetWeekWords( string[]|string $weekWords, string $lang = '' )
Set weak words, where you need to place a HTML space entity, to not break line after each configured weak word in processing text. All words has to be configured as single string with all weak words separated by comma character without any space. |
public
|
#
SetShortcuts( array $shortcuts, string $lang = '' )
Set special shortcuts for specific language to not have any line break inside. If language is not specified, there is used default language from controller instance. |
public
|
#
SetUnits( string[]|string $units )
Set units, where you need to place a HTML space entity, to not break line before each configured unit where is founded digit character before unit and white space before in source text. All units has to be configured as single string with all units separated by comma character without any space. |
protected
array
|
#
getWeekWordsUnitsAndShortcuts( string $lang )
Get weak words as array of strings, units and shortcuts. as array of string for currently processed language. |
public
string
|
#
LineBreaks( string $text, string $lang = "" )
Process configured weak words and units and place HTML space entity where is necessary to not line break source text where it's not wanted. |
protected
|
#
processWeakWord( string $word )
Process single weak word - place HTML space entity where is necessary to not line break source text where it's not wanted. |
public
|
VERSION
|
public static
array
|
$WeekWordsDefault
Weak words by international language code as array key. Weak words are words, where you don't want to have a line break after. Weak words have to be configured as string with all weak words separated by comma character without any spaces. |
#
[
// single syllable conjunctions for English
'en' => 'a,an,the,for,and,nor,but,or,yet,so,if,than,then,as,once,till,when,shy,who,how,of,in,to,with',
// single syllable conjunctions for Deutsch
'de' => 'der,die,das,ein,an,in,am,zu,und,doch,als,ob,bis,da,daß',
// single syllable conjunctions for Czech/Slovak:-)
'cs' => "a,ač,aj,ak,ať,ba,co,či,do,i,k,ke,ku,o,pro,při,s,sa,se,si,sú,v,ve,z,za,ze,že",
]
|
public static
array
|
$ShortcutsDefault
Special shortcuts to not have any line break inside, keyed by language. |
#
[
'cs' => ['př. kr.', 'př. n. l.', 's. r. o.', 'a. s.', 'v. o. s.', 'o. s. ř.',],
]
|
public static
string
|
$UnitsDefault
Units are very short words, where you don't want to have a line break before, where is any digit before caught unit word and space before caught unit word. Units have to be configured as string with all units separated by comma character without any spaces. |
#
"%,‰,mm,cm,dm,m,km,g,dkg,kg,t,ar,ha,ml,dcl,l,cm²,m²,km²,cm³,m³,°C,°F,K"
|
protected static
|
$instance
Singleton instance. |
|
protected
string
|
$lang
Language used for text processing as default. All text processing should be called with custom language value. |
#
""
|
protected
string
|
$text
Source text currently processed. |
#
""
|
protected
array
|
$weekWords
Store with weak words exploded into single strings, keyed by language. |
#
[]
|
protected
string[]
|
$units
Exploded units as array of string to be processed in source text. |
#
[]
|
protected
array
|
$shortcuts
Prepared shortcuts with no-line breaking spaces, keyed by language. |
#
[]
|
$controller,
$request,
$response,
$view
|