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 \CTimestampBehavior \PluginEventBehavior

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

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.

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

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

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

Arguments

$condition

\CDbCriteria

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.

getAllTemplatesDirectories

getAllTemplatesDirectories() 
static

Get instance of template object.

getInstance(string $sTemplateName = null, integer|string $iSurveyId = null, integer|string $iSurveyGroupId = null, boolean $bForceXML = null) : \TemplateConfiguration
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()

Arguments

$sTemplateName

string

$iSurveyId

integer|string

$iSurveyGroupId

integer|string

$bForceXML

boolean

Response

\TemplateConfiguration

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
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) : \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.

Response

\TemplateConfiguration

getTemplateInFolder

getTemplateInFolder( $sFolder) 
static

Arguments

$sFolder

getTemplateInStandard

getTemplateInStandard() 
static

getTemplateInUpload

getTemplateInUpload() 
static

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

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

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

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

resetInstance() 
static

rules

rules() : array

Response

array

validation rules for model attributes.

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

Properties

cache for the method getAllTemplatesDirectories

aAllTemplatesDir : array
static
var

cache for the method getAllTemplatesDirectories

Type(s)

array

cache for the method getTemplateInUpload

aTemplatesInUploadDir : array
static
var

cache for the method getTemplateInUpload

Type(s)

array

cache for the method getTemplateInStandard

aTemplatesInStandardDir : array
static
var

cache for the method getTemplateInStandard

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

list of standard template

standardTemplates : array<mixed,string>
static
var

list of standard template

Type(s)

array<mixed,string>

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

owner_id

owner_id : integer

Type(s)

integer

extends

extends : string

Type(s)

string