Sei sulla pagina 1di 2

class Template Represents a set of template units loaded from a single file.

Template units con sist in HTML with special tags. ***** Static functions ***** public static function enableStyles() public static function disableStyles() Styles are collections of templates that can be swapped in real time in order to produce a skinned website. When styles are enabled, the templates are located in subdirectories tha t correspond to the current style. public static function setPath($newpath) Changes the template path in real time. Usually unnecessary. public static function setStylePathPrefix($newprefix) Changes the prefix for style subdirectories. public static function setStyle($style) Changes the current active style, if styles are enabled. public static function getBasePath() Returns the current path for loaded templates, based on the remaining se ttings. public static function enableInnerCache() public static function disableInnerCache() public static function clearCache() The cache, enabled by default, stores template instances so they only ha ve to be loaded once in the same script run, even when they are instanced multiple times. Uses more memory and less CPU. public static function enableEarlyResolution() public static function disableEarlyResolution() *NOT IMPLEMENTED YET - CURRENTLY MAKES NO DIFFERENCE* Mode in which all template tags (except variables) are expanded on load. Requires more CPU on load but less CPU when a unit is retrieved; Overall it uses fewer resources when units are use d multiple times from the same Template instance. However, it is often desirable not to expand template tags th is early, so their value can depend on usage context. public static function setMessages($minstance) public static function unsetMessages() Associating an instance of Messages to Template is mandatory in order to enable parsing of message tags. If there are no message tags in any template you intend to use, then this is unneces sary. public static function registerConstant($label, $value) public static function unregisterConstant($label) public static function getConstant($label) This constant will automatically expand onto all templates that use it f rom this point onwards. ***** Factory method ***** public static function get($filename) Produces an instance of Template from a template file.

***** Accessors ***** public function getName() Retrieves the filename of the template. public function getPath() Retrieves the path of the template. public function getUnit($unit, $values = NULL, $fromAssoc = false) Retrieves a template unit's HTML, to be used for webpage generation. $values is an array containing variables to be expanded within the unit. The format is as follows: If $fromAssoc is FALSE, then $values[0] = "var1"; $values[1] = "value1"; $values[2] = "var2"; $values[3] = "value2"; etc... If $fromAssoc is TRUE, then $values["var1"] = "value1"; $values["var2] = "value2"; etc... public function getHTML($values = NULL, $fromAssoc = false) Retrieves the 'default' unit's HTML (see above). ***** Functions ***** public function setAllUnits($values, $destroyLeftovers = false, $fromAssoc = fal se) Expands all the units in the template immediately, storing the results i n the instance. See: enableEarlyResolution, getUnit If $destroyLeftovers is TRUE, then all template tags not expanded after this function will be removed from the HTML. private function destroyTemplateTags($html) Retrieves a string with all template tags removed.

Potrebbero piacerti anche