Template

Extends\LSActiveRecord

Class Template

package

Default

Methods

attributeLabels

attributeLabels(): array

Response

array

customized attribute labels (name=>label)

Lists the behaviors of this model

behaviors(): array
inherited

Below is a list of all behaviors we register:

see \PluginEventBehavior\CTimestampBehavior

Response

array

checkExtendsItSelf

checkExtendsItSelf(): boolean
Throws
\Exception

if name equals extends.

Response

boolean

checkIfTemplateExists

checkIfTemplateExists(string $sTemplateName): boolean
static

Arguments

$sTemplateName

string

Response

boolean

checkTemplate

checkTemplate(): boolean
Throws
\Exception

if extended template is not installed.

Response

boolean

Throws exception if any of the extended templates are not installed; otherwise returns true.

checkTemplateExtends(): boolean
Throws
\Exception

if extended template is not installed.

Response

boolean

Check if a given Template has a valid XML File

checkTemplateXML(string $sTemplateFolder): boolean
static
TODO

: check api version

Arguments

$sTemplateFolder

string

the template forder name where to look for the XML

Response

boolean

Decrypt values from database

decrypt( $value = '')
inherited

Arguments

$value

Encrypt/decrypt values

decryptEncryptAttributes( $action = 'decrypt')
inherited

Arguments

$action

Decrypt single value

decryptSingle(string $value = ''): string
inheritedstatic

Arguments

$value

string

String value which needs to be decrypted

Response

string

the decrypted string

Decrypt single value

decryptSingleOld(string $value = ''): string
inheritedstatic

Arguments

$value

string

String value which needs to be decrypted

Response

string

the decrypted string

deleteAllByAttributes

deleteAllByAttributes(array $attributes,string $condition = '',array $params = array()): integer
inherited
todo

This should also be moved to the behavior at some point. This method overrides the parent in order to raise PluginEvents for Bulk delete operations.

Filter Criteria are wrapped into a CDBCriteria instance so we have a single instance responsible for holding the filter criteria to be passed to the PluginEvent, this also enables us to pass the fully configured CDBCriteria instead of the original Parameters.

See {@link find()} for detailed explanation about $condition and $params.

Arguments

$attributes

array

list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.

$condition

string

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

integer

number of rows affected by the execution.

Delete asset related to this template Using DB only

deleteAssetVersion(): integer

Response

integer

(0|1)

dispatchPluginModelEvent

dispatchPluginModelEvent(string $sEventName,\CDbCriteria $criteria = null,array $eventParams = []): \PluginEvent
inherited

Arguments

$sEventName

string

$criteria

\CDbCriteria

$eventParams

array

Response

\PluginEvent

Encrypt values

encrypt()
inherited

Attribute values are encrypted ( if needed )to be used for searching purposes

encryptAttributeValues(array $attributes = null, $bEncryptedOnly = false, $bReplaceValues = true): array
inherited

Arguments

$attributes

array

list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.

$bEncryptedOnly

$bReplaceValues

Response

array

attributes array with encrypted atrribute values is returned

Encrypt values before saving to the database

encryptSave( $runValidation = false)
inherited

Arguments

$runValidation

Enrypt single value

encryptSingle(string $value = '')
inheritedstatic

Arguments

$value

string

String value which needs to be encrypted

Finds all active records satisfying the specified condition but returns them as array

findAllAsArray(mixed $condition = '',array $params = array()): array
inherited

See \find() for detailed explanation about $condition and $params.

Arguments

$condition

mixed

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

array

list of active records satisfying the specified condition. An empty array is returned if none is found.

Overriding of Yii's findAllByAttributes method to provide encrypted attribute value search

findAllByAttributes(array $attributes,mixed $condition = '',array $params = array()): array<mixed,static>
inherited

Arguments

$attributes

array

list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.

$condition

mixed

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

array<mixed,static>

the records found. An empty array is returned if none is found.

Overriding of Yii's findByAttributes method to provide encrypted attribute value search

findByAttributes(array $attributes,mixed $condition = '',array $params = array()): static|null
inherited

Arguments

$attributes

array

list of attribute values (indexed by attribute names) that the active record should match. An attribute value can be an array which will be used to generate an IN condition.

$condition

mixed

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

static|null

the record found. Null if none is found.

Alias function for resetAssetVersion() Don't delete this one to maintain updgrade compatibility

forceAssets(): void

getAllEncryptedAttributes

getAllEncryptedAttributes(integer $iSurveyId,string $sClassName): array
inherited

Arguments

$iSurveyId

integer

$sClassName

string

Response

array

TODO: Should be split into seperate functions in the appropiate model or helper class TODO: Make an interface for records that support encryption.

getAllTemplatesDirectories

getAllTemplatesDirectories()
static

Retrieves a list of broken themes

getBrokenThemes( $sFolder = null)
static

Arguments

$sFolder

Retrieves a list of deprecated templates (the templates in upload/templates/)

getDeprecatedTemplates()
static

Get instance of template object.

getInstance(string $sTemplateName = null,integer|string $iSurveyId = null,integer|string $iSurveyGroupId = null,boolean $bForceXML = null, $abstractInstance = false,boolean $last = false): self
static

Will instantiate the template object first time it is called.

NOTE 1: This function will call prepareTemplateRendering that 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 use this one. Call it only before rendering anything related to the template. NOTE 3: If you need to get the related configuration to this template, rather use: getTemplateConfiguration() NOTE 4: If you want the lastest generated theme, just call Template::getLastInstance()

Arguments

$sTemplateName

string

$iSurveyId

integer|string

$iSurveyGroupId

integer|string

$bForceXML

boolean

$abstractInstance

$last

boolean

if you want to get the last instace without providing template name or sid

Response

self

Return last instance if it exists, else generate it or throw an exception depending on $bAutoGenerate.

getLastInstance(boolean $bAutoGenerate = true): self
static

Arguments

$bAutoGenerate

boolean

: should the function try to generate an instance if it doesn't exist?

Response

self

Return the max value for a field

getMaxId(string $field = null,boolean $forceRefresh = false): false|integer
inherited

This is a convenience method, that uses the primary key of the model to retrieve the highest value.

Throws
\Exception

Arguments

$field

string

The field that contains the Id, when null primary key is used if it is a single field

$forceRefresh

boolean

Don't use value from static cache but always requery the database

Response

false|integer

Return the min value for a field

getMinId(string $field = null,boolean $forceRefresh = false): false|integer
inherited

This is a convenience method, that uses the primary key of the model to retrieve the highest value.

Throws
\Exception

Arguments

$field

string

The field that contains the Id, when null primary key is used if it is a single field

$forceRefresh

boolean

Don't use value from static cache but always requery the database

Response

false|integer

Return the list of ALL files present in the file directory

getOtherFiles(string $filesDir): array
static

Arguments

$filesDir

string

Response

array

Return the standard template list

getStandardTemplateList(): array<mixed,string>
static
deprecated

Use SurveyThemeHelper::getStandardTemplateList() instead.

Throws
\Exception

Response

array<mixed,string>

This method construct a template object, having all the needed configuration datas.

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

It checks if the required template is a core one or a user one. If it's a user template, it will check if it's an old 2.0x template to provide default configuration values corresponding to the old template system If it's not an old template, it will check if it has a configuration file to load its datas. If it's not the case (template probably doesn't exist), it will load the default template configuration TODO : more tests should be done, with a call to private function _is_valid_template(), testing not only if it has a config.xml, but also id this file is correct, if the files refered in css exist, etc.

Arguments

$sTemplateName

string

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

$iSurveyId

integer

the id of the survey.

$iSurveyGroupId

$bForceXML

boolean

the id of the survey.

$abstractInstance

Response

\TemplateConfiguration

getTemplateInFolder

getTemplateInFolder( $sFolder)
static
deprecated

Use SurveyThemeHelper::getTemplateInFolder() instead.

Arguments

$sFolder

getTemplateInStandard

getTemplateInStandard()
static
deprecated

Use SurveyThemeHelper::getTemplateInStandard() instead.

getTemplateInUpload

getTemplateInUpload()
static
deprecated

Use SurveyThemeHelper::getTemplateInUpload() instead.

Returns an array of all available template names - does a basic check if the template might be valid

getTemplateList(): array
static

TODO: replace the calls to that function by a data provider based on search

Response

array

getTemplateListWithPreviews

getTemplateListWithPreviews(): array
static

Response

array

TODO: replace the calls to that function by a data provider based on search

Get the template path for any template : test if template if exist

getTemplatePath(string $sTemplateName = ""): string
static

Arguments

$sTemplateName

string

Response

string

template path

This function returns the complete URL path to a given template name

getTemplatesFileFolder(string $sTemplateName = ""): string
static

Arguments

$sTemplateName

string

Response

string

template url

This function returns the complete URL path to a given template name

getTemplateURL(string $sTemplateName = ""): string
static

Arguments

$sTemplateName

string

Response

string

template url

hasInheritance

hasInheritance( $sTemplateName)
static

Arguments

$sTemplateName

Check if the current instance is the correct one. Could be more complex in the future

isCorrectInstance(string $sTemplateName = null): boolean
static

Arguments

$sTemplateName

string

Response

boolean

isStandardTemplate returns true if a template is a standard template This function does not check if a template actually exists

isStandardTemplate(mixed $sTemplateName): boolean
static
deprecated

Use SurveyThemeHelper::getStandardTemplateList() instead.

Arguments

$sTemplateName

mixed

template name to look for

Response

boolean

True if standard template, otherwise false

Returns the static model of the specified AR class.

model(string $className = __CLASS__): \Template
static

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

Arguments

$className

string

active record class name.

Response

\Template

the static model class

Returns this table's primary key

primaryKey(): string
access

public

Response

string

Modified version that default to do the same as the original, but allows via a third parameter to retrieve the result as array instead of active records. This solves a joining problem. Usage via findAllAsArray method

query(\CDbCriteria $criteria,boolean $all = false,boolean $asAR = true): mixed
inherited

Performs the actual DB query and populates the AR objects with the query result. This method is mainly internally used by other AR query methods.

since 1.1.7

Arguments

$criteria

\CDbCriteria

the query criteria

$all

boolean

whether to return all data

$asAR

boolean

Response

mixed

the AR objects populated with the query result

relations

relations(): array

Response

array

relational rules.

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

renameTo(string $sNewName)

Arguments

$sNewName

string

The newname of the template

Reset assets for this template Using DB only

resetAssetVersion(): void

Sets self::$instance to null; Needed for unit test.

resetInstance()
static

rules

rules(): array

Response

array

validation rules for model attributes.

Function to show encryption symbol in gridview attribute header if value ois encrypted

setEncryptedAttributeLabel(integer $surveyId,string $className,string $attributeName): string
inherited
Throws
\CException

Arguments

$surveyId

integer

$className

string

$attributeName

string

Response

string

tableName

tableName(): string

Response

string

the associated database table name

Filter the template name : test if template if exist

templateNameFilter(string $sTemplateName): string
static

Arguments

$sTemplateName

string

Response

string

existing $sTemplateName

Updates records with the specified condition.

updateAll(array $attributes,mixed $condition = '',array $params = array()): integer
inherited

XSS filtering is enforced for attributes listed in model's $xssFilterAttributes property. See \find() for detailed explanation about $condition and $params. Note, the attributes are not checked for safety and no validation is done.

Arguments

$attributes

array

list of attributes (name=>$value) to be updated

$condition

mixed

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

integer

the number of rows being updated

Properties

cache for the method getAllTemplatesDirectories

aAllTemplatesDir :array
static
var

cache for the method getAllTemplatesDirectories

Type(s)

array

cache for the method getTemplateFilesFolder

aTemplatesFileFolder :array
static
var

cache for the method getTemplateFilesFolder

Type(s)

array

cache for the method templateNameFilter

aNamesFiltered :array
static
var

cache for the method templateNameFilter

Type(s)

array

- The instance of template object

instance :\Template
static
var
  • The instance of template object

Type(s)

\Template

Array of attributes that should be XSS filtered on mass updates

xssFilterAttributes :array<mixed,string>
inherited
var

Array of attributes that should be XSS filtered on mass updates

Type(s)

array<mixed,string>

bEncryption

bEncryption :
inherited

Type(s)

name

name :string

Template name

Type(s)

string

folder

folder :string

Template folder name eg: 'default'

Type(s)

string

title

title :string

Type(s)

string

creation_date

creation_date :string

Type(s)

string

author

author :string

Type(s)

string

author_email

author_email :string

Type(s)

string

author_url

author_url :string

Type(s)

string

license

license :string

Type(s)

string

version

version :string

Type(s)

string

view_folder

view_folder :string

Type(s)

string

files_folder

files_folder :string

Type(s)

string

description

description :string

Type(s)

string

last_update

last_update :string

Type(s)

string

api_version

api_version :string

Type(s)

string

owner_id

owner_id :integer

Type(s)

integer

extends

extends :string

Type(s)

string