[ Index ] |
|
Code source de Joomla 1.0.13 |
[Code source] [Imprimer] [Statistiques]
patTemplate $Id: patTemplate.php 1546 2005-12-23 07:01:01Z eddieajau $
Author: | Stephan Schmidt <schst@php.net> |
License: | LGPL |
Version: | 3.1.0 |
Poids: | 2705 lignes (70 kb) |
Inclus ou requis: | 0 fois |
Référencé: | 0 fois |
Nécessite: | 0 fichiers |
patTemplate:: (70 méthodes):
patTemplate()
setOption()
getOption()
setBasedir()
setRoot()
getRoot()
setNamespace()
getNamespace()
setDefaultAttribute()
setDefaultAttributes()
getDefaultAttributes()
setType()
setTags()
getStartTag()
getEndTag()
addModuleDir()
setAttribute()
setAttributes()
getAttributes()
getAttribute()
clearAttribute()
prepareTemplate()
addVar()
getVar()
clearVar()
addVars()
clearVars()
addRows()
addObject()
getObjectVars()
addGlobalVar()
clearGlobalVar()
clearGlobalVars()
addGlobalVars()
getGlobalVars()
exists()
useTemplateCache()
applyOutputFilter()
applyInputFilter()
readTemplatesFromFile()
readTemplatesFromInput()
_loadTemplatesFromCache()
loadTemplateFromInput()
loadTemplate()
loadModule()
moduleExists()
parseTemplate()
_initTemplate()
_parseVariables()
_parseGlobals()
_applyModifers()
_parseDependencies()
_fetchTemplate()
_hasVariables()
_getConditionValue()
_fetchVariables()
_handleUnusedVars()
getParsedTemplate()
displayParsedTemplate()
parseIntoVar()
clearTemplate()
clearAllTemplates()
freeTemplate()
freeAllTemplates()
_getDependencies()
dump()
getIncludePath()
applyInputFilters()
placeholderExists()
__toString()
patFactory:: (1 méthode):
createTemplate()
Classe: patTemplate - X-Ref
patTemplatepatTemplate( $type = 'html' ) X-Ref |
Create a new patTemplate instance. The constructor accepts the type of the templates as sole parameter. You may choose one of: - html (default) - tex The type influences the tags you are using in your templates. param: string type (either html or tex) |
setOption($option, $value) X-Ref |
sets an option Currently, the following options are supported - maintainBc (true|false) - namespace (string) param: string option to set param: string value of the option |
getOption( $option ) X-Ref |
gets an option param: string option to get return: mixed value of the option |
setBasedir($basedir) X-Ref |
sets name of directory where templates are stored param: string dir where templates are stored |
setRoot($root, $reader = '__default') X-Ref |
sets root base for the template The parameter depends on the reader you are using. param: string root base of the templates |
getRoot($reader = '__default') X-Ref |
gets name of root base for the templates return: mixed root base |
setNamespace($ns) X-Ref |
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. param: string|array namespace(s) |
getNamespace() X-Ref |
gets namespace of patTemplate tags return: string|array namespace(s) |
setDefaultAttribute( $name, $value ) X-Ref |
set default attribute param: string attribute name param: mixed attribute value |
setDefaultAttributes( $attributes ) X-Ref |
set default attributes param: array attributes |
getDefaultAttributes() X-Ref |
get default attributes return: return default attributes |
setType( $type ) X-Ref |
set the type for the templates param: string type (html or tex) return: boolean true on success |
setTags( $startTag, $endTag ) X-Ref |
set the start and end tag for variables param: string start tag param: string end tag return: boolean true on success |
getStartTag() X-Ref |
get start tag for variables return: string start tag |
getEndTag() X-Ref |
get end tag for variables return: string end tag |
addModuleDir( $moduleType, $dir ) X-Ref |
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. param: string module type param: string|array directory or directories to search. |
setAttribute( $template, $attribute, $value ) X-Ref |
Sets an attribute of a template supported attributes: visibilty, loop, parse, unusedvars param: string $template name of the template param: string $attribute name of the attribute param: mixed $value value of the attribute |
setAttributes( $template, $attributes ) X-Ref |
Sets several attribute of a template $attributes has to be a assotiative arrays containing attribute/value pairs supported attributes: visibilty, loop, parse, unusedvars param: string $template name of the template param: array $attributes attribute/value pairs |
getAttributes( $template ) X-Ref |
Get all attributes of a template param: string name of the template return: array attributes |
getAttribute( $template, $attribute ) X-Ref |
Gets an attribute of a template supported attributes: visibilty, loop, parse, unusedvars param: string $template name of the template param: string $attribute name of the attribute return: mixed value of the attribute |
clearAttribute( $template, $attribute ) X-Ref |
Clears an attribute of a template supported attributes: visibilty, loop, parse, unusedvars param: string $template name of the template param: string $attribute name of the attribute |
prepareTemplate( $name ) X-Ref |
Prepare a template This can be used if you want to add variables to a template, that has not been loaded yet. param: string template name |
addVar( $template, $varname, $value ) X-Ref |
add a variable to a template A variable may also be an indexed array, but _not_ an associative array! param: string $template name of the template param: string $varname name of the variable param: mixed $value value of the variable |
getVar( $template, $varname ) X-Ref |
get the value of a variable param: string name of the template param: string name of the variable return: string value of the variable, null if the variable is not set |
clearVar( $template, $varname ) X-Ref |
clear the value of a variable param: string name of the template param: string name of the variable return: boolean |
addVars( $template, $variables, $prefix = '' ) X-Ref |
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 param: string $template name of the template param: array $variables assotiative array of the variables param: string $prefix prefix for all variable names |
clearVars( $template ) X-Ref |
Clear all variables in a template This clears only variables, but does param: string $template name of the template return: boolean |
addRows( $template, $rows, $prefix = '' ) X-Ref |
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 param: string $template name of the template param: array $rows array containing assotiative arrays with variable/value pairs param: string $prefix prefix for all variable names |
addObject( $template, $object, $prefix = '', $ignorePrivate = false ) X-Ref |
Adds an object to a template All properties of the object will be available as template variables. param: string name of the template param: object|array object or array of objects param: string prefix for all variable names param: boolean ignore private properties (starting with _) |
getObjectVars($obj, $ignorePrivate = false) X-Ref |
get the vars from an object param: object param: boolean ignore private properties (starting with _) return: array |
addGlobalVar( $varname, $value ) X-Ref |
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. param: string $varname name of the global variable param: string $value value of the variable return: boolean true on success |
clearGlobalVar( $varname ) X-Ref |
Clears a global variable param: string $varname name of the global variable return: boolean true on success |
clearGlobalVars() X-Ref |
Clears all global variables return: boolean true on success |
addGlobalVars( $variables, $prefix = '' ) X-Ref |
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. param: array $variables array containing the variables param: string $prefix prefix for variable names return: boolean true on success |
getGlobalVars() X-Ref |
get all global variables return: array global variables |
exists( $name ) X-Ref |
checks wether a template exists param: string name of the template return: boolean true, if the template exists, false otherwise |
useTemplateCache( $cache, $params = array() X-Ref |
enable a template cache A template cache will improve performace, as the templates do not have to be read on each request. param: string name of the template cache param: array parameters for the template cache return: boolean true on success, patError otherwise |
applyOutputFilter( $filter, $params = array() X-Ref |
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. param: string name of the output filter param: array parameters for the output filter return: boolean true on success, patError otherwise |
applyInputFilter( $filter, $params = array() X-Ref |
enable an input filter input filters are used to modify the template stream before it is split into smaller templates- param: string name of the input filter param: array parameters for the input filter return: boolean true on success, patError otherwise |
readTemplatesFromFile( $filename ) X-Ref |
open a file and parse for patTemplate tags param: name of the file return: true, if the template could be parsed |
readTemplatesFromInput( $input, $reader = 'File', $options = null, $parseInto = null ) X-Ref |
open any input and parse for patTemplate tags param: string name of the input (filename, shm segment, etc.) param: string driver that is used as reader, you may also pass a Reader object param: array additional options that will only be used for this template param: string name of the template that should be used as a container, should not be used by public return: boolean true, if the template could be parsed, false otherwise |
_loadTemplatesFromCache( $input, &$reader, $options, $key ) X-Ref |
load from template cache param: string name of the input (filename, shm segment, etc.) param: string driver that is used as reader, you may also pass a Reader object param: array options for the reader param: string cache key return: array|boolean either an array containing the templates, or false |
loadTemplateFromInput( $input, $reader = 'File', $options = null, $parseInto = false ) X-Ref |
open any input and load content into template param: string name of the input (filename, shm segment, etc.) param: string driver that is used as reader param: string name of the template that should be used as a container, return: boolean true, if the template could be parsed, false otherwise |
loadTemplate( $template ) X-Ref |
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. param: string template name return: boolean true, if template could be loaded |
loadModule( $moduleType, $moduleName, $params = array() X-Ref |
loads a patTemplate module Modules are located in the patTemplate folder and include: - Readers - Caches - Variable Modifiers - Filters - Functions - Stats param: string moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter) param: string moduleName param: array parameters for the module return: object |
moduleExists( $moduleType, $moduleName ) X-Ref |
checks whether a module exists. Modules are located in the patTemplate folder and include: - Readers - Caches - Variable Modifiers - Filters - Functions - Stats param: string moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter) param: string moduleName return: boolean |
parseTemplate( $template, $mode = 'w' ) X-Ref |
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) param: string name of the template param: string mode for the parsing |
_initTemplate( $template ) X-Ref |
Initialize a template This method checks the variable specifications and copys variables from other templates. param: string name of the template return: boolean true on success |
_parseVariables( $template ) X-Ref |
parse all variables in a template param: string |
_parseGlobals($template) X-Ref |
parse global variables in the template param: string name of the template return: boolean |
_applyModifers($template, &$vars) X-Ref |
apply variable modifiers The variables will be passed by reference. param: string name of the template (use modifiers from this template) param: array variables to which the modifiers should be applied return: boolean |
_parseDependencies($template) X-Ref |
parse all dependencies in a template param: string |
_fetchTemplate( $template ) X-Ref |
fetch plain template The template content will be stored in the template configuration so it can be used by other methods. param: string template name return: boolean |
_hasVariables($template) X-Ref |
check, whether a template contains variables param: string template name return: boolean |
_getConditionValue( $template, $value, $isVar = true ) X-Ref |
fetch the value of a condition variable _fetchVariables() has to be called before this method is being called. param: string template name param: string condition value param: boolean flag that indicates whether value is the name of the variable that should be resolved |
_fetchVariables( $template ) X-Ref |
fetch variables for a template The variables will be stored in the template configuration so they can be used by other methods. param: string template name return: boolean |
_handleUnusedVars( $template ) X-Ref |
handle all unused variables in a template This is influenced by the 'unusedvars' attribute of the template param: string |
getParsedTemplate( $name = null, $applyFilters = false ) X-Ref |
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. param: string name of the template param: boolean whether to apply output filters return: string Content of the parsed template |
displayParsedTemplate($name = null, $applyFilters = true) X-Ref |
displays a parsed Template If the template has not been loaded, it will be loaded. param: string name of the template param: boolean whether to apply output filters return: boolean true on success |
parseIntoVar( $srcTmpl, $destTmpl, $var, $append = false ) X-Ref |
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. param: string name of the template param: boolean if set to true, the value will be appended to the value already stored. return: string Content of the parsed template |
clearTemplate( $name, $recursive = false ) X-Ref |
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() param: string name of the template param: boolean set this to true to clear all child templates, too |
clearAllTemplates() X-Ref |
clears all templates |
freeTemplate( $name, $recursive = false ) X-Ref |
frees a template All memory consumed by the template will be freed. param: string name of the template param: boolean clear dependencies of the template |
freeAllTemplates() X-Ref |
frees all templates All memory consumed by the templates will be freed. |
_getDependencies( $template ) X-Ref |
get _all_ dependencies of a template, regardless of the subtemplates param: string template name return: array list of all subtemplates |
dump( $restrict = null, $dumper = 'Html' ) X-Ref |
Displays useful information about all or named templates This method breaks BC, as it now awaits an array instead of unlimited parameters. param: mixed array of templates that should be dumped, or null if you param: string dumper |
getIncludePath() X-Ref |
get the include path return: string |
applyInputFilters( $template ) X-Ref |
apply input filters that have been set This is being called by the readers. param: string template return: string filtered templeta |
placeholderExists($placeholder, $tmpl, $cached = true) X-Ref |
checks, whether a placeholder exists in a template param: string name of the placeholder param: string name of the template param: boolean whether to use the cached result of a previous call |
__toString() X-Ref |
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 <code> $tmpl = new patTemplate(); $tmpl->readTemplatesFromFile( 'myfile.tmpl' ); echo $tmpl; </code> return: string |
Classe: patFactory - X-Ref
createTemplate( $files=null ) X-Ref |
param: array An array of additional files to include from the root folder return: object |
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |