Twig view renderer, LimeSurvey overload
Allow to run sandbox Configuration Provide different render methods for different context:
The only tricky point here is the path problematic (where should be searched the views to render?)
see | |
---|---|
author | Leonid Svyatov leonid@svyatov.ru |
author | Alexander Makarov sam@rmcreative.ru |
link | |
link | |
version | 1.1.15 |
package | Default |
_addCustom(string $classType,array $elements)
Throws |
|
---|
string
'Function' or 'Filter'
array
Parameters of elements to add
addExtensions(array $extensions)
array
@see self::$extensions
addFilters(array $filters)
array
@see self::$filters
addFunctions(array $functions)
array
@see self::$functions
addGlobals(array $globals)
array
@see self::$globals
addRecursiveTemplatesPath(\TemplateConfiguration $oTemplate,array<mixed,string> $extraPaths = array(),string|null $dirName = null)
\TemplateConfiguration
the template where to start
array<mixed,string>
to be added before template, parent template plugin add and core views. Example : question template
string|null
directory name to be added as extra directory inside template view
addUserExtensions(array $extensions)
array
@see self::$user_extensions
convertTwigToHtml(string $sString,array $aData = array(),\TemplateConfiguration|null $oTemplate = null): string
Throws |
|
---|
string
The string of HTML/Twig to convert
array
Array containing the datas needed to render the view ($thissurvey)
\TemplateConfiguration|null
string
fixDataCoherence(array $aData): array
array
array
getAdditionalInfos( $aData,\TemplateConfiguration $oTemplate):
TODO: move all the display logic to surveyRuntime so we don't need this function here
\TemplateConfiguration
getLoader(): \FileLoader
\FileLoader
getPathOfFile(string $twigView,\TemplateConfiguration $oTemplate = null,array<mixed,string> $extraPath = array(),string|null $dirName = null): string
Throws |
|
---|
string
twigfile to be used (with twig extension)
\TemplateConfiguration
array<mixed,string>
path to be added before plugins add and core views
string|null
directory name to be added as extra directory inside template view
string
complete filename to be used
getPluginsData(string $sString,array $aData): array
string
array
array
getTemplateForView(string $sView,\TemplateConfiguration $oRTemplate): \Template|boolean
string
the view (layout) to render
\TemplateConfiguration
the template where the custom option page should be looked for
\Template|boolean
init()
renderAnswerOptions(string $sView,array $aData): string
It first checks if the question use a template (set in display attributes) If it is the case, it will use the views of that template, else, it will render the core view.
Throws |
|
---|
string
the view (layout) to render
array
the datas needed for the view rendering
string
the generated html
renderFile(\CBaseController $context,string $sourceFile,mixed $data,boolean $return): mixed
This method is required by \IViewRenderer.
\CBaseController
the controller or widget who is rendering the view file.
string
the view file path
mixed
the data to be passed to the view
boolean
whether the rendering result should be returned
mixed
the rendering result, or null if the rendering result is not needed.
renderHtmlPage(string $sHtml,\Template $oTemplate)
string
The Html content of the page (it must not contain anymore any twig statement)
renderOptionPage(\Template $oTemplate,array $renderArray = array()): string
Throws |
|
---|
array
Array that will be passed to the options.twig as variables.
string
renderPartial(string $twigView,array $aData): string
todo | find a way to fix in beforeCloseHtml @see https://bugs.limesurvey.org/view.php?id=13889 |
---|---|
Throws |
|
string
twigfile to be used (with twig extension)
array
to be used
string
renderQuestion(string $sView,array $aData): string
It first checks if the question use a template (set in display attributes) If it is the case, it will use the views of that template, else, it will render the core view.
Throws |
|
---|
string
the view (layout) to render
array
the datas needed for the view rendering
string
the generated html
renderTemplateForQuestionEditPreview(string $sLayout,array $aData,boolean $root = false,boolean $bReturn = false): mixed|string
Throws |
|
---|
string
the name of the layout to render
array
the datas needed to fill the layout
boolean
boolean
if true, it will return the html string without rendering the whole page. Usefull for debuging, and used for Print Answers
mixed|string
renderTemplateForTemplateEditor(string $sView,array $aData,\Template $oEditedTemplate): string
It returns the HTML string needed for the tmp file using the template twig file.
todo | missing return statement (php warning) |
---|---|
Throws |
|
string
the view (layout) to render
array
the datas needed for the view rendering
string
the generated html
renderTemplateFromFile(string $sLayout,array $aData,boolean $bReturn): mixed|string
Throws |
|
---|
string
the name of the layout to render
array
the datas needed to fill the layout
boolean
if true, it will return the html string without rendering the whole page. Usefull for debuging, and used for Print Answers
mixed|string
renderViewFromFile( $sLayoutFilePath,array $aData,boolean $bReturn = false,boolean $bUseRootDir = true): string
Extendable to use admin templates in the future currently running on pathes, like the yii render methods go.
todo | missing return statement (php warning) |
---|---|
Throws |
|
array
the datas needed to fill the layout
boolean
if true, it will return the html string without rendering the whole page. Usefull for debuging, and used for Print Answers
boolean
Prepend application root dir to sLayoutFilePath if true.
string
HTML
setLexerOptions(array $options)
array
@see self::$lexerOptions
sandboxConfig :array
var | Twig_Extension_Sandbox configuration |
---|
array
_twig :
user_extensions :array
var | Custom LS Users Extensions Example: array('HelloWorld_Twig_Extension') |
---|
array
twigPathAlias :string
var | Path alias to Twig |
---|
string
fileExtension :string
var | Twig template files extension |
---|
string
globals :array
var | Objects or static classes Keys of array are names to call in template, values - objects or names of static class as string Example: array('html'=>'CHtml', 'clientScript'=>Yii::app()->clientScript) Than in template: {{ html.link('Login', 'site/login') }} or {{ clientScript.registerCssFile(...) }} |
---|
array
functions :array
var | Custom functions Keys of array are names to call in template, values - names of functions or static methods of some class Example: array('rot13'=>'str_rot13', 'link'=>'CHtml::link') Than in template: {{ rot13('test') }} or {{ link('Login', 'site/login') }} |
---|
array
filters :array
var | Custom filters Keys of array are names to call in template, values - names of functions or static methods of some class Example: array('rot13'=>'str_rot13', 'jsonEncode'=>'CJSON::encode') Then in template: {{ 'test'|rot13 }} or {{ model|jsonEncode }} |
---|
array
extensions :array
var | Custom extensions Example: array('Twig_Extension_Sandbox', 'Twig_Extension_Text') |
---|
array
lexerOptions :array
var | Twig lexer options |
---|---|
see | Example: Smarty-like syntax array( 'tag_comment' => array('{', '}'), 'tag_block' => array('{', '}'), 'tag_variable' => array('{$', '}') ) |
array
_paths :