TemplateConfig
extends CActiveRecord
in package
Class TemplateConfig Common methods for TemplateConfiguration and TemplateManifest
Table of Contents
Properties
- $config : SimpleXMLElement
- $cssFramework : object
- $filesPath : string
- $isStandard : bool
- $oMotherTemplate : TemplateConfiguration
- $oOptionAttributes : mixed
- $oOptions : object
- $options_page : mixed
- $path : string
- $sPackageName : string
- $sTemplateName : string
- $sTemplateurl : string
- $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
Methods
- __toString() : string
- convertOptionsToJson() : string
- Extracts option values from theme options node (XML) into a json key-value map.
- 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
- getClassAndAttributes() : mixed
- Core config and attributes
- 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 …
- 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
- importManifest() : bool
- Create a new entry in {{templates}} and {{template_configuration}} table using the template manifest
- isCompatible() : bool|null
- Checks if theme is compatible with the current limesurvey version
- 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>
- 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
- changeMotherConfiguration() : array<string|int, mixed>
- Change the mother template configuration depending on template settings
- getDependsPackages() : array<string|int, string>
- Get the depends package
- getFilePath() : string|false
- Get the file path for a given template.
- getFilesToLoad() : array<string|int, mixed>
- From a list of json files in db it will generate a PHP array ready to use by removeFileFromPackage()
- 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
Properties
$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?
$oMotherTemplate
public
TemplateConfiguration
$oMotherTemplate
The mother template object This is used when a template inherit another one.
$oOptionAttributes
public
mixed
$oOptionAttributes
$oOptions
public
object
$oOptions
The template options
$options_page
public
mixed
$options_page
= 'core'
$path
public
string
$path
Path of this template
$sPackageName
public
string
$sPackageName
Name of the asset package of this template
$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)
Methods
__toString()
public
__toString() : string
Tags
Return values
stringconvertOptionsToJson()
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
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>|nullgetApiVersion()
get the template API version
public
getApiVersion() : int
Return values
intgetClassAndAttributes()
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
getTemplateForAsset()
Find which template should be used to render a given view
public
getTemplateForAsset(string $sFile, TemplateConfiguration $oRTemplate) : TemplateConfiguration|bool
Parameters
- $sFile : string
-
the file to check
- $oRTemplate : TemplateConfiguration
-
the template where the custom option page should be looked for
Return values
TemplateConfiguration|boolgetTemplateForFile()
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
TemplateConfiggetTemplatesWithNoDb()
Returns an array with uninstalled and/or incompatible survey themes
public
static getTemplatesWithNoDb() : array<string|int, TemplateConfiguration>
Return values
array<string|int, TemplateConfiguration>getTemplateURL()
Returns the complete URL path to a given template name
public
getTemplateURL() : string
Return values
string —template url
importManifest()
Create a new entry in {{templates}} and {{template_configuration}} table using the template manifest
public
static importManifest(string $sTemplateName, array<string|int, mixed> $aDatas) : bool
Parameters
- $sTemplateName : string
-
the name of the template to import
- $aDatas : array<string|int, mixed>
Tags
Return values
bool —true on success | exception
isCompatible()
Checks if theme is compatible with the current limesurvey version
public
static isCompatible( $themePath) : bool|null
Parameters
Return values
bool|nullremoveFiles()
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
throwConsoleError()
public
throwConsoleError([string|null $sCustomMessage = null ]) : mixed
Parameters
- $sCustomMessage : string|null = null
Tags
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
Return values
bool|intuninstallThemesRecursive()
Uninstalls all surveythemes that are being extended from the supplied surveytheme name
public
static uninstallThemesRecursive( $templateName) : void
Parameters
Tags
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
Tags
Return values
boolchangeMotherConfiguration()
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>getDependsPackages()
Get the depends package
protected
getDependsPackages(TemplateConfiguration $oTemplate) : array<string|int, string>
Parameters
- $oTemplate : TemplateConfiguration
Tags
Return values
array<string|int, string>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|falsegetFilesToLoad()
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>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