LimeSurvey API - Master branch

TemplateManifest extends TemplateConfiguration
in package

Template Configuration Model

This model retrieves all the data of template configuration from the configuration file

Tags
subpackage

Backend

Table of Contents

Properties

$aInstancesFromTemplateName  : array<string|int, mixed>
$aPreparedToRender  : array<string|int, mixed>
$bJustCreated  : mixed
$bUseMagicInherit  : mixed
$config  : SimpleXMLElement
$cssFramework  : object
$cssframework_css  : string
$cssframework_js  : string
$cssframework_name  : string
$files_css  : string
$files_js  : string
$files_print_css  : string
$filesPath  : string
$generalFilesPath  : mixed
$gsid  : int
$id  : int
$isStandard  : bool
$oMotherTemplate  : TemplateConfiguration
$oOptionAttributes  : mixed
$oOptions  : object
$oParentTemplate  : TemplateConfiguration
$options  : string
$options_page  : mixed
$packages_ltr  : string
$packages_rtl  : string
$packages_to_load  : string
$path  : string
$showpopups  : int
$sid  : int
$sPackageName  : string
$sPreviewImgTag  : string
$sTemplateName  : string
$sTemplateurl  : string
$template  : Template
$template_description  : mixed
$template_extends  : mixed
$template_name  : string
$template_type  : mixed
$templateEditor  : mixed
$uid  : int
$viewPath  : string
$aCssFrameworkReplacement  : array<string|int, mixed>
$apiVersion  : int
$depends  : array<string|int, string>
$hasConfigFile  : string
$iSurveyId  : int
$packages  : array<string|int, string>
$xmlFile  : string
$aFilesTo  : array<string|int, mixed>
$aFrameworkAssetsToReplace  : array<string|int, mixed>
$aReplacements  : array<string|int, mixed>
$bTemplateCheckResult  : bool
$Ofiles  : array<string|int, mixed>
$sTypeIcon  : string

Methods

__get()  : mixed
PHP getter magic method.
__toString()  : string
actualizeLastUpdate()  : mixed
Update the configuration file "last update" node.
addFileReplacement()  : bool|void
Add a file replacement entry eg: <filename replace="css/template.css">css/template.css</filename>
addFileReplacementInDB()  : mixed
Add a file replacement entry in DB In the first place it tries to get the all the configuration entries for this template (it can be void if edited from template editor, or they can be numerous if the template has local config at survey/survey group/user level) Then, it call $oTemplateConfiguration->addFileReplacement($sFile, $sType) for each one of them.
addOptionFromXMLToLiveTheme()  : void
Apply options from XML configuration for all missing template options
addOptionToLiveTheme()  : void
Add an option definition to the current theme.
attributeLabels()  : array<string|int, mixed>
changeAuthorInDom()  : mixed
Change author inside the DOM
changeDateInDOM()  : mixed
Change the date inside the DOMDocument Used only when copying/extend a survey
changeEmailInDom()  : mixed
Change author email inside the DOM
changeExtendsInDom()  : mixed
Change the extends node inside the DOM If it doesn't exist, it will create it
changeNameInDOM()  : mixed
Change the name inside the DOMDocument (will not save it)
checkAndcreateSurveyConfig()  : TemplateConfiguration
For a given survey, it checks if its theme have a all the needed configuration entries (survey + survey group).
checkTemplate()  : bool
Check if the template exists and is valid
convertOptionsToJson()  : string
Extracts option values from theme options node (XML) into a json key-value map.
defaultScope()  : mixed
deleteEngineInDom()  : mixed
Delete engine node inside the DOM, except the optionspage configuration
extendsConfig()  : mixed
Update the config file of a given template so that it extends another one
extendsFile()  : string
Copy a file from mother template to local directory and edit manifest if needed
formatArrayFields()  : array<string|int, mixed>
This will prepare an array for the field, so the json_encode will create If a field is empty, its value should not be null, but an empty array for the json encoding in DB
formatToJsonArray()  : string
Convert the values to a json.
getAllDbTemplateFolders()  : array<string|int, mixed>|null
Returns an array of all unique template folders that are registered in the database
getApiVersion()  : int
get the template API version
getAssetsToReplaceFormated()  : stdClass
Get the list of file replacement from Engine Framework
getButtons()  : string
Get buttons/actions for the "Available admin themes", not installed
getClassAndAttributes()  : mixed
Core config and attributes
getContentForScreen()  : string
Returns the content file name for a given screen
getDefaultCoreDataForRendering()  : mixed
Hard coded data for theme rendering outside of the normal survey taking.
getDefaultDataForLanguageChanger()  : mixed
getDefaultDataForRendering()  : mixed
Return the default datas for theme views.
getDefaultDataForRenderingFromXml()  : mixed
getDescription()  : string
Twig statements can be used in Theme description Override method from TemplateConfiguration to use the description from the XML
getFilePathForEditing()  : mixed
Retreives the absolute path for a file to edit (current template, mother template, etc) Also perform few checks (permission to edit? etc)
getFilesForPackages()  : array<string|int, mixed>
Get the files (css or js) defined in the manifest of a template and its mother templates
getFontDropdownOptions()  : mixed
getGlobalParent()  : TemplateConfiguration
Get the global template configuration with same name as $this.
getHasOptionPage()  : bool
Returns true if this theme or any mothertemplate has a TemplateConfiguration set
getInstance()  : TemplateConfiguration
Get an instance of a fitting TemplateConfiguration NOTE: for rendering prupose, you should never call this function directly, but rather Template::getInstance.
getInstanceFromSurveyGroup()  : TemplateConfiguration
Returns a TemplateConfiguration Object based on a surveygroup ID If no instance is existing, it will create one.
getInstanceFromSurveyId()  : TemplateConfiguration
Returns a TemplateConfiguration Object based on a surveyID If no instance is existing, it will create one.
getInstanceFromTemplateName()  : TemplateConfiguration
Gets an instance of a templateconfiguration by name
getLayoutForScreen()  : string
Returns the layout file name for a given screen
getManifestDOM()  : DOMDocument
Get the DOMDocument of the Manifest
getOptionAttributes()  : mixed
Get options_page value from template configuration
getOptionPage()  : mixed
getOptionPageAttributes()  : array<string|int, mixed>
getOtherFiles()  : array<string|int, mixed>
Get the list of all the files inside the file folder for a template and its mother templates
getParentConfiguration()  : TemplateConfiguration
getPreview()  : array<string|int, mixed>|mixed|string|null
getScreensDetails()  : array<string|int, mixed>
Returns the complete list of screens, with layout and contents. Used from Twig Command line
getScreensList()  : array<string|int, mixed>
Returns an array of screens list with their respective titles. Used by Theme Editor to build the screend selection dropdown For retro-compatibility purpose, if the array is empty it will use the old default values.
getshowpopups()  : mixed
Get showpopups value from config or template configuration
getTemplateAndMotherNames()  : string
getTemplateForAsset()  : TemplateConfiguration|bool
Find which template should be used to render a given view
getTemplateForFile()  : TemplateConfig
Get the template for a given file. It checks if a file exist in the current template or in one of its mother templates Can return a 302 redirect (this is not really a throw …
getTemplateForXPath()  : mixed
getTemplatesWithNoDb()  : array<string|int, TemplateConfiguration>
Returns an array with uninstalled and/or incompatible survey themes
getTemplateURL()  : string
Returns the complete URL path to a given template name
getThemeOptionsFromSurveyId()  : array<string|int, mixed>
Returns a Theme options array based on a surveyID
getTwigStrings()  : array<string|int, mixed>
Returns all the twig strings inside the current XML. Used from TwigCommand NOTE: this not recursive. So it will show only the string of the current XML, not of parent XML. (not needed to generate twig cache from command line since all XML files are parsed)
getTypeIcon()  : string
getValidScreenFiles()  : array<string|int, mixed>
Used from the template editor.
importManifest()  : bool
Installs an available theme Create a new entry in {{templates}} and {{template_configuration}} table using the template manifest
importManifestLss()  : bool
Create a new entry in {{template_configuration}} table using the survey theme options from lss export file
isCompatible()  : bool|null
Checks if theme is compatible with the current limesurvey version
model()  : TemplateConfiguration
Returns the static model of the specified AR class.
prepareTemplateRendering()  : self
Prepare all the needed datas to render the temple If any problem (like template doesn't exist), it will load the default theme configuration NOTE 1: This function will create/update all the packages needed to render the template, which imply to do the same for all mother templates NOTE 2: So if you just want to access the TemplateConfiguration AR Object, you don't need to call it. Call it only before rendering anything related to the template.
relations()  : array<string|int, mixed>
removeFiles()  : mixed
Remove the css/js files defined in theme config, from any package (even the core ones) The file should have the exact same name as in the package (see: application/config/packages.php and application/config/vendor.php) eg: to remove awesome-bootstrap-checkbox.css, in the theme config file add <remove>awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css</remove>
rename()  : mixed
Change the template name inside the manifest (called from template editor) NOTE: all tests (like template exist, etc) are done from template controller.
rules()  : array<string|int, mixed>
sanitizeImagePathsOnJson()  : mixed
Sanitizes the theme options making sure that paths are valid.
search()  : CActiveDataProvider
Retrieves a list of models based on the current search/filter conditions.
searchGrid()  : CActiveDataProvider
Retrieves a list of models based on the current search/filter conditions.
setBasics()  : mixed
Specific Integration of TemplateConfig.
setGlobalOption()  : void
Set a value on a given option at global setting level (survey level not affected).
setOption()  : void
Set option (unless if options is set to "inherit").
setOptionKeysToInherit()  : mixed
Set each option key value to 'inherit' instead of having only one 'inherit' value for options.
setToInherit()  : mixed
tableName()  : string
throwConsoleError()  : mixed
uninstall()  : bool|int
Uninstalls the selected surveytheme and deletes database entry and configuration
uninstallThemesRecursive()  : void
Uninstalls all surveythemes that are being extended from the supplied surveytheme name
validateTheme()  : bool
Checks if a theme is valid Can be extended with more checks in the future if needed
addMotherTemplatePackage()  : array<string|int, string>
loads the main theme template from the parent theme that it is extending, as a package. Ready to be registered
changeMotherConfiguration()  : array<string|int, mixed>
Change the mother template configuration depending on template settings
createTemplatePackage()  : mixed
Create a package for the asset manager.
getCustomScreenData()  : mixed
If theme developer created custom screens, they will provide custom data.
getDependsPackages()  : array<string|int, string>
Get the depends package
getFilePath()  : string|false
Get the file path for a given template.
getFilesTo()  : array<string|int, mixed>
From a list of json files in db it will generate a PHP array ready to use by removeFileFromPackage()
getFilesToLoad()  : array<string|int, mixed>
From a list of json files in db it will generate a PHP array ready to use by removeFileFromPackage()
getFrameworkAssetsReplacement()  : array<string|int, mixed>
Get the list of file replacement from Engine Framework
getFrameworkAssetsToReplace()  : array<string|int, mixed>
Get the list of file replacement from Engine Framework
getOfiles()  : bool|mixed
Get the json files (to load/replace/remove) from a theme, and checks if its correctly formated
getOptionKey()  : mixed
Search through the inheritence chain and find the inherited value for theme option
getTemplateConfigurationForAttribute()  : TemplateConfiguration
Get the closest template in the hierarchy that has the definition for $attribute
parseDefaultData()  : mixed
removeFileFromPackage()  : void
Proxy for Yii::app()->clientScript->removeFileFromPackage() It's not realy needed here, but it is needed for TemplateConfiguration model.
removeFilesFromPackage()  : mixed
Checks if some files are inside a package, and remove them.
setIsStandard()  : void
Check if this template is a standard template and save it in current model $this->isStandard
setMotherTemplates()  : mixed
Configure the mother template (and its mother templates) This is an object recursive call to TemplateManifest::prepareTemplateRendering()
setOptionInheritance()  : void
Loop through all theme options defined, trigger check for inheritance and write the new value back to the options object
setOptions()  : void
Decodes json string from the database field "options" and stores it inside $this->oOptions Also triggers inheritence checks
setThisTemplate()  : void
Set the default configuration values for the template, and use the motherTemplate value if needed
uninstallIncorectTheme()  : mixed
Uninstall a theme and, display error message, and redirect to theme list
getAttributeValue()  : mixed
Returns the value of the specified attribute ($attributeName) from the closest Template in the hierarchy.
getImageInfo()  : array<string|int, mixed>|null
Return image information
getRelatedTemplate()  : Template|null
Returns the related Template.
getRelativePath()  : string
readManifest()  : void
Read the config.xml file of the template and push its contents to $this->config
replaceVariationFilesWithRtl()  : array<string|int, mixed>
When rtl language is chosen: if a css file in folder variations is in array cssFiles, then it will be replaced with the *-rtl version
setCssFramework()  : void
setPath()  : mixed
Set the path of the current template It checks if it's a core or a user template, if it exists, and if it has a config file
setTemplateName()  : mixed
Set the template name.

Properties

$aInstancesFromTemplateName

public static array<string|int, mixed> $aInstancesFromTemplateName

cache for method getInstanceFromTemplateName

$aPreparedToRender

public static array<string|int, mixed> $aPreparedToRender

cache for method prepareTemplateRendering

$config

public SimpleXMLElement $config

Will contain the config.xml

$cssFramework

public object $cssFramework

What framework css is used

$filesPath

public string $filesPath

Path of the tmeplate's files

$isStandard

public bool $isStandard

Is this template a core one?

$oParentTemplate

public TemplateConfiguration $oParentTemplate

The parent template name A template configuration, in the database, can inherit from another one. This used to manage the different configuration levels for a very same template: global, survey group, survey This is not related to motherTemplate (inheritance between two different templates)

$sPackageName

public string $sPackageName

Name of the asset package of this template

$sPreviewImgTag

public string $sPreviewImgTag

the template preview image tag for the template list

$sTemplateName

public string $sTemplateName = ''

The template name

$sTemplateurl

public string $sTemplateurl

Url to reach the framework

$viewPath

public string $viewPath

Path of the views files (twig template)

$aCssFrameworkReplacement

protected array<string|int, mixed> $aCssFrameworkReplacement

Css Framework Replacement

$apiVersion

protected int $apiVersion

Version of the LS API when created. Must be private : disallow update

$depends

protected array<string|int, string> $depends = array()

List of all dependencies (could be more that just the config.xml packages)

$hasConfigFile

protected string $hasConfigFile = ''

Does it has a config.xml file?

$iSurveyId

protected int $iSurveyId = ''

The current Survey Id. It can be void. It's use only to retrieve the current template of a given survey

$packages

protected array<string|int, string> $packages

Array of package dependencies defined in config.xml

$xmlFile

protected string $xmlFile

What xml config file does it use? (config/minimal)

$aFrameworkAssetsToReplace

private array<string|int, mixed> $aFrameworkAssetsToReplace

cache for the method getFrameworkAssetsToReplace()

$aReplacements

private array<string|int, mixed> $aReplacements

cache for the method getFrameworkAssetsReplacement

Methods

__get()

PHP getter magic method.

public __get(string $name) : mixed

This method is overridden so that AR attributes can be accessed like properties.

Parameters
$name : string

property name

Tags
see
getAttribute
Return values
mixed

property value

__toString()

public __toString() : string
Tags
todo

document me

Return values
string

actualizeLastUpdate()

Update the configuration file "last update" node.

public actualizeLastUpdate() : mixed

For now, it is called only from template editor

addFileReplacement()

Add a file replacement entry eg: <filename replace="css/template.css">css/template.css</filename>

public addFileReplacement(string $sFile, string $sType) : bool|void
Parameters
$sFile : string

the file to replace

$sType : string

css|js

Return values
bool|void

addFileReplacementInDB()

Add a file replacement entry in DB In the first place it tries to get the all the configuration entries for this template (it can be void if edited from template editor, or they can be numerous if the template has local config at survey/survey group/user level) Then, it call $oTemplateConfiguration->addFileReplacement($sFile, $sType) for each one of them.

public addFileReplacementInDB(string $sFile, string $sType) : mixed
Parameters
$sFile : string

the file to replace

$sType : string

css|js

addOptionFromXMLToLiveTheme()

Apply options from XML configuration for all missing template options

public addOptionFromXMLToLiveTheme() : void

addOptionToLiveTheme()

Add an option definition to the current theme.

public addOptionToLiveTheme(string $name, mixed $value) : void

Will be used to turn ON ajax mode on update.

Parameters
$name : string
$value : mixed

attributeLabels()

public attributeLabels() : array<string|int, mixed>
Tags
todo

document me

Return values
array<string|int, mixed>

customized attribute labels (name=>label)

changeAuthorInDom()

Change author inside the DOM

public static changeAuthorInDom(DOMDocument $oNewManifest) : mixed
Parameters
$oNewManifest : DOMDocument

The DOMDOcument of the manifest

changeDateInDOM()

Change the date inside the DOMDocument Used only when copying/extend a survey

public static changeDateInDOM(DOMDocument $oNewManifest[, string $sDate = '' ]) : mixed
Parameters
$oNewManifest : DOMDocument

The DOMDOcument of the manifest

$sDate : string = ''

The wanted date, if empty the current date with config time adjustment will be used

changeEmailInDom()

Change author email inside the DOM

public static changeEmailInDom(DOMDocument $oNewManifest) : mixed
Parameters
$oNewManifest : DOMDocument

The DOMDOcument of the manifest

changeExtendsInDom()

Change the extends node inside the DOM If it doesn't exist, it will create it

public static changeExtendsInDom(DOMDocument $oNewManifest, string $sToExtends) : mixed
Parameters
$oNewManifest : DOMDocument

The DOMDOcument of the manifest

$sToExtends : string

Name of the template to extends

changeNameInDOM()

Change the name inside the DOMDocument (will not save it)

public static changeNameInDOM(DOMDocument $oNewManifest, string $sName) : mixed
Parameters
$oNewManifest : DOMDocument

The DOMDOcument of the manifest

$sName : string

The wanted name

checkAndcreateSurveyConfig()

For a given survey, it checks if its theme have a all the needed configuration entries (survey + survey group).

public static checkAndcreateSurveyConfig(int $iSurveyId) : TemplateConfiguration

Else, it will create it.

Parameters
$iSurveyId : int
Return values
TemplateConfiguration

the template configuration for the survey group

checkTemplate()

Check if the template exists and is valid

public checkTemplate() : bool
Return values
bool

convertOptionsToJson()

Extracts option values from theme options node (XML) into a json key-value map.

public static convertOptionsToJson(array<string|int, mixed>|object $options) : string

Inner nodes (which maybe inside each option element) are ignored. Option values are trimmed as they may contain undesired new lines in the XML document.

Parameters
$options : array<string|int, mixed>|object

the filed to convert

Return values
string

json

deleteEngineInDom()

Delete engine node inside the DOM, except the optionspage configuration

public static deleteEngineInDom(DOMDocument $oNewManifest) : mixed
Parameters
$oNewManifest : DOMDocument

The DOMDOcument of the manifest

extendsConfig()

Update the config file of a given template so that it extends another one

public static extendsConfig(string $sToExtends, string $sNewName) : mixed

It will:

  1. Delete files and engine nodes
  2. Update the name of the template
  3. Change the creation/modification date to the current date
  4. Change the autor name to the current logged in user
  5. Change the author email to the admin email

Used in template editor Both templates and configuration files must exist before using this function

It's used when extending a template from template editor

Parameters
$sToExtends : string

the name of the template to extend

$sNewName : string

the name of the new template

extendsFile()

Copy a file from mother template to local directory and edit manifest if needed

public extendsFile(mixed $sFile) : string
Parameters
$sFile : mixed
Return values
string

template url

formatArrayFields()

This will prepare an array for the field, so the json_encode will create If a field is empty, its value should not be null, but an empty array for the json encoding in DB

public static formatArrayFields(TemplateManifest $oTemplate, string $sFieldPath, string $sFieldName) : array<string|int, mixed>
Parameters
$oTemplate : TemplateManifest
$sFieldPath : string

path to the field (under config)

$sFieldName : string

name of the field

Return values
array<string|int, mixed>

field value | empty array

formatToJsonArray()

Convert the values to a json.

public static formatToJsonArray(array<string|int, mixed>|object $oFiled[, bool $bConvertEmptyToString = false ]) : string

It checks that the correct values is inserted.

Parameters
$oFiled : array<string|int, mixed>|object

the filed to convert

$bConvertEmptyToString : bool = false

formats empty values as empty strings instead of objects.

Return values
string

json

getAllDbTemplateFolders()

Returns an array of all unique template folders that are registered in the database

public static getAllDbTemplateFolders() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getApiVersion()

get the template API version

public getApiVersion() : int
Return values
int

getAssetsToReplaceFormated()

Get the list of file replacement from Engine Framework

public static getAssetsToReplaceFormated(mixed $oEngine, string $sType[, bool $bInlcudeRemove = false ]) : stdClass
Parameters
$oEngine : mixed
$sType : string

css|js the type of file

$bInlcudeRemove : bool = false

also get the files to remove

Return values
stdClass

getButtons()

Get buttons/actions for the "Available admin themes", not installed

public getButtons() : string
Tags
throws
CException
Return values
string

getClassAndAttributes()

Core config and attributes

public getClassAndAttributes() : mixed

Most classes and id and attributes from template views are defined here. So even if users extends/modify the core template, we can still apply some debugs

NB 1: Some of the classes should be bring back to templates

NB 2: This is a temporary function. Before releasing to master, it will be replaced by a XML file inside the template itself So third party providers will also be able to use this mechanics to provides bug fixes/enhancement to their templates

getContentForScreen()

Returns the content file name for a given screen

public getContentForScreen(string $sScreen) : string
Parameters
$sScreen : string

the screen you want to retrieve the files from. If null: all screens

Return values
string

the file name

getDefaultCoreDataForRendering()

Hard coded data for theme rendering outside of the normal survey taking.

public getDefaultCoreDataForRendering() : mixed

Currently used in two cases: theme editor preview, and twig cache file generation from command line.

getDefaultDataForLanguageChanger()

public getDefaultDataForLanguageChanger([mixed $thissurvey = array() ]) : mixed
Parameters
$thissurvey : mixed = array()

getDefaultDataForRendering()

Return the default datas for theme views.

public getDefaultDataForRendering([mixed $thissurvey = array() ]) : mixed

This is used when rendering the views outside of the normal survey taking. Currently used in two cases: theme editor preview, and twig cache file generation from command line.

Parameters
$thissurvey : mixed = array()

getDefaultDataForRenderingFromXml()

public getDefaultDataForRenderingFromXml([mixed $thissurvey = array() ]) : mixed
Parameters
$thissurvey : mixed = array()

getDescription()

Twig statements can be used in Theme description Override method from TemplateConfiguration to use the description from the XML

public getDescription() : string
Return values
string

description from the xml

getFilePathForEditing()

Retreives the absolute path for a file to edit (current template, mother template, etc) Also perform few checks (permission to edit? etc)

public getFilePathForEditing(string $sFile[, mixed $aAllowedFiles = null ]) : mixed
Parameters
$sFile : string

relative path to the file to edit

$aAllowedFiles : mixed = null

getFilesForPackages()

Get the files (css or js) defined in the manifest of a template and its mother templates

public getFilesForPackages(string $type, string $oRTemplate) : array<string|int, mixed>
Parameters
$type : string

css|js

$oRTemplate : string

template from which the recurrence should start

Return values
array<string|int, mixed>

getFontDropdownOptions()

public static getFontDropdownOptions() : mixed

getHasOptionPage()

Returns true if this theme or any mothertemplate has a TemplateConfiguration set

public getHasOptionPage() : bool
Tags
throws
Exception
Return values
bool

getInstance()

Get an instance of a fitting TemplateConfiguration NOTE: for rendering prupose, you should never call this function directly, but rather Template::getInstance.

public static getInstance([string $sTemplateName = null ][, int $iSurveyGroupId = null ][, int $iSurveyId = null ][, mixed $abstractInstance = false ]) : TemplateConfiguration

if force_xmlsettings_for_survey_rendering is on, then the configuration from the XML file should be loaded, not the one from database

Parameters
$sTemplateName : string = null
$iSurveyGroupId : int = null
$iSurveyId : int = null
$abstractInstance : mixed = false
Return values
TemplateConfiguration

getInstanceFromSurveyGroup()

Returns a TemplateConfiguration Object based on a surveygroup ID If no instance is existing, it will create one.

public static getInstanceFromSurveyGroup(int $iSurveyGroupId[, string $sTemplateName = null ][, bool $abstractInstance = false ]) : TemplateConfiguration
Parameters
$iSurveyGroupId : int
$sTemplateName : string = null
$abstractInstance : bool = false
Return values
TemplateConfiguration

getInstanceFromSurveyId()

Returns a TemplateConfiguration Object based on a surveyID If no instance is existing, it will create one.

public static getInstanceFromSurveyId(int $iSurveyId[, string $sTemplateName = null ][, bool $abstractInstance = false ]) : TemplateConfiguration
Parameters
$iSurveyId : int
$sTemplateName : string = null
$abstractInstance : bool = false
Return values
TemplateConfiguration

getInstanceFromTemplateName()

Gets an instance of a templateconfiguration by name

public static getInstanceFromTemplateName(string $sTemplateName[, bool $abstractInstance = false ]) : TemplateConfiguration
Parameters
$sTemplateName : string
$abstractInstance : bool = false
Return values
TemplateConfiguration

getLayoutForScreen()

Returns the layout file name for a given screen

public getLayoutForScreen(string $sScreen) : string
Parameters
$sScreen : string

the screen you want to retrieve the files from. If null: all screens

Return values
string

the file name

getManifestDOM()

Get the DOMDocument of the Manifest

public static getManifestDOM(string $sConfigPath) : DOMDocument
Parameters
$sConfigPath : string

path where to find the manifest

Return values
DOMDocument

getOptionAttributes()

Get options_page value from template configuration

public static getOptionAttributes(mixed $path) : mixed
Parameters
$path : mixed

getOptionPageAttributes()

public getOptionPageAttributes() : array<string|int, mixed>
Tags
todo

document me

Return values
array<string|int, mixed>

getOtherFiles()

Get the list of all the files inside the file folder for a template and its mother templates

public getOtherFiles() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPreview()

public getPreview() : array<string|int, mixed>|mixed|string|null
Tags
todo

document me

Return values
array<string|int, mixed>|mixed|string|null

getScreensDetails()

Returns the complete list of screens, with layout and contents. Used from Twig Command line

public getScreensDetails() : array<string|int, mixed>
Return values
array<string|int, mixed>

the list of screens, layouts, contents

getScreensList()

Returns an array of screens list with their respective titles. Used by Theme Editor to build the screend selection dropdown For retro-compatibility purpose, if the array is empty it will use the old default values.

public getScreensList() : array<string|int, mixed>
Return values
array<string|int, mixed>

the list of screens with their titles

getshowpopups()

Get showpopups value from config or template configuration

public getshowpopups() : mixed

getTemplateAndMotherNames()

public getTemplateAndMotherNames() : string
Return values
string

getTemplateForFile()

Get the template for a given file. It checks if a file exist in the current template or in one of its mother templates Can return a 302 redirect (this is not really a throw …

public getTemplateForFile(string $sFile, TemplateConfig $oRTemplate[, bool $force = false ]) : TemplateConfig
Parameters
$sFile : string

the file to look for (must contain relative path, unless it's a view file)

$oRTemplate : TemplateConfig

template from which the recurrence should start

$force : bool = false

file to be in template or mother template

Return values
TemplateConfig

getTemplateForXPath()

public static getTemplateForXPath(mixed $oTemplate, string $sFieldPath) : mixed
Parameters
$oTemplate : mixed
$sFieldPath : string

getTemplateURL()

Returns the complete URL path to a given template name

public getTemplateURL() : string
Tags
throws
CException
Return values
string

template url

getThemeOptionsFromSurveyId()

Returns a Theme options array based on a surveyID

public static getThemeOptionsFromSurveyId([int $iSurveyId = 0 ][, bool $bInherited = false ]) : array<string|int, mixed>
Parameters
$iSurveyId : int = 0
$bInherited : bool = false

should inherited theme option values be used?

Return values
array<string|int, mixed>

getTwigStrings()

Returns all the twig strings inside the current XML. Used from TwigCommand NOTE: this not recursive. So it will show only the string of the current XML, not of parent XML. (not needed to generate twig cache from command line since all XML files are parsed)

public getTwigStrings([array<string|int, mixed> $items = array() ]) : array<string|int, mixed>
Parameters
$items : array<string|int, mixed> = array()

if you already have a list of items and want to use it.

Return values
array<string|int, mixed>

the list of strings using twig

getValidScreenFiles()

Used from the template editor.

public getValidScreenFiles([string $sType = "view" ][, string $sScreen = null ]) : array<string|int, mixed>

It returns an array of editable files by screen for a given file type

Parameters
$sType : string = "view"

the type of files (view/css/js)

$sScreen : string = null

the screen you want to retrieve the files from. If null: all screens

Return values
array<string|int, mixed>

array ( [screen name] => array([files]) )

importManifest()

Installs an available theme Create a new entry in {{templates}} and {{template_configuration}} table using the template manifest

public static importManifest(string $sTemplateName[, mixed $aDatas = array() ]) : bool
Parameters
$sTemplateName : string

the name of the template to import

$aDatas : mixed = array()

Data

Tags
throws
Exception
Return values
bool

true on success | exception

importManifestLss()

Create a new entry in {{template_configuration}} table using the survey theme options from lss export file

public static importManifestLss([ $iSurveyId = 0 ][,  $xml = null ]) : bool
Parameters
$iSurveyId : = 0

int the id of the survey

$xml : = null

SimpleXMLElement

Return values
bool

true on success

isCompatible()

Checks if theme is compatible with the current limesurvey version

public static isCompatible( $themePath) : bool|null
Parameters
$themePath :
Return values
bool|null

model()

Returns the static model of the specified AR class.

public static model([string $className = __CLASS__ ]) : TemplateConfiguration

Please note that you should have this exact method in all your CActiveRecord descendants!

Parameters
$className : string = __CLASS__

active record class name.

Return values
TemplateConfiguration

the static model class

prepareTemplateRendering()

Prepare all the needed datas to render the temple If any problem (like template doesn't exist), it will load the default theme configuration NOTE 1: This function will create/update all the packages needed to render the template, which imply to do the same for all mother templates NOTE 2: So if you just want to access the TemplateConfiguration AR Object, you don't need to call it. Call it only before rendering anything related to the template.

public prepareTemplateRendering([string $sTemplateName = '' ][, string $iSurveyId = '' ][, bool $bUseMagicInherit = true ]) : self
Parameters
$sTemplateName : string = ''

the name of the template to load. The string comes from the template selector in survey settings

$iSurveyId : string = ''

the id of the survey. If

$bUseMagicInherit : bool = true
Return values
self

relations()

public relations() : array<string|int, mixed>
Tags
todo

document me

Return values
array<string|int, mixed>

relational rules.

removeFiles()

Remove the css/js files defined in theme config, from any package (even the core ones) The file should have the exact same name as in the package (see: application/config/packages.php and application/config/vendor.php) eg: to remove awesome-bootstrap-checkbox.css, in the theme config file add <remove>awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css</remove>

public removeFiles() : mixed

rename()

Change the template name inside the manifest (called from template editor) NOTE: all tests (like template exist, etc) are done from template controller.

public static rename(string $sOldName, string $sNewName) : mixed
Parameters
$sOldName : string

The old name of the template

$sNewName : string

The newname of the template

rules()

public rules() : array<string|int, mixed>
Tags
todo

document me

Return values
array<string|int, mixed>

validation rules for model attributes.

sanitizeImagePathsOnJson()

Sanitizes the theme options making sure that paths are valid.

public sanitizeImagePathsOnJson(mixed $attribute, mixed $params) : mixed

Options that match a file will be marked as invalid if the file is not valid, or replaced with the virtual path if the file is valid.

Parameters
$attribute : mixed
$params : mixed

Retrieves a list of models based on the current search/filter conditions.

public search() : CActiveDataProvider

Typical usecase:

  • Initialize the model fields with values from filter form.
  • Execute this method to get CActiveDataProvider instance which will filter models according to data in model fields.
  • Pass data provider to CGridView, CListView or any similar widget.
Return values
CActiveDataProvider

the data provider that can return the models based on the search/filter conditions.

searchGrid()

Retrieves a list of models based on the current search/filter conditions.

public searchGrid([int $gsid = null ]) : CActiveDataProvider
Parameters
$gsid : int = null

Survey group, else get global

Tags
throws
Exception
Return values
CActiveDataProvider

setBasics()

Specific Integration of TemplateConfig.

public setBasics([mixed $sTemplateName = '' ][, mixed $iSurveyId = '' ][, mixed $bUseMagicInherit = false ]) : mixed
Parameters
$sTemplateName : mixed = ''
$iSurveyId : mixed = ''
$bUseMagicInherit : mixed = false

setGlobalOption()

Set a value on a given option at global setting level (survey level not affected).

public setGlobalOption(string $name, mixed $value) : void

Will be used to turn ON ajax mode on update.

Parameters
$name : string
$value : mixed

setOption()

Set option (unless if options is set to "inherit").

public setOption(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed

setOptionKeysToInherit()

Set each option key value to 'inherit' instead of having only one 'inherit' value for options.

public setOptionKeysToInherit() : mixed

Keys are fetched from parent xml configuration.

tableName()

public tableName() : string
Tags
todo

document me

Return values
string

the associated database table name

throwConsoleError()

public throwConsoleError([string|null $sCustomMessage = null ]) : mixed
Parameters
$sCustomMessage : string|null = null
Tags
throws
CException
todo

document me

uninstall()

Uninstalls the selected surveytheme and deletes database entry and configuration

public static uninstall(string $templatename) : bool|int
Parameters
$templatename : string

Name of Template

Tags
throws
CDbException
Return values
bool|int

uninstallThemesRecursive()

Uninstalls all surveythemes that are being extended from the supplied surveytheme name

public static uninstallThemesRecursive( $templateName) : void
Parameters
$templateName :
Tags
throws
CDbException

validateTheme()

Checks if a theme is valid Can be extended with more checks in the future if needed

public static validateTheme( $themeName,  $themePath[, bool $redirect = true ]) : bool
Parameters
$themeName :
$themePath :
$redirect : bool = true
Tags
throws
CDbException
Return values
bool

addMotherTemplatePackage()

loads the main theme template from the parent theme that it is extending, as a package. Ready to be registered

protected addMotherTemplatePackage(mixed $packages) : array<string|int, string>
Parameters
$packages : mixed
Return values
array<string|int, string>

changeMotherConfiguration()

Change the mother template configuration depending on template settings

protected changeMotherConfiguration(mixed $sType, mixed $aSettings) : array<string|int, mixed>
Parameters
$sType : mixed
$aSettings : mixed
Return values
array<string|int, mixed>

createTemplatePackage()

Create a package for the asset manager.

protected createTemplatePackage(TemplateConfiguration|TemplateManifest $oTemplate) : mixed

The asset manager will push to tmp/assets/xyxyxy/ the whole template directory (with css, js, files, etc.) And it will publish the CSS and the JS defined in config.xml. So CSS can use relative path for pictures. The publication of the package itself is in LSETwigViewRenderer::renderTemplateFromString()

Parameters
$oTemplate : TemplateConfiguration|TemplateManifest

TemplateManifest

getCustomScreenData()

If theme developer created custom screens, they will provide custom data.

protected getCustomScreenData([mixed $thissurvey = array() ]) : mixed

This function will get those custom data to pass them to the preview.

Parameters
$thissurvey : mixed = array()

getFilePath()

Get the file path for a given template.

protected getFilePath(string $sFile, TemplateConfig $oTemplate) : string|false

It will check if css/js (relative to path), or view (view path) It will search for current template and mother templates

Parameters
$sFile : string

relative path to the file

$oTemplate : TemplateConfig

the template where to look for (and its mother templates)

Return values
string|false

getFilesTo()

From a list of json files in db it will generate a PHP array ready to use by removeFileFromPackage()

protected getFilesTo(mixed $oTemplate, mixed $sType, mixed $sAction) : array<string|int, mixed>
Parameters
$oTemplate : mixed
$sType : mixed
$sAction : mixed
Return values
array<string|int, mixed>

getFilesToLoad()

From a list of json files in db it will generate a PHP array ready to use by removeFileFromPackage()

protected getFilesToLoad(mixed $oTemplate, mixed $sType) : array<string|int, mixed>
Parameters
$oTemplate : mixed
$sType : mixed
Return values
array<string|int, mixed>

getFrameworkAssetsReplacement()

Get the list of file replacement from Engine Framework

protected getFrameworkAssetsReplacement(string $sType) : array<string|int, mixed>
Parameters
$sType : string

css|js the type of file

Return values
array<string|int, mixed>

getFrameworkAssetsToReplace()

Get the list of file replacement from Engine Framework

protected getFrameworkAssetsToReplace(string $sType[, bool $bInlcudeRemove = false ]) : array<string|int, mixed>
Parameters
$sType : string

css|js the type of file

$bInlcudeRemove : bool = false

also get the files to remove

Return values
array<string|int, mixed>

getOfiles()

Get the json files (to load/replace/remove) from a theme, and checks if its correctly formated

protected getOfiles( $oTemplate,  $sField) : bool|mixed
Parameters
$oTemplate :

the theme to check

$sField :

name of the DB field to get (file_css, file_js, file_print_css)

Return values
bool|mixed

getOptionKey()

Search through the inheritence chain and find the inherited value for theme option

protected getOptionKey(string $key) : mixed
Parameters
$key : string

parseDefaultData()

protected parseDefaultData(mixed $sXpath, mixed $aArrayToFeed) : mixed
Parameters
$sXpath : mixed
$aArrayToFeed : mixed

removeFileFromPackage()

Proxy for Yii::app()->clientScript->removeFileFromPackage() It's not realy needed here, but it is needed for TemplateConfiguration model.

protected removeFileFromPackage(string $sPackageName, string $sType, array<string|int, mixed> $aSettings) : void

So, we use it here to have the same interface for TemplateManifest and TemplateConfiguration, So, in the future, we'll can both inherit them from a same object (best would be to extend CModel to create a LSYii_Template)

Parameters
$sPackageName : string

name of the package to edit

$sType : string

the type of settings to change (css or js)

$aSettings : array<string|int, mixed>

array of local setting

removeFilesFromPackage()

Checks if some files are inside a package, and remove them.

protected removeFilesFromPackage(string $sPackageName, array<string|int, mixed> $aPackage, string $sType, array<string|int, mixed> $aFilesToRemove) : mixed
Parameters
$sPackageName : string

name of the package

$aPackage : array<string|int, mixed>

the package to check (as provided by Yii::app()->clientScript)

$sType : string

the type of file (css or js)

$aFilesToRemove : array<string|int, mixed>

an array containing the files to chech and remove

setIsStandard()

Check if this template is a standard template and save it in current model $this->isStandard

protected setIsStandard() : void
Tags
throws
CException

setMotherTemplates()

Configure the mother template (and its mother templates) This is an object recursive call to TemplateManifest::prepareTemplateRendering()

protected setMotherTemplates() : mixed

setOptionInheritance()

Loop through all theme options defined, trigger check for inheritance and write the new value back to the options object

protected setOptionInheritance() : void

setOptions()

Decodes json string from the database field "options" and stores it inside $this->oOptions Also triggers inheritence checks

protected setOptions() : void

setThisTemplate()

Set the default configuration values for the template, and use the motherTemplate value if needed

protected setThisTemplate() : void

uninstallIncorectTheme()

Uninstall a theme and, display error message, and redirect to theme list

protected uninstallIncorectTheme(string $sTemplateName) : mixed
Parameters
$sTemplateName : string

getAttributeValue()

Returns the value of the specified attribute ($attributeName) from the closest Template in the hierarchy.

private getAttributeValue(string $attributeName) : mixed
Parameters
$attributeName : string

getImageInfo()

Return image information

private getImageInfo(string $file[, mixed $pathPrefix = '' ]) : array<string|int, mixed>|null
Parameters
$file : string

with Path

$pathPrefix : mixed = ''
Return values
array<string|int, mixed>|null

getRelatedTemplate()

Returns the related Template.

private getRelatedTemplate() : Template|null

The template can only be accessed as a relation when this model is stored in the DB. Before saving, $this->template is null. In that case, this method will load the approriate Template.

Return values
Template|null

getRelativePath()

private getRelativePath( $from,  $to) : string
Parameters
$from :
$to :
Tags
todo

document me

Return values
string

readManifest()

Read the config.xml file of the template and push its contents to $this->config

private readManifest() : void
Tags
throws
Exception

replaceVariationFilesWithRtl()

When rtl language is chosen: if a css file in folder variations is in array cssFiles, then it will be replaced with the *-rtl version

private replaceVariationFilesWithRtl(array<string|int, mixed> $cssFiles) : array<string|int, mixed>
Parameters
$cssFiles : array<string|int, mixed>
Return values
array<string|int, mixed>

setPath()

Set the path of the current template It checks if it's a core or a user template, if it exists, and if it has a config file

private setPath() : mixed

setTemplateName()

Set the template name.

private setTemplateName([mixed $sTemplateName = '' ][, mixed $iSurveyId = '' ]) : mixed

If no templateName provided, then a survey ID should be given (it will then load the template related to the survey)

Parameters
$sTemplateName : mixed = ''
$iSurveyId : mixed = ''

        
On this page

Search results