returns a new template string object with the resource id being the template source code
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
creates a template from a string
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:
caches the provided output into the cache file
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
clears the cached template if it's older than the given time
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
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)
void
forceCompilation
()
returns the cached template output file name, true if it's cache-able but not cached or false if it's not cached
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
returns the full cached file name and assigns a default value to it if required
string
getCacheFilename
(
Dwoo $dwoo)
-
Dwoo
$dwoo: the dwoo instance that requests the file name
returns the cache duration for this template
defaults to null if it was not provided
int|null
getCacheTime
()
Implementation of:
- Dwoo_ITemplate::getCacheTime()
- returns the cache duration for this template
returns the chmod value for all files written (cached or compiled ones)
defaults to 0777
int|null
getChmod
()
returns the full compiled file name and assigns a default value to it if required
string
getCompiledFilename
(
Dwoo $dwoo)
-
Dwoo
$dwoo: the dwoo instance that requests the file name
Redefined in descendants as:
returns the compiler used by this template, if it was just compiled, or null
Implementation of:
- Dwoo_ITemplate::getCompiler()
- returns the compiler used by this template, if it was just compiled, or null
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
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:
returns the resource identifier for this template, false here as strings don't have identifiers
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:
returns the resource name for this template class
string
getResourceName
()
Implementation of:
- Dwoo_ITemplate::getResourceName()
- returns the resource name for this template class
Redefined in descendants as:
returns the template source of this template
string
getSource
()
Implementation of:
- Dwoo_ITemplate::getSource()
- returns the template source of this template
Redefined in descendants as:
returns an unique value identifying the current version of this template, in this case it's the md4 hash of the content
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
Checks if compiled file is valid (it exists)
boolean
isValidCompiledFile
(string $file)
Redefined in descendants as:
ensures the given path exists
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)
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
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
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
void
setChmod
([int $mask = null])
-
int
$mask: new bitmask to use for all files