spunQ_Template Class Reference

A template folder. More...

List of all members.

Public Member Functions

 getName ()
 Gets the name of this template.
 getTemplateFile ()
 Gets the template file.
 getFolder ()
 Gets the template folder.
 getWidth ()
 Gets the declared width of the template.
 getCacheOptions ()
 Provides options for the caching mechanism.
 getDescription ()
 Gets the description of the template out of the doc comment.
 getAnnotations ()
 Provides all annotations of this template.
 getJsIsInHeader ()
 Whether this template's js file should be in the header.
 getRequiredVariables ()
 Gets the required variables, mapped to their type description.
 getVariableDefaults ()
 Gets the current variable defaults.
 filterVariables ($variables)
 Checks for each variable given whether it is defined in the template.
 getRequiredCss ()
 getRequiredJs ()
 display ($variables)
 Shows this template with given variable values.

Static Public Member Functions

static get ($alias)
 Gets the template with given alias.
static parseVarType ($string, $filePath)
 Parses a variable definition line in the doc comment.

Protected Member Functions

 __construct ($name, $file)
 Constructor.
 initFromDocComment ()
 Sets members according to definition in the template file's doc comment.

Protected Attributes

 $name
 The name of this template.
 $variables = array()
 Variables required by this template, mapped to their type description.
 $variableDefaults = array()
 Default values for variables.
 $requiredCss = array()
 Css aliases required by this template.
 $headerJs = array()
 Header javascript aliases required by this template.
 $footerJs = array()
 Footer javascript aliases required by this template.
 $width
 Width of the template as declared in doc comment.
 $description
 Description of the template as declared in doc comment.
 $annotations
 All annotations of this template.
 $file
 The template file.
 $cacheOptions = array()
 Mapping cache options to their values.
 $jsIsInHeader = false
 Whether this file's javascript file should be in the header.
 $devModeComments = true
 Whether surrounding html comments should be displayed in dev mode.

Static Protected Attributes

static $instances = array()

Private Member Functions

 printComments ()
 Checks if HTML comments should be displayed before & after tpl.
 _display ($variables)
 Helper function for display().


Detailed Description

A template folder.

spunQ templates are kept in separate folders (one for each template), since the number of files associated with a single folder can be quite a few. A template folder can contain the following files:

Todo:
document interpreted doc-comment tags.

Definition at line 27 of file Template.class.php.


Constructor & Destructor Documentation

spunQ_Template::__construct ( name,
file 
) [protected]

Constructor.

Parameters:
$name The name of the template
$file The template file

Definition at line 161 of file Template.class.php.


Member Function Documentation

spunQ_Template::_display ( variables  )  [private]

Helper function for display().

Needed for including the template file with a clean scope.

Parameters:
$variables The variables to set.
Returns:
spunQ_Template $this

Definition at line 439 of file Template.class.php.

spunQ_Template::display ( variables  ) 

Shows this template with given variable values.

Parameters:
$variables Mapping of variable names to values.
Returns:
spunQ_Template $this
Exceptions:
spunQ_MissingVariableException 
spunQ_InvalidVariableException 

Definition at line 280 of file Template.class.php.

spunQ_Template::filterVariables ( variables  ) 

Checks for each variable given whether it is defined in the template.

Parameters:
$variables Mapping of variable names to values.
Returns:
map<string,any>

Definition at line 255 of file Template.class.php.

static spunQ_Template::get ( alias  )  [static]

Gets the template with given alias.

Parameters:
$alias The alias to get template for.
Type:
spunQ_Template

Definition at line 36 of file Template.class.php.

spunQ_Template::getAnnotations (  ) 

Provides all annotations of this template.

Returns:
map<string,string>

Definition at line 220 of file Template.class.php.

spunQ_Template::getCacheOptions (  ) 

Provides options for the caching mechanism.

Returns:
array<array<string>> Doc comment annotations starting with 'cache', return value is identical to that of spunQ_ReflectionTypeParser::parseDocumentation().

Definition at line 205 of file Template.class.php.

spunQ_Template::getFolder (  ) 

Gets the template folder.

Returns:
spunQ_Folder

Definition at line 188 of file Template.class.php.

spunQ_Template::getJsIsInHeader (  ) 

Whether this template's js file should be in the header.

See also:
headers()

footers()

Returns:
boolean

Definition at line 230 of file Template.class.php.

spunQ_Template::getName (  ) 

Gets the name of this template.

Type:
string

Definition at line 172 of file Template.class.php.

spunQ_Template::getRequiredVariables (  ) 

Gets the required variables, mapped to their type description.

Type:
map<string,string>

Definition at line 238 of file Template.class.php.

spunQ_Template::getTemplateFile (  ) 

Gets the template file.

Returns:
spunQ_File

Definition at line 180 of file Template.class.php.

spunQ_Template::initFromDocComment (  )  [protected]

Sets members according to definition in the template file's doc comment.

Returns:
spunQ_Template $this

Definition at line 339 of file Template.class.php.

static spunQ_Template::parseVarType ( string,
filePath 
) [static]

Parses a variable definition line in the doc comment.

Parameters:
$string The line to parse.
$filePath The path to the file this line is coming from. Solely needed for pointing at the file in the case of an exception.
Returns:
array Consisting of the variable name and its type.

Definition at line 54 of file Template.class.php.

spunQ_Template::printComments (  )  [private]

Checks if HTML comments should be displayed before & after tpl.

Placed in dedicated function to not clutter scope of _display().

Returns:
boolean

Definition at line 425 of file Template.class.php.


Member Data Documentation

spunQ_Template::$annotations [protected]

All annotations of this template.

Type:
map<string,string>

Definition at line 129 of file Template.class.php.

spunQ_Template::$cacheOptions = array() [protected]

Mapping cache options to their values.

Type:
array

Definition at line 141 of file Template.class.php.

spunQ_Template::$description [protected]

Description of the template as declared in doc comment.

Type:
string

Definition at line 123 of file Template.class.php.

spunQ_Template::$file [protected]

The template file.

Type:
spunQ_File

Definition at line 135 of file Template.class.php.

spunQ_Template::$footerJs = array() [protected]

Footer javascript aliases required by this template.

Type:
array<string>

Definition at line 111 of file Template.class.php.

spunQ_Template::$headerJs = array() [protected]

Header javascript aliases required by this template.

Type:
array<string>

Definition at line 105 of file Template.class.php.

spunQ_Template::$jsIsInHeader = false [protected]

Whether this file's javascript file should be in the header.

See also:
headers()

footers()

Type:
boolean

Definition at line 149 of file Template.class.php.

spunQ_Template::$name [protected]

The name of this template.

Type:
string

Definition at line 79 of file Template.class.php.

spunQ_Template::$requiredCss = array() [protected]

Css aliases required by this template.

Type:
array<string>

Definition at line 99 of file Template.class.php.

spunQ_Template::$variableDefaults = array() [protected]

Default values for variables.

If a url template omits a variable, this default value will be assumed.

Type:
map<string,string> Mapping of variable names to their default value.

Definition at line 93 of file Template.class.php.

spunQ_Template::$variables = array() [protected]

Variables required by this template, mapped to their type description.

Type:
map<string,string>

Definition at line 85 of file Template.class.php.

spunQ_Template::$width [protected]

Width of the template as declared in doc comment.

Type:
integer

Definition at line 117 of file Template.class.php.


The documentation for this class was generated from the following file:

Generated on Fri Jul 1 11:12:44 2011 for spunQ3 by  doxygen 1.5.9