TemplateConfiguration

Extends \TemplateConfig

Class TemplateConfig Common methods for TemplateConfiguration and TemplateManifest

Methods

tableName

tableName() : string

Response

string

the associated database table name

rules

rules() : array

Response

array

validation rules for model attributes.

relations

relations() : array

Response

array

relational rules.

attributeLabels

attributeLabels() : array

Response

array

customized attribute labels (name=>label)

Gets an instance of a templateconfiguration by name

getInstanceFromTemplateName(string $sTemplateName) : \TemplateConfiguration
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
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
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
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
static

Arguments

$sTemplateName

string

$iSurveyGroupId

integer

$iSurveyId

integer

Response

\TemplateConfiguration

Returns the static model of the specified AR class.

model(string $className = __CLASS__) : \TemplateConfiguration
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

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

setToInherit

setToInherit() 

checkTemplate

checkTemplate() 

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

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 = '') 

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

..}, "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

getTypeIcon

getTypeIcon() 

getButtons

getButtons() 

getHasOptionPage

getHasOptionPage() 

_filterImages

_filterImages($file) 

Arguments

$file

getOptionPageAttributes

getOptionPageAttributes() 

getOptionPage

getOptionPage() 

Change the mother template configuration depending on template settings

changeMotherConfiguration($sType, $aSettings) : array
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

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

getTemplateForPath

getTemplateForPath(\TemplateConfiguration $oRTemplate, string $sPath) 

Arguments

$sPath

string

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

setThisTemplate() 

setCssFramework

setCssFramework() 

setOptions

setOptions() 

setOptionInheritance

setOptionInheritance() 

getOptionKey

getOptionKey(string $key) : mixed

Arguments

$key

string

Response

mixed

addMotherTemplatePackage

addMotherTemplatePackage($packages) 

Arguments

$packages

Get the list of file replacement from Engine Framework

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

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

getFrameworkAssetsReplacement(string $sType) : array

Arguments

$sType

string

css|js the type of file

Response

array

getParentConfiguration

getParentConfiguration() 

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

Arguments

$sOldName

string

The old name of the template

$sNewName

string

The newname of the template

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

Arguments

$name

string

the name of the attribute

Response

mixed

get the template API version

getApiVersion() : integer
inherited

Response

integer

Returns the complete URL path to a given template name

getTemplateURL() : string
inherited

Response

string

template url

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

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
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 : 

bJustCreated

bJustCreated : 

the template preview image tag for the template list

sPreviewImgTag : string
var

the template preview image tag for the template list

Type(s)

string

cache for method getInstanceFromTemplateName

aInstancesFromTemplateName : array
static
var

cache for method getInstanceFromTemplateName

Type(s)

array

cache for method prepareTemplateRendering

aPreparedToRender : array
static
var

cache for method prepareTemplateRendering

Type(s)

array

is the template valid?

bTemplateCheckResult : boolean
var

is the template valid?

Type(s)

boolean

the type of template for icon (core vs user)

sTypeIcon : string
var

the type of template for icon (core vs user)

Type(s)

string

cache for the method getFilesToLoad()

aFilesToLoad : array
var

cache for the method getFilesToLoad()

Type(s)

array

cache for the method getFrameworkAssetsToReplace()

aFrameworkAssetsToReplace : array
var

cache for the method getFrameworkAssetsToReplace()

Type(s)

array

cache for the method getFrameworkAssetsReplacement

aReplacements : array
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