TemplateConfiguration

Extends\TemplateConfig

Class TemplateConfig Common methods for TemplateConfiguration and TemplateManifest

package

Default

Methods

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

__toString

__toString(): string
inherited
todo

document me

Response

string

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): boolean|void

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

Throws
\Exception

Arguments

$sFile

string

the file to replace

$sType

string

css|js

Response

boolean|void

addMotherTemplatePackage

addMotherTemplatePackage( $packages): array
todo

document me

Arguments

$packages

Response

array

Apply options from XML configuration for all missing template options

addOptionFromXMLToLiveTheme(): void

Add an option definition to the current theme.

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

Will be used to turn ON ajax mode on update.

Arguments

$name

string

$value

mixed

attributeLabels

attributeLabels(): array
todo

document me

Response

array

customized attribute labels (name=>label)

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

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

checkAndcreateSurveyConfig(integer $iSurveyId): \TemplateConfiguration
static

Else, it will create it.

TODO

: recursivity for survey group

Arguments

$iSurveyId

integer

Response

\TemplateConfiguration

the template configuration for the survey group

checkTemplate

checkTemplate(): boolean
todo

document me

Response

boolean

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

defaultScope

defaultScope()
inheritdoc

Convert the values to a json.

formatToJsonArray(array|object $oFiled,boolean $bConvertEmptyToString = false): string
inheritedstatic

It checks that the correct values is inserted.

Arguments

$oFiled

array|object

the filed to convert

$bConvertEmptyToString

boolean

formats empty values as empty strings instead of objects.

Response

string

json

getAllDbTemplateFolders

getAllDbTemplateFolders(): array|null
inherited
todo

document me

Response

array|null

get the template API version

getApiVersion(): integer
inherited

Response

integer

getButtons

getButtons(): string
todo

document me

Response

string

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

Get the depends package

getDependsPackages(\TemplateConfiguration $oTemplate): array<mixed,\stdClass>
inherited
uses

Arguments

Response

array<mixed,\stdClass>

Twig statements can be used in Theme description

getDescription()

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

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

getFilesToLoad( $oTemplate, $sType): array
inherited
var

string js or css ?

Arguments

$oTemplate

$sType

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

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 global template configuration with same name as $this.

getGlobalParent(): \TemplateConfiguration

The global config has no sid, no gsid and no uid.

Response

\TemplateConfiguration

getHasOptionPage

getHasOptionPage(): boolean
todo

document me

Throws
\Exception

Response

boolean

Return image information

getImageInfo(string $file): array|null

Arguments

$file

string

with Path

Response

array|null

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

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

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

Arguments

$sTemplateName

string

$iSurveyGroupId

integer

$iSurveyId

integer

$abstractInstance

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,boolean $abstractInstance = false): \TemplateConfiguration
static

Arguments

$iSurveyGroupId

integer

$sTemplateName

string

$abstractInstance

boolean

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,boolean $abstractInstance = false): \TemplateConfiguration
static

Arguments

$iSurveyId

integer

$sTemplateName

string

$abstractInstance

boolean

Response

\TemplateConfiguration

Gets an instance of a templateconfiguration by name

getInstanceFromTemplateName(string $sTemplateName,boolean $abstractInstance = false): \TemplateConfiguration
static

Arguments

$sTemplateName

string

$abstractInstance

boolean

Response

\TemplateConfiguration

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

getOfiles( $oTemplate, $sField): boolean|mixed

Arguments

$oTemplate

the theme to check

$sField

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

Response

boolean|mixed

getOptionKey

getOptionKey(string $key): mixed
todo

document me

Arguments

$key

string

Response

mixed

getOptionPage

getOptionPage(): mixed
todo

document me

Response

mixed

getOptionPageAttributes

getOptionPageAttributes(): array
todo

document me

Response

array

getParentConfiguration

getParentConfiguration(): \TemplateConfiguration
todo

document me

Response

\TemplateConfiguration

getPreview

getPreview(): array|mixed|string|null
inherited
todo

document me

Response

array|mixed|string|null

getRelativePath

getRelativePath( $from, $to): string
todo

document me

Arguments

$from

$to

Response

string

Get showpopups value from config or template configuration

getshowpopups()

getTemplateAndMotherNames

getTemplateAndMotherNames(): string
todo

document me

Response

string

Find which template should be used to render a given view

getTemplateForAsset(string $sFile,\TemplateConfiguration $oRTemplate): \TemplateConfiguration|boolean
inherited

Arguments

$sFile

string

the file to check

$oRTemplate

\TemplateConfiguration

the template where the custom option page should be looked for

Response

\TemplateConfiguration|boolean

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 …

getTemplateForFile(string $sFile,\TemplateConfig $oRTemplate,boolean $force = false): \TemplateConfig
inherited

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

$force

boolean

file to be in template or mother template

Response

\TemplateConfig

getTemplateForPath

getTemplateForPath(\TemplateConfiguration $oRTemplate,string $sPath): \TemplateConfiguration
todo

document me

Arguments

$sPath

string

Response

\TemplateConfiguration

getTemplatesWithNoDb

getTemplatesWithNoDb(): array|null
inherited
todo

document me

Response

array|null

Returns the complete URL path to a given template name

getTemplateURL(): string
inherited

Response

string

template url

Returns a Theme options array based on a surveyID

getThemeOptionsFromSurveyId(integer $iSurveyId,boolean $bInherited = false): array
static

Arguments

$iSurveyId

integer

$bInherited

boolean

should inherited theme option values be used?

Response

array

getTypeIcon

getTypeIcon(): string
todo

document me

Response

string

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

importManifest(string $sTemplateName,array $aDatas): boolean
inheritedstatic
Throws
\Exception|\InvalidArgumentException

Arguments

$sTemplateName

string

the name of the template to import

$aDatas

array

Response

boolean

true on success | exception

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

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 = '',boolean $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

boolean

Response

$this

relations

relations(): array
todo

document me

Response

array

relational rules.

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

removeFileFromPackage(string $sPackageName,string $sType, $aSettings): void

Arguments

$sPackageName

string

name of the package to edit

$sType

string

the type of settings to change (css or js)

$aSettings

array of local setting

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/third_party.php) eg: to remove awesome-bootstrap-checkbox.css, in the theme config file add <remove>awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css</remove>

removeFiles()
inherited

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

removeFilesFromPackage(string $sPackageName,array $aPackage,string $sType,array $aFilesToRemove)
inherited

Arguments

$sPackageName

string

name of the package

$aPackage

array

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

$sType

string

the type of file (css or js)

$aFilesToRemove

array

an array containing the files to chech and remove

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

rules

rules(): array
todo

document me

Response

array

validation rules for model attributes.

searchGrid

searchGrid(): \CActiveDataProvider
todo

document me

Throws
\Exception

Response

\CActiveDataProvider

setBasics

setBasics(string $sTemplateName = '',string $iSurveyId = '',boolean $bUseMagicInherit = false)
todo

document me

Arguments

$sTemplateName

string

$iSurveyId

string

$bUseMagicInherit

boolean

setCssFramework

setCssFramework(): void
todo

document me

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

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

Will be used to turn ON ajax mode on update.

Arguments

$name

string

$value

mixed

setIsStandard

setIsStandard(): boolean|null
inherited
todo

document me

missing return value (php warning)

Response

boolean|null

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

setMotherTemplates()

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

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

Arguments

$name

string

$value

mixed

setOptionInheritance

setOptionInheritance()
todo

document me

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

setOptionKeysToInherit()

Keys are fetched from parent xml configuration.

setOptions

setOptions(): void
todo

document me

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

setThisTemplate()

setToInherit

setToInherit()
todo

document me

tableName

tableName(): string
todo

document me

Response

string

the associated database table name

throwConsoleError

throwConsoleError(string|null $sCustomMessage = null)
inherited
todo

document me

Throws
\CException

Arguments

$sCustomMessage

string|null

uninstall

uninstall(string $templatename): boolean|integer
inheritedstatic
todo

document me

Arguments

$templatename

string

Name of Template

Response

boolean|integer

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

uninstallIncorectTheme(string $sTemplateName)

Arguments

$sTemplateName

string

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 :

Type(s)

bJustCreated

bJustCreated :

Type(s)

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

of prepared to render TemplateConfig

aPreparedToRender :array
inheritedstatic
var

of prepared to render TemplateConfig

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 getFilesTo

aFilesTo :array
var

cache for the method getFilesTo

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

cache for the method getOfiles

Ofiles :array
var

cache for the method getOfiles

Type(s)

array

generalFilesPath

generalFilesPath :

Type(s)

show warnings when running survey

showpopups :integer
var

show warnings when running survey

Type(s)

integer

template_type

template_type :

Type(s)

template_extends

template_extends :

Type(s)

template_description

template_description :

Type(s)

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 :object
inherited
var

What framework css is used

Type(s)

object

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 :object
inherited
var

The template options

Type(s)

object

oOptionAttributes

oOptionAttributes :
inherited

Type(s)

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

depends :array<mixed,string>
inherited
var

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

Type(s)

array<mixed,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 :array<mixed,\stdClass>
inherited
var

Array of package dependencies defined in config.xml

Type(s)

array<mixed,\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

Type(s)

aTemplatesWithoutDB

aTemplatesWithoutDB :
inheritedstatic

Type(s)

options_page

options_page :
inherited

Type(s)