API Joomla 1.5.26
Documentation des API du CMS Joomla en version 1.5
|
patTemplate::__toString | ( | ) |
Convert the template to its string representation.
This method allows you to just echo the patTemplate object in order to display the template.
Requires PHP5
$tmpl = new patTemplate(); $tmpl->readTemplatesFromFile( 'myfile.tmpl' ); echo $tmpl;
private
Références getParsedTemplate().
patTemplate::_applyModifers | ( | $ | template, |
&$ | vars | ||
) |
apply variable modifiers
The variables will be passed by reference.
private
string | name of the template (use modifiers from this template) |
array | variables to which the modifiers should be applied |
Références $type, et loadModule().
Référencé par _parseGlobals(), et _parseVariables().
patTemplate::_fetchTemplate | ( | $ | template | ) |
fetch plain template
The template content will be stored in the template configuration so it can be used by other methods.
private
string | template name |
condition template
condition template
modulo template
standard template
Références _fetchVariables(), _getConditionValue(), et _hasVariables().
Référencé par parseTemplate().
patTemplate::_fetchVariables | ( | $ | template | ) |
fetch variables for a template
The variables will be stored in the template configuration so they can be used by other methods.
private
string | template name |
variables already have been fetched
get the scalar variables
get the row variables
add some system variables
Références exists(), et patErrorManager::raiseWarning().
Référencé par _fetchTemplate(), _getConditionValue(), et parseTemplate().
patTemplate::_getConditionValue | ( | $ | template, |
$ | value, | ||
$ | isVar = true |
||
) |
fetch the value of a condition variable
_fetchVariables() has to be called before this method is being called.
private
string | template name |
string | condition value |
boolean | flag that indicates whether value is the name of the variable that should be resolved |
get the value from the template variables
is __last?
is __default?
Références _fetchVariables().
Référencé par _fetchTemplate().
patTemplate::_getDependencies | ( | $ | template | ) |
get _all_ dependencies of a template, regardless of the subtemplates
private
string | template name |
Référencé par clearTemplate(), et freeTemplate().
patTemplate::_handleUnusedVars | ( | $ | template | ) |
handle all unused variables in a template
This is influenced by the 'unusedvars' attribute of the template
private
string |
Référencé par parseTemplate().
patTemplate::_hasVariables | ( | $ | template | ) |
check, whether a template contains variables
private
string | template name |
Référencé par _fetchTemplate().
patTemplate::_initTemplate | ( | $ | template | ) |
Initialize a template
This method checks the variable specifications and copys variables from other templates.
private
string | name of the template |
copy from the same template
copy from another template
Référencé par parseTemplate().
patTemplate::_loadTemplatesFromCache | ( | $ | input, |
&$ | reader, | ||
$ | options, | ||
$ | key | ||
) |
load from template cache
private
string | name of the input (filename, shm segment, etc.) |
string | driver that is used as reader, you may also pass a Reader object |
array | options for the reader |
string | cache key |
get modification time
Réimplémentée dans JTemplate.
Références loadModule().
Référencé par readTemplatesFromInput().
patTemplate::_parseDependencies | ( | $ | template | ) |
parse all dependencies in a template
private
string |
Références $i, parseTemplate(), et patErrorManager::raiseError().
Référencé par parseTemplate().
patTemplate::_parseGlobals | ( | $ | template | ) |
parse global variables in the template
private
string | name of the template |
Références _applyModifers().
Référencé par parseTemplate().
patTemplate::_parseVariables | ( | $ | template | ) |
parse all variables in a template
private
string |
modify variables before parsing
Références _applyModifers(), addVar(), et setAttribute().
Référencé par parseTemplate().
patTemplate::addGlobalVar | ( | $ | varname, |
$ | value | ||
) |
Adds a global variable
Global variables are valid in all templates of this object. A global variable has to be scalar, it will be converted to a string.
public
string | $varname | name of the global variable |
string | $value | value of the variable |
patTemplate::addGlobalVars | ( | $ | variables, |
$ | prefix = '' |
||
) |
Adds several global variables
Global variables are valid in all templates of this object.
$variables is an associative array, containing name/value pairs of the variables.
public
array | $variables | array containing the variables |
string | $prefix | prefix for variable names |
patTemplate::addModuleDir | ( | $ | moduleType, |
$ | dir | ||
) |
add a directory where patTemplate should search for modules.
You may either pass a string or an array of directories.
patTemplate will be searching for a module in the same order you added them. If the module cannot be found in the custom folders, it will look in patTemplate/$moduleType.
public
string | module type |
string|array | directory or directories to search. |
patTemplate::addObject | ( | $ | template, |
$ | object, | ||
$ | prefix = '' , |
||
$ | ignorePrivate = false |
||
) |
Adds an object to a template
All properties of the object will be available as template variables.
public
string | name of the template |
object|array | object or array of objects |
string | prefix for all variable names |
boolean | ignore private properties (starting with _) |
Références $rows, addRows(), addVars(), elseif, et getObjectVars().
patTemplate::addRows | ( | $ | template, |
$ | rows, | ||
$ | prefix = '' |
||
) |
Adds several rows of variables to a template
Each Template can have an unlimited amount of its own variables Can be used to add a database result as variables to a template
string | $template | name of the template |
array | $rows | array containing assotiative arrays with variable/value pairs |
string | $prefix | prefix for all variable names public |
Référencé par addObject().
patTemplate::addVar | ( | $ | template, |
$ | varname, | ||
$ | value | ||
) |
add a variable to a template
A variable may also be an indexed array, but _not_ an associative array!
public
string | $template | name of the template |
string | $varname | name of the variable |
mixed | $value | value of the variable |
Références $i.
Référencé par _parseVariables(), clearTemplate(), et readTemplatesFromInput().
patTemplate::addVars | ( | $ | template, |
$ | variables, | ||
$ | prefix = '' |
||
) |
Adds several variables to a template
Each Template can have an unlimited amount of its own variables $variables has to be an assotiative array containing variable/value pairs
string | $template | name of the template |
array | $variables | assotiative array of the variables |
string | $prefix | prefix for all variable names public |
Références $i.
Référencé par addObject().
patTemplate::applyInputFilter | ( | $ | filter, |
$ | params = array() |
||
) |
enable an input filter
input filters are used to modify the template stream before it is split into smaller templates-
public
string | name of the input filter |
array | parameters for the input filter |
Références $params, patErrorManager::isError(), et loadModule().
patTemplate::applyInputFilters | ( | $ | template | ) |
apply input filters that have been set
This is being called by the readers.
public
string | template |
Références $i.
patTemplate::applyOutputFilter | ( | $ | filter, |
$ | params = array() , |
||
$ | template = null |
||
) |
enable an output filter
Output filters are used to modify the template result before it is sent to the browser.
They are applied, when displayParsedTemplate() is called.
public
string | name of the output filter |
array | parameters for the output filter |
Références $params, exists(), patErrorManager::isError(), loadModule(), et patErrorManager::raiseWarning().
patTemplate::clearAllTemplates | ( | ) |
clears all templates
public clearTemplate()
Références $i, et clearTemplate().
patTemplate::clearAttribute | ( | $ | template, |
$ | attribute | ||
) |
Clears an attribute of a template
supported attributes: visibilty, loop, parse, unusedvars
string | $template | name of the template |
string | $attribute | name of the attribute public |
Références patErrorManager::raiseWarning().
patTemplate::clearGlobalVar | ( | $ | varname | ) |
Clears a global variable
public
string | $varname | name of the global variable |
patTemplate::clearGlobalVars | ( | ) |
Clears all global variables
public
patTemplate::clearTemplate | ( | $ | name, |
$ | recursive = false |
||
) |
clears a parsed Template
Parsed Content, variables and the loop attribute are cleared
If you will not be using this template anymore, then you should call freeTemplate()
public
string | name of the template |
boolean | set this to true to clear all child templates, too |
clear child templates as well
Références $name, _getDependencies(), et addVar().
Référencé par clearAllTemplates().
patTemplate::clearVar | ( | $ | template, |
$ | varname | ||
) |
clear the value of a variable
public
string | name of the template |
string | name of the variable |
Références $i.
patTemplate::clearVars | ( | $ | template | ) |
Clear all variables in a template
This clears only variables, but does
public
string | $template | name of the template |
patTemplate::displayParsedTemplate | ( | $ | name = null , |
$ | applyFilters = true |
||
) |
displays a parsed Template
If the template has not been loaded, it will be loaded.
string | name of the template |
boolean | whether to apply output filters |
error happened
Références $name, getParsedTemplate(), et patErrorManager::isError().
patTemplate::dump | ( | $ | restrict = null , |
$ | dumper = 'Html' |
||
) |
Displays useful information about all or named templates
This method breaks BC, as it now awaits an array instead of unlimited parameters.
mixed | array of templates that should be dumped, or null if you want all templates to be dumped |
string | dumper public |
Références $name, patErrorManager::isError(), et loadModule().
patTemplate::exists | ( | $ | name | ) |
checks wether a template exists
public
string | name of the template |
Références $name.
Référencé par _fetchVariables(), applyOutputFilter(), et placeholderExists().
patTemplate::freeAllTemplates | ( | ) |
frees all templates
All memory consumed by the templates will be freed.
public
patTemplate::freeTemplate | ( | $ | name, |
$ | recursive = false |
||
) |
frees a template
All memory consumed by the template will be freed.
public
string | name of the template |
boolean | clear dependencies of the template |
free child templates as well
Références $name, _getDependencies(), et patErrorManager::raiseWarning().
patTemplate::getAttribute | ( | $ | template, |
$ | attribute | ||
) |
Gets an attribute of a template
supported attributes: visibilty, loop, parse, unusedvars
string | $template | name of the template |
string | $attribute | name of the attribute |
Références patErrorManager::raiseWarning().
patTemplate::getAttributes | ( | $ | template | ) |
Get all attributes of a template
string | name of the template |
Références patErrorManager::raiseWarning().
Référencé par readTemplatesFromInput().
patTemplate::getDefaultAttributes | ( | ) |
get default attributes
public
patTemplate::getEndTag | ( | ) |
get end tag for variables
public
patTemplate::getGlobalVars | ( | ) |
get all global variables
public
patTemplate::getIncludePath | ( | ) |
get the include path
public
Référencé par loadModule(), et moduleExists().
patTemplate::getNamespace | ( | ) |
patTemplate::getObjectVars | ( | $ | obj, |
$ | ignorePrivate = false |
||
) |
get the vars from an object
private
object | |
boolean | ignore private properties (starting with _) |
Référencé par addObject().
patTemplate::getOption | ( | $ | option | ) |
gets an option
public
string | option to get |
Références $option.
patTemplate::getParsedTemplate | ( | $ | name = null , |
$ | applyFilters = false |
||
) |
returns a parsed Template
If the template already has been parsed, it just returns the parsed template. If the template has not been loaded, it will be loaded.
public
string | name of the template |
boolean | whether to apply output filters |
Références $i, $name, patErrorManager::isError(), et parseTemplate().
Référencé par __toString(), et displayParsedTemplate().
patTemplate::getRoot | ( | $ | reader = '__default' | ) |
gets name of root base for the templates
public
patTemplate::getStartTag | ( | ) |
get start tag for variables
public
patTemplate::getVar | ( | $ | template, |
$ | varname | ||
) |
get the value of a variable
public
string | name of the template |
string | name of the variable |
Références $i.
Référencé par readTemplatesFromInput().
& patTemplate::loadModule | ( | $ | moduleType, |
$ | moduleName, | ||
$ | params = array() , |
||
$ | new = false |
||
) |
loads a patTemplate module
Modules are located in the patTemplate folder and include:
public
string | moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter) |
string | moduleName |
array | parameters for the module |
Références $file, $params, getIncludePath(), et patErrorManager::raiseError().
Référencé par _applyModifers(), _loadTemplatesFromCache(), applyInputFilter(), applyOutputFilter(), dump(), loadTemplateFromInput(), parseTemplate(), readTemplatesFromInput(), et useTemplateCache().
patTemplate::loadTemplate | ( | $ | template | ) |
load a template that had autoload="off"
This is needed, if you change the source of a template and want to load it, after changing the attribute.
public
string | template name |
Références loadTemplateFromInput(), patErrorManager::raiseWarning(), et readTemplatesFromInput().
patTemplate::loadTemplateFromInput | ( | $ | input, |
$ | reader = 'File' , |
||
$ | options = null , |
||
$ | parseInto = false |
||
) |
open any input and load content into template
public
string | name of the input (filename, shm segment, etc.) |
string | driver that is used as reader |
string | name of the template that should be used as a container, |
Références patErrorManager::isError(), et loadModule().
Référencé par loadTemplate(), parseTemplate(), et readTemplatesFromInput().
patTemplate::moduleExists | ( | $ | moduleType, |
$ | moduleName | ||
) |
checks whether a module exists.
Modules are located in the patTemplate folder and include:
public
string | moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter) |
string | moduleName |
Références getIncludePath().
patTemplate::parseIntoVar | ( | $ | srcTmpl, |
$ | destTmpl, | ||
$ | var, | ||
$ | append = false |
||
) |
parse a template and push the result into a variable of any other template
If the template already has been parsed, it will just be pushed into the variable. If the template has not been loaded, it will be loaded.
public
string | name of the template |
boolean | if set to true, the value will be appended to the value already stored. |
Références patErrorManager::isError(), et parseTemplate().
patTemplate::parseTemplate | ( | $ | template, |
$ | mode = 'w' |
||
) |
parses a template
Parses a template and stores the parsed content. mode can be "w" for write (delete already parsed content) or "a" for append (appends the new parsed content to the already parsed content)
public
string | name of the template |
string | mode for the parsing |
template is not visible
check, if the template has been loaded and load it if necessary.
check for autoclear
template has been parsed and mode is not 'append'
loop at least one times
template should be cleared before parsing
fetch the variables
fetch the template
parse
store result
check for maximum loops
Références $i, $start, _fetchTemplate(), _fetchVariables(), _handleUnusedVars(), _initTemplate(), _parseDependencies(), _parseGlobals(), _parseVariables(), patErrorManager::isError(), loadModule(), loadTemplateFromInput(), patErrorManager::raiseWarning(), et readTemplatesFromInput().
Référencé par _parseDependencies(), getParsedTemplate(), et parseIntoVar().
patTemplate::patTemplate | ( | $ | type = 'html' | ) |
Create a new patTemplate instance.
The constructor accepts the type of the templates as sole parameter. You may choose one of:
The type influences the tags you are using in your templates.
public
string | type (either html or tex) |
Références $type, et setType().
Référencé par patTemplate_Compiler::patTemplate_Compiler().
patTemplate::placeholderExists | ( | $ | placeholder, |
$ | tmpl, | ||
$ | cached = true |
||
) |
patTemplate::prepareTemplate | ( | $ | name | ) |
Prepare a template
This can be used if you want to add variables to a template, that has not been loaded yet.
public
string | template name |
Références $name.
Référencé par readTemplatesFromInput().
patTemplate::readTemplatesFromFile | ( | $ | filename | ) |
open a file and parse for patTemplate tags
public
name | of the file |
Références $filename, et readTemplatesFromInput().
patTemplate::readTemplatesFromInput | ( | $ | input, |
$ | reader = 'File' , |
||
$ | options = null , |
||
$ | parseInto = null |
||
) |
open any input and parse for patTemplate tags
public
string | name of the input (filename, shm segment, etc.) |
string | driver that is used as reader, you may also pass a Reader object |
array | additional options that will only be used for this template |
string | name of the template that should be used as a container, should not be used by public calls. |
get the unique cache key
check for error returned from cache
templates have not been loaded from cache
set the root attributes
check for error returned from reader
store the
traverse all templates
root template
store the name
if this is the first template that has been loaded set it as the root template
set some default values
store the template
store the default values of the variables
autoload the template
Some error management is needed here...
Références $name, _loadTemplatesFromCache(), addVar(), getAttributes(), getVar(), patErrorManager::isError(), loadModule(), loadTemplateFromInput(), prepareTemplate(), et patErrorManager::raiseError().
Référencé par loadTemplate(), parseTemplate(), et readTemplatesFromFile().
patTemplate::setAttribute | ( | $ | template, |
$ | attribute, | ||
$ | value | ||
) |
Sets an attribute of a template
supported attributes: visibilty, loop, parse, unusedvars
string | $template | name of the template |
string | $attribute | name of the attribute |
mixed | $value | value of the attribute public |
Références patErrorManager::raiseWarning().
Référencé par _parseVariables().
patTemplate::setAttributes | ( | $ | template, |
$ | attributes | ||
) |
Sets several attribute of a template
$attributes has to be a assotiative arrays containing attribute/value pairs supported attributes: visibilty, loop, parse, unusedvars
string | $template | name of the template |
array | $attributes | attribute/value pairs public |
Références patErrorManager::raiseError(), et patErrorManager::raiseWarning().
patTemplate::setBasedir | ( | $ | basedir | ) |
sets name of directory where templates are stored
public
string | dir where templates are stored |
Références setRoot().
patTemplate::setDefaultAttribute | ( | $ | name, |
$ | value | ||
) |
set default attribute
public
string | attribute name |
mixed | attribute value |
Références $name.
patTemplate::setDefaultAttributes | ( | $ | attributes | ) |
set default attributes
public
array | attributes |
patTemplate::setNamespace | ( | $ | ns | ) |
sets namespace of patTemplate tags
If you want to use more than one namespace, you may set this to an array. All tags in these namespaces will be treated as patTemplate tags.
public
string|array | namespace(s) |
patTemplate::setOption | ( | $ | option, |
$ | value | ||
) |
sets an option
Currently, the following options are supported
public
string | option to set |
string | value of the option |
Références $option.
patTemplate::setRoot | ( | $ | root, |
$ | reader = '__default' |
||
) |
sets root base for the template
The parameter depends on the reader you are using.
public
string | root base of the templates |
Référencé par setBasedir().
patTemplate::setTags | ( | $ | startTag, |
$ | endTag | ||
) |
set the start and end tag for variables
public
string | start tag |
string | end tag |
Référencé par setType().
patTemplate::setType | ( | $ | type | ) |
set the type for the templates
public
string | type (html or tex) |
Références $type, patErrorManager::raiseWarning(), et setTags().
Référencé par patTemplate().
patTemplate::useTemplateCache | ( | $ | cache, |
$ | params = array() |
||
) |
enable a template cache
A template cache will improve performace, as the templates do not have to be read on each request.
public
string | name of the template cache |
array | parameters for the template cache |
Références $params, patErrorManager::isError(), et loadModule().
patTemplate::$_defaultAttributes |
array( 'type' => 'standard', 'visibility' => 'visible', 'loop' => 1, 'unusedvars' => 'strip', 'whitespace' => 'keep', 'autoclear' => 'off', 'autoload' => 'on' )
patTemplate::$_discoveredPlaceholders = array() |
patTemplate::$_endTag = '}' |
patTemplate::$_globals = array() |
patTemplate::$_inputFilters = array() |
patTemplate::$_moduleDirs = array() |
patTemplate::$_modules = array() |
patTemplate::$_options |
array( 'startTag' => '{', 'endTag' => '}', 'root' => array('__default' => '.'), 'namespace' => 'patTemplate', 'maintainBc' => true, 'defaultFunction' => false )
patTemplate::$_outputFilters = array() |
patTemplate::$_root |
patTemplate::$_startTag = '{' |
patTemplate::$_systemVars |
array( 'appName' => 'patTemplate', 'appVersion' => '3.1.0', 'author' => array( 'Stephan Schmidt <schst@php.net>' ) )
patTemplate::$_templateList = array() |
patTemplate::$_templates = array() |
patTemplate::$_tmplCache = null |
patTemplate::$_vars = array() |