Class Dwoo_Template_String

Description

Implements interfaces:

represents a Dwoo template contained in a string

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Located in /Dwoo/Template/String.php (line 17)


	
			
Direct descendents
Class Description
Dwoo_Template_File represents a Dwoo template contained in a file
Variable Summary
Method Summary
static Dwoo_Template_String templateFactory (Dwoo $dwoo, mixed $resourceId, [int $cacheTime = null], [string $cacheId = null], [string $compileId = null], [Dwoo_ITemplate $parentTemplate = null])
Dwoo_Template_String __construct (string $templateString, [int $cacheTime = null], [string $cacheId = null], [string $compileId = null])
mixed cache (Dwoo $dwoo, string $output)
bool clearCache (Dwoo $dwoo, [int $olderThan = -1])
string|bool getCachedTemplate (Dwoo $dwoo)
string getCacheFilename (Dwoo $dwoo)
int|null getCacheTime ()
int|null getChmod ()
string getCompiledFilename (Dwoo $dwoo)
string getCompiledTemplate (Dwoo $dwoo, [Dwoo_ICompiler $compiler = null])
string getIsModifiedCode ()
string getName ()
string getResourceName ()
string getSource ()
string getUid ()
boolean isValidCompiledFile (string $file)
void makeDirectory (string $path, [string $baseDir = null])
void setCacheTime ([int $seconds = null])
void setChmod ([int $mask = null])
Variables
static array $cache = array('cached'=>array(),'compiled'=>array()) (line 69)

caches the results of the file checks to save some time when the same templates is rendered several times

  • access: protected
string $cacheId (line 43)

template cache id, if not provided in the constructor, it is set to the md4 hash of the request_uri. it is however highly recommended to provide one that will fit your needs.

in all cases, the compilation id is prepended to the cache id to separate templates with similar cache ids from one another

  • access: protected
int $cacheTime (line 52)

validity duration of the generated cache file (in seconds)

set to -1 for infinite cache, 0 to disable and null to inherit the Dwoo instance's cache time

  • access: protected
int $chmod = 0777 (line 85)

chmod value for all files written (cached or compiled ones)

set to null if you don't want any chmod operation to happen

  • access: protected
bool $compilationEnforced (line 61)

boolean flag that defines whether the compilation should be enforced (once) or not use this if you have issues with the compiled templates not being updated but if you do need this it's most likely that you should file a bug report

  • access: protected
string $compileId (line 31)

template compilation id

  • access: protected
Dwoo_ICompiler $compiler (line 76)

holds the compiler that built this template

  • access: protected
string $name (line 24)

template name

  • access: protected
Methods
static templateFactory (line 407)

returns a new template string object with the resource id being the template source code

  • access: public
static Dwoo_Template_String templateFactory (Dwoo $dwoo, mixed $resourceId, [int $cacheTime = null], [string $cacheId = null], [string $compileId = null], [Dwoo_ITemplate $parentTemplate = null])
  • Dwoo $dwoo: the dwoo instance requiring it
  • mixed $resourceId: the filename (relative to this template's dir) of the template to include
  • int $cacheTime: duration of the cache validity for this template, if null it defaults to the Dwoo instance that will render this template
  • string $cacheId: the unique cache identifier of this page or anything else that makes this template's content unique, if null it defaults to the current url
  • string $compileId: the unique compiled identifier, which is used to distinguish this template from others, if null it defaults to the filename+bits of the path
  • Dwoo_ITemplate $parentTemplate: the template that is requesting a new template object (through an include, extends or any other plugin)

Implementation of:
Dwoo_ITemplate::templateFactory()
returns a new template object from the given resource identifier, null if no include is possible (resource not found), or false if include is not permitted by this resource type

Redefined in descendants as:
  • Dwoo_Template_File::templateFactory() : returns a new template object from the given include name, null if no include is possible (resource not found), or false if include is not permitted by this resource type
Constructor __construct (line 100)

creates a template from a string

  • access: public
Dwoo_Template_String __construct (string $templateString, [int $cacheTime = null], [string $cacheId = null], [string $compileId = null])
  • string $templateString: the template to use
  • int $cacheTime: duration of the cache validity for this template, if null it defaults to the Dwoo instance that will render this template, set to -1 for infinite cache or 0 to disable
  • string $cacheId: the unique cache identifier of this page or anything else that makes this template's content unique, if null it defaults to the current url
  • string $compileId: the unique compiled identifier, which is used to distinguish this template from others, if null it defaults to the md4 hash of the template

Redefined in descendants as:
cache (line 283)

caches the provided output into the cache file

  • return: full path of the cached file or false upon failure
  • access: public
mixed cache (Dwoo $dwoo, string $output)
  • Dwoo $dwoo: the dwoo instance that requests it
  • string $output: the template output

Implementation of:
Dwoo_ITemplate::cache()
caches the provided output into the cache file
clearCache (line 324)

clears the cached template if it's older than the given time

  • return: true if the cache was not present or if it was deleted, false if it remains there
  • access: public
bool clearCache (Dwoo $dwoo, [int $olderThan = -1])
  • Dwoo $dwoo: the dwoo instance that was used to cache that template
  • int $olderThan: minimum time (in seconds) required for the cache to be cleared

Implementation of:
Dwoo_ITemplate::clearCache()
clears the cached template if it's older than the given time
forceCompilation (line 236)

marks this template as compile-forced, which means it will be recompiled even if it

was already saved and wasn't modified since the last compilation. do not use this in production, it's only meant to be used in development (and the development of dwoo particularly)

  • access: public
void forceCompilation ()
getCachedTemplate (line 248)

returns the cached template output file name, true if it's cache-able but not cached or false if it's not cached

  • access: public
string|bool getCachedTemplate (Dwoo $dwoo)
  • Dwoo $dwoo: the dwoo instance that requests it

Implementation of:
Dwoo_ITemplate::getCachedTemplate()
returns the cached template output file name, true if it's cache-able but not cached or false if it's not cached
getCacheFilename (line 435)

returns the full cached file name and assigns a default value to it if required

  • return: the full path to the cached file
  • access: protected
string getCacheFilename (Dwoo $dwoo)
  • Dwoo $dwoo: the dwoo instance that requests the file name
getCacheTime (line 126)

returns the cache duration for this template

defaults to null if it was not provided

  • access: public
int|null getCacheTime ()

Implementation of:
Dwoo_ITemplate::getCacheTime()
returns the cache duration for this template
getChmod (line 153)

returns the chmod value for all files written (cached or compiled ones)

defaults to 0777

  • access: public
int|null getChmod ()
getCompiledFilename (line 419)

returns the full compiled file name and assigns a default value to it if required

  • return: the full path to the compiled file
  • access: protected
string getCompiledFilename (Dwoo $dwoo)
  • Dwoo $dwoo: the dwoo instance that requests the file name

Redefined in descendants as:
getCompiledTemplate (line 338)

returns the compiled template file name

  • access: public
string getCompiledTemplate (Dwoo $dwoo, [Dwoo_ICompiler $compiler = null])
  • Dwoo $dwoo: the dwoo instance that requests it
  • Dwoo_ICompiler $compiler: the compiler that must be used

Implementation of:
Dwoo_ITemplate::getCompiledTemplate()
returns the compiled template file name
getCompiler (line 226)

returns the compiler used by this template, if it was just compiled, or null

  • access: public
Dwoo_ICompiler getCompiler ()

Implementation of:
Dwoo_ITemplate::getCompiler()
returns the compiler used by this template, if it was just compiled, or null
getIsModifiedCode (line 461)

returns some php code that will check if this template has been modified or not

if the function returns null, the template will be instanciated and then the Uid checked

  • access: public
string getIsModifiedCode ()

Implementation of:
Dwoo_ITemplate::getIsModifiedCode()
returns some php code that will check if this template has been modified or not

Redefined in descendants as:
getName (line 175)

returns the template name

  • access: public
string getName ()

Implementation of:
Dwoo_ITemplate::getName()
returns the template name
getResourceIdentifier (line 195)

returns the resource identifier for this template, false here as strings don't have identifiers

  • access: public
false getResourceIdentifier ()

Implementation of:
Dwoo_ITemplate::getResourceIdentifier()
returns the resource identifier for this template or false if it has no identifier

Redefined in descendants as:
getResourceName (line 185)

returns the resource name for this template class

  • access: public
string getResourceName ()

Implementation of:
Dwoo_ITemplate::getResourceName()
returns the resource name for this template class

Redefined in descendants as:
getSource (line 205)

returns the template source of this template

  • access: public
string getSource ()

Implementation of:
Dwoo_ITemplate::getSource()
returns the template source of this template

Redefined in descendants as:
getUid (line 216)

returns an unique value identifying the current version of this template, in this case it's the md4 hash of the content

  • access: public
string getUid ()

Implementation of:
Dwoo_ITemplate::getUid()
returns an unique string identifying the current version of this template, for example a timestamp of the last modified date or a hash of the template source

Redefined in descendants as:
  • Dwoo_Template_File::getUid() : returns an unique value identifying the current version of this template, in this case it's the unix timestamp of the last modification
isValidCompiledFile (line 386)

Checks if compiled file is valid (it exists)

  • return: True cache file existance
  • access: protected
boolean isValidCompiledFile (string $file)
  • string $file: file

Redefined in descendants as:
makeDirectory (line 474)

ensures the given path exists

  • access: protected
void makeDirectory (string $path, [string $baseDir = null])
  • string $path: any path
  • string $baseDir: the base directory where the directory is created ($path must still contain the full path, $baseDir is only used for unix permissions)
setCacheTime (line 141)

sets the cache duration for this template

can be used to set it after the object is created if you did not provide it in the constructor

  • access: public
void setCacheTime ([int $seconds = null])
  • int $seconds: duration of the cache validity for this template, if null it defaults to the Dwoo instance's cache time. 0 = disable and -1 = infinite cache

Implementation of:
Dwoo_ITemplate::setCacheTime()
sets the cache duration for this template
setChmod (line 165)

set the chmod value for all files written (cached or compiled ones)

set to null if you don't want to do any chmod() operation

  • access: public
void setChmod ([int $mask = null])
  • int $mask: new bitmask to use for all files

Documentation generated on Sat, 18 Jul 2009 21:05:21 +0200 by phpDocumentor 1.4.0