[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Web/UI/ -> TTemplateManager.php (sommaire)

TTemplateManager and TTemplate class file

Author: Qiang Xue <qiang.xue@gmail.com>
Copyright: Copyright © 2005 PradoSoft
License: http://www.pradosoft.com/license/
Version: $Id: TTemplateManager.php 1536 2006-12-01 19:51:21Z xue $
Poids: 1000 lignes (34 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 2 classes

TTemplateManager:: (4 méthodes):
  init()
  getTemplateByClassName()
  getTemplateByFileName()
  getLocalizedTemplate()

TTemplate:: (19 méthodes):
  __construct()
  getIsSourceTemplate()
  getContextPath()
  getDirective()
  getItems()
  instantiateIn()
  configureControl()
  configureComponent()
  configureEvent()
  configureProperty()
  configureSubProperty()
  parse()
  parseAttributes()
  parseTemplateProperty()
  parseAttribute()
  validateAttributes()
  getIncludedFiles()
  handleException()
  preprocess()


Classe: TTemplateManager  - X-Ref

TTemplateManager class

TTemplateManager manages the loading and parsing of control templates.

There are two ways of loading a template, either by the associated template
control class name, or the template file name.
The former is via calling {@link getTemplateByClassName}, which tries to
locate the corresponding template file under the directory containing
the class file. The name of the template file is the class name with
the extension '.tpl'. To load a template from a template file path,
call {@link getTemplateByFileName}.

By default, TTemplateManager is registered with {@link TPageService} as the
template manager module that can be accessed via {@link TPageService::getTemplateManager()}.

init($config)   X-Ref
Initializes the module.
This method is required by IModule and is invoked by application.
It starts output buffer if it is enabled.

param: TXmlElement module configuration

getTemplateByClassName($className)   X-Ref
Loads the template corresponding to the specified class name.

return: ITemplate template for the class name, null if template doesn't exist.

getTemplateByFileName($fileName)   X-Ref
Loads the template from the specified file.

return: ITemplate template parsed from the specified file, null if the file doesn't exist.

getLocalizedTemplate($filename)   X-Ref
Finds a localized template file.

param: string template file.
return: string|null a localized template file if found, null otherwise.

Classe: TTemplate  - X-Ref

TTemplate implements PRADO template parsing logic.
A TTemplate object represents a parsed PRADO control template.
It can instantiate the template as child controls of a specified control.
The template format is like HTML, with the following special tags introduced,
- component tags: a component tag represents the configuration of a component.
The tag name is in the format of com:ComponentType, where ComponentType is the component
class name. Component tags must be well-formed. Attributes of the component tag
are treated as either property initial values, event handler attachment, or regular
tag attributes.
- property tags: property tags are used to set large block of attribute values.
The property tag name is in the format of prop:AttributeName, where AttributeName
can be a property name, an event name or a regular tag attribute name.
- directive: directive specifies the property values for the template owner.
It is in the format of &lt;% property name-value pairs %&gt;
- expressions: They are in the formate of &lt;= PHP expression &gt; and &lt;% PHP statements &gt;
- comments: There are two kinds of comments, regular HTML comments and special template comments.
The former is in the format of &lt;!-- comments --&gt;, which will be treated as text strings.
The latter is in the format of &lt;%* comments %&gt;, which will be stripped out.

Tags other than the above are not required to be well-formed.

A TTemplate object represents a parsed PRADO template. To instantiate the template
for a particular control, call {@link instantiateIn($control)}, which
will create and intialize all components specified in the template and
set their parent as $control.

__construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true)   X-Ref
Constructor.
The template will be parsed after construction.

param: string the template string
param: string the template context directory
param: string the template file, null if no file
param: integer the line number that parsing starts from (internal use)
param: boolean whether this template is a source template, i.e., this template is loaded from

getIsSourceTemplate()   X-Ref

return: boolean whether this template is a source template, i.e., this template is loaded from

getContextPath()   X-Ref

return: string context directory path

getDirective()   X-Ref

return: array name-value pairs declared in the directive

getItems()   X-Ref

return: array the parsed template

instantiateIn($tplControl)   X-Ref
Instantiates the template.
Content in the template will be instantiated as components and text strings
and passed to the specified parent control.

param: TControl the parent control

configureControl($control,$name,$value)   X-Ref
Configures a property/event of a control.

param: TControl control to be configured
param: string property name
param: mixed property initial value

configureComponent($component,$name,$value)   X-Ref
Configures a property of a non-control component.

param: TComponent component to be configured
param: string property name
param: mixed property initial value

configureEvent($control,$name,$value,$contextControl)   X-Ref
Configures an event for a control.

param: TControl control to be configured
param: string event name
param: string event handler
param: TControl context control

configureProperty($component,$name,$value)   X-Ref
Configures a simple property for a component.

param: TComponent component to be configured
param: string property name
param: mixed property initial value

configureSubProperty($component,$name,$value)   X-Ref
Configures a subproperty for a component.

param: TComponent component to be configured
param: string subproperty name
param: mixed subproperty initial value

parse($input)   X-Ref
Parses a template string.

This template parser recognizes five types of data:
regular string, well-formed component tags, well-formed property tags, directives, and expressions.

The parsing result is returned as an array. Each array element can be of three types:
- a string, 0: container index; 1: string content;
- a component tag, 0: container index; 1: component type; 2: attributes (name=>value pairs)
If a directive is found in the template, it will be parsed and can be
retrieved via {@link getDirective}, which returns an array consisting of
name-value pairs in the directive.

Note, attribute names are treated as case-insensitive and will be turned into lower cases.
Component and directive types are case-sensitive.
Container index is the index to the array element that stores the container object.
If an object has no container, its container index is -1.

param: string the template string

parseAttributes($str,$offset)   X-Ref
Parses the attributes of a tag from a string.

param: string the string to be parsed.
return: array attribute values indexed by names.

parseTemplateProperty($content,$offset)   X-Ref
Pas de description

parseAttribute($value)   X-Ref
Parses a single attribute.

param: string the string to be parsed.
return: array attribute initialization

validateAttributes($type,$attributes)   X-Ref
Pas de description

getIncludedFiles()   X-Ref

return: array list of included external template files

handleException($e,$line,$input=null)   X-Ref
Handles template parsing exception.
This method rethrows the exception caught during template parsing.
It adjusts the error location by giving out correct error line number and source file.

param: Exception template exception
param: int line number
param: string template string if no source file is used

preprocess($input)   X-Ref
Preprocesses the template string by including external templates

param: string template string
return: string expanded template string



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7