LS_Twig_Extension
extends AbstractExtension
in package
Table of Contents
Methods
- assetPublish() : mixed
- checkPermission() : bool
- Checks for a permission on render
- createAbsoluteUrl() : mixed
- createUrl() : mixed
- darkencss() : mixed
- ellipsizeString() : string
- get flat and ellipsize string
- flatEllipsizeText() : string
- flat and ellipsize text, for template compatibility
- flatString() : string
- Get html text and remove whole not clean string
- getAllQuestionClasses() : string
- Retrieve the question classes for a given question id Use in survey template question.twig file.
- getAllTokenAnswers() : mixed
- Retrieve all the previous answers from a given token To use it: {% set aResponses = getAllTokenAnswers(aSurveyInfo.sid) %} {{ dump(aResponses) }}
- getConfig() : mixed
- getExpressionManagerOutput() : string
- Get the parsed output of the expression manger for a specific string
- getGoogleAnalyticsTrackingUrl() : string
- Returns the "tracking url" for Google Analytics when style is "Survey-SID/GROUP"
- getLanguageRTL() : mixed
- Returns true if the language uses RTL writing system.
- getParam() : mixed
- getPosition() : string
- getPost() : mixed
- getQuery() : mixed
- getTemplateForRessource() : mixed
- getTextDisplayWidget() : string
- Get the textcontrol widget output for a specific string
- image() : string
- imageSrc() : string|false
- in_multiarray() : mixed
- Check if a needle is in a multidimensional array
- json_decode() : array<string|int, mixed>
- Convert a json object to a PHP array (so no troubles with object method in sandbox)
- lightencss() : mixed
- listCoreScripts() : mixed
- listScriptFiles() : mixed
- processString() : string
- Process any string with current page
- registerCssFile() : mixed
- registerGeneralScript() : mixed
- Publish a script file from general script directory, using or not the asset manager (depending on configuration) In any twig file, you can register a general script file doing: {{ registerGeneralScript($sGeneralScriptFileName) }}
- registerPackage() : mixed
- registerPublicCssFile() : mixed
- Publish a css file from public style directory, using or not the asset manager (depending on configuration) In any twig file, you can register a public css file doing: {{ registerPublicCssFile($sPublicCssFileName) }}
- registerScript() : mixed
- Publish a script In any twig file, you can register a script doing: {{ registerScript($sId, $sScript) }}
- registerScriptFile() : mixed
- registerTemplateCssFile() : mixed
- Publish a css file from template directory, using or not the asset manager (depending on configuration) In any twig file, you can register a template css file doing: {{ registerTemplateCssFile($sTemplateCssFileName) }}
- registerTemplateScript() : mixed
- Publish a script file from template directory, using or not the asset manager (depending on configuration) In any twig file, you can register a template script file doing: {{ registerTemplateScript($sTemplateScriptFileName) }}
- renderCaptcha() : mixed
- safecount() : void
- since count with a noncountable element is throwing a warning in latest php versions we have to be sure not to kill rendering by a wrong variable
- templateResourceUrl() : string|false
- unregisterPackage() : mixed
- unregisterScriptFile() : mixed
- unregisterScriptForAjax() : mixed
- Unregister all packages/script files for AJAX rendering
Methods
assetPublish()
public
static assetPublish(string $sRessource) : mixed
Parameters
- $sRessource : string
checkPermission()
Checks for a permission on render
public
static checkPermission(string $permission, string $permissionGrade[, int|null $iSurveyId = null ]) : bool
Parameters
- $permission : string
- $permissionGrade : string
- $iSurveyId : int|null = null
-
(default null)
Return values
boolcreateAbsoluteUrl()
public
static createAbsoluteUrl(mixed $url[, mixed $params = array() ]) : mixed
Parameters
- $url : mixed
- $params : mixed = array()
createUrl()
public
static createUrl(mixed $url[, mixed $params = array() ]) : mixed
Parameters
- $url : mixed
- $params : mixed = array()
darkencss()
public
static darkencss(mixed $cssColor[, mixed $grade = 10 ][, mixed $alpha = 1 ]) : mixed
Parameters
- $cssColor : mixed
- $grade : mixed = 10
- $alpha : mixed = 1
ellipsizeString()
get flat and ellipsize string
public
static ellipsizeString(string $string, int $maxlength[, float $position = 1 ][, string $ellipsis = '…' ]) : string
Parameters
- $string : string
-
to ellipsize
- $maxlength : int
-
of the final string
- $position : float = 1
-
of the ellipsis in string (between 0 and 1)
- $ellipsis : string = '…'
-
string to shown in place of removed part
Return values
stringflatEllipsizeText()
flat and ellipsize text, for template compatibility
public
static flatEllipsizeText(string $sString[, bool $bFlat = true ][, int $iAbbreviated = 0 ][, string $sEllipsis = '...' ][, int $fPosition = 1 ]) : string
Parameters
- $sString : string
-
:the string
- $bFlat : bool = true
-
: flattenText or not : completely flat (not like flattenText from common_helper)
- $iAbbreviated : int = 0
-
: max string text (if true : always flat), 0 or false : don't abbreviated
- $sEllipsis : string = '...'
-
if abbreviated : the char to put at end (or middle)
- $fPosition : int = 1
-
if abbreviated position to split (in % : 0 to 1)
Tags
Return values
stringflatString()
Get html text and remove whole not clean string
public
static flatString(string $string[, bool $encode = false ]) : string
Parameters
- $string : string
-
to flatten
- $encode : bool = false
-
html entities
Return values
stringgetAllQuestionClasses()
Retrieve the question classes for a given question id Use in survey template question.twig file.
public
static getAllQuestionClasses(int $iQid) : string
TODO: we'd rather provide a oQuestion object to the twig view with a method getAllQuestion(). But for now, this public static function respect the old way of doing
Parameters
- $iQid : int
-
the question id
Tags
Return values
string —the classes
getAllTokenAnswers()
Retrieve all the previous answers from a given token To use it: {% set aResponses = getAllTokenAnswers(aSurveyInfo.sid) %} {{ dump(aResponses) }}
public
static getAllTokenAnswers(mixed $iSurveyID) : mixed
Of course, the survey must use token. If you want to show it after completion, the you must turn on public statistics
Parameters
- $iSurveyID : mixed
getConfig()
public
static getConfig(mixed $item) : mixed
Parameters
- $item : mixed
getExpressionManagerOutput()
Get the parsed output of the expression manger for a specific string
public
static getExpressionManagerOutput(string $sInString) : string
Parameters
- $sInString : string
Return values
stringgetGoogleAnalyticsTrackingUrl()
Returns the "tracking url" for Google Analytics when style is "Survey-SID/GROUP"
public
static getGoogleAnalyticsTrackingUrl(int $surveyId[, string $trackUrlPageName = '' ]) : string
Parameters
- $surveyId : int
- $trackUrlPageName : string = ''
-
Specific page name to include in the tracking url. If it's empty, we will try to infer it from the context.
Return values
string —The tracking URL as "
getLanguageRTL()
Returns true if the language uses RTL writing system.
public
static getLanguageRTL(mixed $sLanguageCode) : mixed
Parameters
- $sLanguageCode : mixed
getParam()
public
static getParam(mixed $sName[, mixed $sDefaultValue = null ]) : mixed
Parameters
- $sName : mixed
- $sDefaultValue : mixed = null
getPosition()
public
static getPosition( $position) : string
Parameters
Return values
stringgetPost()
public
static getPost(mixed $sName[, mixed $sDefaultValue = null ]) : mixed
Parameters
- $sName : mixed
- $sDefaultValue : mixed = null
getQuery()
public
static getQuery(mixed $sName[, mixed $sDefaultValue = null ]) : mixed
Parameters
- $sName : mixed
- $sDefaultValue : mixed = null
getTemplateForRessource()
public
static getTemplateForRessource(string $sRessource) : mixed
Parameters
- $sRessource : string
getTextDisplayWidget()
Get the textcontrol widget output for a specific string
public
static getTextDisplayWidget(string $sInString, mixed $name) : string
Parameters
- $sInString : string
- $name : mixed
Return values
stringimage()
public
static image(mixed $sImagePath[, mixed $alt = '' ][, mixed $htmlOptions = array() ]) : string
Parameters
- $sImagePath : mixed
- $alt : mixed = ''
- $htmlOptions : mixed = array()
Return values
stringimageSrc()
public
static imageSrc(mixed $sImagePath[, mixed $default = false ]) : string|false
Parameters
- $sImagePath : mixed
- $default : mixed = false
Return values
string|falsein_multiarray()
Check if a needle is in a multidimensional array
public
in_multiarray(mixed $needle, array<string|int, mixed> $haystack[, bool $strict = false ]) : mixed
Parameters
- $needle : mixed
-
The searched value.
- $haystack : array<string|int, mixed>
-
The array.
- $strict : bool = false
-
If the third parameter strict is set to TRUE then the in_array() function will also check the types of the needle in the haystack.
Tags
json_decode()
Convert a json object to a PHP array (so no troubles with object method in sandbox)
public
static json_decode(string $json[, bool $assoc = true ]) : array<string|int, mixed>
Parameters
- $json : string
- $assoc : bool = true
-
return sub object as array too
Return values
array<string|int, mixed>lightencss()
public
static lightencss(mixed $cssColor[, mixed $grade = 10 ][, mixed $alpha = 1 ]) : mixed
Parameters
- $cssColor : mixed
- $grade : mixed = 10
- $alpha : mixed = 1
listCoreScripts()
public
static listCoreScripts() : mixed
listScriptFiles()
public
static listScriptFiles() : mixed
processString()
Process any string with current page
public
static processString(mixed $string[, bool $static = false ][, int $numRecursionLevels = 3 ][, array<string|int, mixed> $aReplacement = array() ]) : string
Parameters
- $string : mixed
- $static : bool = false
-
return static string (or not)
- $numRecursionLevels : int = 3
-
recursion (max) level to do
- $aReplacement : array<string|int, mixed> = array()
-
replacement out of EM
Return values
stringregisterCssFile()
public
static registerCssFile(mixed $path) : mixed
Parameters
- $path : mixed
registerGeneralScript()
Publish a script file from general script directory, using or not the asset manager (depending on configuration) In any twig file, you can register a general script file doing: {{ registerGeneralScript($sGeneralScriptFileName) }}
public
static registerGeneralScript(string $sGeneralScriptFileName[, string $position = null ][, array<string|int, mixed> $htmlOptions = array() ]) : mixed
Parameters
- $sGeneralScriptFileName : string
-
name of the script file to publish in general script directory (it should contains the subdirectories)
- $position : string = null
- $htmlOptions : array<string|int, mixed> = array()
registerPackage()
public
static registerPackage(mixed $name) : mixed
Parameters
- $name : mixed
registerPublicCssFile()
Publish a css file from public style directory, using or not the asset manager (depending on configuration) In any twig file, you can register a public css file doing: {{ registerPublicCssFile($sPublicCssFileName) }}
public
static registerPublicCssFile(string $sPublicCssFileName) : mixed
Parameters
- $sPublicCssFileName : string
-
name of the CSS file to publish in public style directory
registerScript()
Publish a script In any twig file, you can register a script doing: {{ registerScript($sId, $sScript) }}
public
static registerScript(mixed $id, mixed $script[, mixed $position = null ][, array<string|int, mixed> $htmlOptions = array() ]) : mixed
NOTE: this function is not recursive, so don't use it to register a script located inside a theme folder, or inherited themes will be broken. NOTE! to register a script located inside a theme folder, registerTemplateScript()
Parameters
- $id : mixed
- $script : mixed
- $position : mixed = null
- $htmlOptions : array<string|int, mixed> = array()
registerScriptFile()
public
static registerScriptFile(mixed $path[, mixed $position = null ]) : mixed
Parameters
- $path : mixed
- $position : mixed = null
registerTemplateCssFile()
Publish a css file from template directory, using or not the asset manager (depending on configuration) In any twig file, you can register a template css file doing: {{ registerTemplateCssFile($sTemplateCssFileName) }}
public
static registerTemplateCssFile(string $sTemplateCssFileName) : mixed
Parameters
- $sTemplateCssFileName : string
-
name of the CSS file to publish in template directory (it should contains the subdirectories)
registerTemplateScript()
Publish a script file from template directory, using or not the asset manager (depending on configuration) In any twig file, you can register a template script file doing: {{ registerTemplateScript($sTemplateScriptFileName) }}
public
static registerTemplateScript(string $sTemplateScriptFileName[, string $position = null ][, array<string|int, mixed> $htmlOptions = array() ]) : mixed
Parameters
- $sTemplateScriptFileName : string
-
name of the script file to publish in general script directory (it should contains the subdirectories)
- $position : string = null
- $htmlOptions : array<string|int, mixed> = array()
renderCaptcha()
public
static renderCaptcha() : mixed
safecount()
since count with a noncountable element is throwing a warning in latest php versions we have to be sure not to kill rendering by a wrong variable
public
static safecount(mixed $element) : void
Parameters
- $element : mixed
templateResourceUrl()
public
static templateResourceUrl(mixed $resourcePath[, mixed $default = false ]) : string|false
Parameters
- $resourcePath : mixed
- $default : mixed = false
Return values
string|falseunregisterPackage()
public
static unregisterPackage(string $name) : mixed
Parameters
- $name : string
unregisterScriptFile()
public
static unregisterScriptFile(string $name) : mixed
Parameters
- $name : string
unregisterScriptForAjax()
Unregister all packages/script files for AJAX rendering
public
static unregisterScriptForAjax() : mixed