TemplateManifest

Extends \TemplateConfiguration

Template Configuration Model

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

package

LimeSurvey

subpackage

Backend

Methods

Update the configuration file "last update" node.

actualizeLastUpdate() 

For now, it is called only from template editor

Used from the template editor.

getValidScreenFiles(string $sType = "view", string $sScreen = null) : array

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

Arguments

$sType

string

the type of files (view/css/js)

$sScreen

string

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

Response

array

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

Returns the layout file name for a given screen

getLayoutForScreen(string $sScreen) : string

Arguments

$sScreen

string

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

Response

string

the file name

Returns the content file name for a given screen

getContentForScreen(string $sScreen) : string

Arguments

$sScreen

string

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

Response

string

the file name

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

getFilePathForEditing(string $sFile, $aAllowedFiles = null) 

Arguments

$sFile

string

relative path to the file to edit

$aAllowedFiles

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

extendsFile($sFile) : string

Arguments

$sFile

Response

string

template url

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

getFilesForPackages(string $type, string $oRTemplate) : array

Arguments

$type

string

css|js

$oRTemplate

string

template from which the recurrence should start

Response

array

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.

addFileReplacementInDB(string $sFile, string $sType) 

Arguments

$sFile

string

the file to replace

$sType

string

css|js

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

getOtherFiles() : array

Response

array

Returns the complete URL path to a given template name

getTemplateURL() : string
inherited

Response

string

template url

getButtons

getButtons() 
inherited

Create a new entry in {{templates}} and {{template_configuration}} table using the template manifest

importManifest(string $sTemplateName, array $aDatas) : boolean
inherited static
throws

InvalidArgumentException

Arguments

$sTemplateName

string

the name of the template to import

$aDatas

array

Response

boolean

true on success | exception

getTemplateForXPath

getTemplateForXPath($oTemplate, string $sFieldPath) 
static

Arguments

$oTemplate

$sFieldPath

string

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

formatArrayFields(\TemplateManifest $oTemplate, string $sFieldPath, string $sFieldName) : array
static

Arguments

$oTemplate

\TemplateManifest

$sFieldPath

string

path to the field (under config)

$sFieldName

string

name of the field

Response

array

field value | empty array

Get the DOMDocument of the Manifest

getManifestDOM(string $sConfigPath) : \DOMDocument
static

Arguments

$sConfigPath

string

path where to find the manifest

Response

\DOMDocument

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

changeNameInDOM(\DOMDocument $oNewManifest, string $sName) 
static

Arguments

$oNewManifest

\DOMDocument

The DOMDOcument of the manifest

$sName

string

The wanted name

Change the date inside the DOMDocument

changeDateInDOM(\DOMDocument $oNewManifest, string $sDate = '') 
static

Arguments

$oNewManifest

\DOMDocument

The DOMDOcument of the manifest

$sDate

string

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

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

rename(string $sOldName, string $sNewName) 
inherited static

Arguments

$sOldName

string

The old name of the template

$sNewName

string

The newname of the template

Delete files and engine node inside the DOM

deleteEngineInDom(\DOMDocument $oNewManifest) 
static

Arguments

$oNewManifest

\DOMDocument

The DOMDOcument of the manifest

Change author inside the DOM

changeAuthorInDom(\DOMDocument $oNewManifest) 
static

Arguments

$oNewManifest

\DOMDocument

The DOMDOcument of the manifest

Change author email inside the DOM

changeEmailInDom(\DOMDocument $oNewManifest) 
static

Arguments

$oNewManifest

\DOMDocument

The DOMDOcument of the manifest

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

changeExtendsInDom(\DOMDocument $oNewManifest, string $sToExtends) 
static

Arguments

$oNewManifest

\DOMDocument

The DOMDOcument of the manifest

$sToExtends

string

Name of the template to extends

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

extendsConfig(string $sToExtends, string $sNewName) 
static

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

Arguments

$sToExtends

string

the name of the template to extend

$sNewName

string

the name of the new template

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

readManifest() 

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

setPath() 

Set the template name.

setTemplateName($sTemplateName = '', $iSurveyId = '') 

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

var

string the name of the template

int the id of the survey

Arguments

$sTemplateName

$iSurveyId

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.

prepareTemplateRendering(string $sTemplateName = '', string $iSurveyId = '', bool $bUseMagicInherit = true) : $this
inherited

Arguments

$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

Response

$this

setBasics

setBasics($sTemplateName = '', $iSurveyId = '') 
inherited

Arguments

$sTemplateName

$iSurveyId

Add a file replacement in the field `file_{css|js|print_css}` in table {{template_configuration}}, eg: {"replace": [ {original files to replace here.

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

..}, "css/template.css",]} In general, should be called from TemplateManifest, after adding a file replacement inside the manifest.

throws

Arguments

$sFile

string

the file to replace

$sType

string

css|js

Response

bool|void

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

getFilesToLoad($oTemplate, $sType) : array
var

string json

Arguments

$oTemplate

$sType

Response

array

Change the mother template configuration depending on template settings

changeMotherConfiguration($sType, $aSettings) : array
inherited
var

string the type of settings to change (css or js)

array array of local setting

Arguments

$sType

$aSettings

Response

array

Proxy for Yii::app()->clientScript->removeFileFromPackage()

removeFileFromPackage(string $sPackageName, string $sType, mixed $aSettings) : array
inherited

Arguments

$sPackageName

string

string name of the package to edit

$sType

string

string the type of settings to change (css or js)

$aSettings

mixed

array array of local setting

Response

array

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

setMotherTemplates() 
inherited

getTemplateForPath

getTemplateForPath(\TemplateConfiguration $oRTemplate, string $sPath) 
inherited

Arguments

$sPath

string

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

setThisTemplate() 
inherited

addMotherTemplatePackage

addMotherTemplatePackage($packages) 
inherited

Arguments

$packages

Get the list of file replacement from Engine Framework

getFrameworkAssetsToReplace(string $sType, boolean $bInlcudeRemove = false) : array
inherited

Arguments

$sType

string

css|js the type of file

$bInlcudeRemove

boolean

also get the files to remove

Response

array

Get the list of file replacement from Engine Framework

getAssetsToReplaceFormated($oEngine, string $sType, boolean $bInlcudeRemove = false) : \stdClass
static

Arguments

$oEngine

$sType

string

css|js the type of file

$bInlcudeRemove

boolean

also get the files to remove

Response

\stdClass

Get the list of file replacement from Engine Framework

getFrameworkAssetsReplacement(string $sType) : array
inherited

Arguments

$sType

string

css|js the type of file

Response

array

tableName

tableName() : string
inherited

Response

string

the associated database table name

rules

rules() : array
inherited

Response

array

validation rules for model attributes.

relations

relations() : array
inherited

Response

array

relational rules.

attributeLabels

attributeLabels() : array
inherited

Response

array

customized attribute labels (name=>label)

Gets an instance of a templateconfiguration by name

getInstanceFromTemplateName(string $sTemplateName) : \TemplateConfiguration
inherited static

Arguments

$sTemplateName

string

Response

\TemplateConfiguration

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

getInstanceFromSurveyGroup(integer $iSurveyGroupId, string $sTemplateName = null) : \TemplateConfiguration
inherited static

Arguments

$iSurveyGroupId

integer

$sTemplateName

string

Response

\TemplateConfiguration

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

getInstanceFromSurveyId(integer $iSurveyId, string $sTemplateName = null) : \TemplateConfiguration
inherited static

Arguments

$iSurveyId

integer

$sTemplateName

string

Response

\TemplateConfiguration

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

checkAndcreateSurveyConfig(int $iSurveyId) : \TemplateConfiguration
inherited static
TODO

: recursivity for survey group

Arguments

$iSurveyId

int

Response

\TemplateConfiguration

the template configuration for the survey group

Get an instance of a fitting TemplateConfiguration

getInstance(string $sTemplateName = null, integer $iSurveyGroupId = null, integer $iSurveyId = null) : \TemplateConfiguration
inherited static

Arguments

$sTemplateName

string

$iSurveyGroupId

integer

$iSurveyId

integer

Response

\TemplateConfiguration

Returns the static model of the specified AR class.

model(string $className = __CLASS__) : \TemplateConfiguration
inherited static

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

Arguments

$className

string

active record class name.

Response

\TemplateConfiguration

the static model class

setToInherit

setToInherit() 
inherited

checkTemplate

checkTemplate() 
inherited

getTypeIcon

getTypeIcon() 
inherited

getHasOptionPage

getHasOptionPage() 
inherited

_filterImages

_filterImages($file) 
inherited

Arguments

$file

getOptionPageAttributes

getOptionPageAttributes() 
inherited

getOptionPage

getOptionPage() 
inherited

setCssFramework

setCssFramework() 
inherited

setOptions

setOptions() 
inherited

setOptionInheritance

setOptionInheritance() 
inherited

getOptionKey

getOptionKey(string $key) : mixed
inherited

Arguments

$key

string

Response

mixed

getParentConfiguration

getParentConfiguration() 
inherited

Proxy for the AR method to manage the inheritance If one of the field that can be inherited is set to "inherit", then it will return the value of its parent NOTE: this is recursive, if the parent field itself is set to inherit, then it will the value of the parent of the parent, etc

__get(string $name) : mixed
inherited

Arguments

$name

string

the name of the attribute

Response

mixed

get the template API version

getApiVersion() : integer
inherited

Response

integer

Get the template for a given file. It checks if a file exist in the current template or in one of its mother templates

getTemplateForFile(string $sFile, \TemplateConfig $oRTemplate) : \TemplateConfig
inherited
throws

Arguments

$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

Response

\TemplateConfig

Create a package for the asset manager.

createTemplatePackage(\TemplateConfiguration $oTemplate) 
inherited

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()

Arguments

$oTemplate

\TemplateConfiguration

TemplateManifest

Get the file path for a given template.

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

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

Arguments

$sFile

string

relative path to the file

$oTemplate

\TemplateConfig

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

Response

string|false

Get the depends package

getDependsPackages(\TemplateConfiguration $oTemplate) : string[]
inherited
uses

Arguments

Response

string[]

getPreview

getPreview() 
inherited

setIsStandard

setIsStandard() : boolean|null
inherited

Response

boolean|null

Core config and attributes

getClassAndAttributes() 
inherited

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

__toString

__toString() 
inherited

uninstall

uninstall($templatename) 
inherited static

Arguments

$templatename

Get a string containing the name of the current template and all its parents Used to inject those names into body classes

getTemplateAndMotherNames() 
inherited

Convert the values to a json.

formatToJsonArray(array|object $oFiled) : string
inherited static

It checks that the correct values is inserted.

Arguments

$oFiled

array|object

the filed to convert

Response

string

json

getAllDbTemplateFolders

getAllDbTemplateFolders() 
inherited

getTemplatesWithNoDb

getTemplatesWithNoDb() 
inherited

Properties

templateEditor

templateEditor : 

the template preview image tag for the template list

sPreviewImgTag : string
inherited
var

the template preview image tag for the template list

Type(s)

string

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)

oParentTemplate : \TemplateConfiguration
inherited
var

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)

Type(s)

\TemplateConfiguration

bUseMagicInherit

bUseMagicInherit : 
inherited

bJustCreated

bJustCreated : 
inherited

cache for method getInstanceFromTemplateName

aInstancesFromTemplateName : array
inherited static
var

cache for method getInstanceFromTemplateName

Type(s)

array

cache for method prepareTemplateRendering

aPreparedToRender : array
inherited static
var

cache for method prepareTemplateRendering

Type(s)

array

is the template valid?

bTemplateCheckResult : boolean
inherited
var

is the template valid?

Type(s)

boolean

the type of template for icon (core vs user)

sTypeIcon : string
inherited
var

the type of template for icon (core vs user)

Type(s)

string

cache for the method getFilesToLoad()

aFilesToLoad : array
inherited
var

cache for the method getFilesToLoad()

Type(s)

array

cache for the method getFrameworkAssetsToReplace()

aFrameworkAssetsToReplace : array
inherited
var

cache for the method getFrameworkAssetsToReplace()

Type(s)

array

cache for the method getFrameworkAssetsReplacement

aReplacements : array
inherited
var

cache for the method getFrameworkAssetsReplacement

Type(s)

array

The template name

sTemplateName : string
inherited
var

The template name

Type(s)

string

Name of the asset package of this template

sPackageName : string
inherited
var

Name of the asset package of this template

Type(s)

string

Path of this template

path : string
inherited
var

Path of this template

Type(s)

string

Url to reach the framework

sTemplateurl : string[]
inherited
var

Url to reach the framework

Type(s)

string[]

Path of the views files (twig template)

viewPath : string
inherited
var

Path of the views files (twig template)

Type(s)

string

Path of the tmeplate's files

filesPath : string
inherited
var

Path of the tmeplate's files

Type(s)

string

What framework css is used

cssFramework : string[]
inherited
var

What framework css is used

Type(s)

string[]

Is this template a core one?

isStandard : boolean
inherited
var

Is this template a core one?

Type(s)

boolean

Will contain the config.xml

config : \SimpleXMLElement
inherited
var

Will contain the config.xml

Type(s)

\SimpleXMLElement

The mother template object This is used when a template inherit another one.

oMotherTemplate : \TemplateConfiguration
inherited
var

The mother template object This is used when a template inherit another one.

Type(s)

\TemplateConfiguration

The template options

oOptions : array
inherited
var

The template options

Type(s)

array

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

depends : string[]
inherited
var

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

Type(s)

string[]

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

apiVersion : integer
inherited
var

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

Type(s)

integer

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

iSurveyId : string
inherited
var

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

Type(s)

string

Does it has a config.xml file?

hasConfigFile : string
inherited
var

Does it has a config.xml file?

Type(s)

string

Array of package dependencies defined in config.xml

packages : \stdClass[]
inherited
var

Array of package dependencies defined in config.xml

Type(s)

\stdClass[]

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

xmlFile : string
inherited
var

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

Type(s)

string

Css Framework Replacement

aCssFrameworkReplacement : array
inherited
var

Css Framework Replacement

Type(s)

array

allDbTemplateFolders

allDbTemplateFolders : 
inherited

aTemplatesWithoutDB

aTemplatesWithoutDB : 
inherited static