PHP Класс Prado\Web\UI\TTemplate

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 where AttributeName can be a property name, an event name or a regular tag attribute name. - group subproperty tags: subproperties of a common property can be configured using - directive: directive specifies the property values for the template owner. It is in the format of <%@ property name-value pairs %>; - expressions: They are in the format of <%= PHP expression %> and <%% PHP statements %> - comments: There are two kinds of comments, regular HTML comments and special template comments. The former is in the format of , which will be treated as text strings. The latter is in the format of , 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.
С версии: 3.0
Автор: Qiang Xue ([email protected])
Наследование: extends Prado\TApplicationComponent, implements Prado\Web\UI\ITemplate
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( $template, $contextPath, $tplFile = null, $startingLine, $sourceTemplate = true ) Constructor.
getContextPath ( ) : string
getDirective ( ) : array
getHashCode ( ) : string
getIncludedFiles ( ) : array
getIsSourceTemplate ( ) : boolean
getItems ( ) : array
getTemplateFile ( ) : string
instantiateIn ( $tplControl, $parentControl = null ) Instantiates the template.

Защищенные методы

Метод Описание
configureComponent ( $component, $name, $value ) Configures a property of a non-control component.
configureControl ( $control, $name, $value ) Configures a property/event of a control.
configureEvent ( $control, $name, $value, $contextControl ) Configures an event for a control.
configureProperty ( $component, $name, $value ) Configures a simple property for a component.
configureSubProperty ( $component, $name, $value ) Configures a subproperty for a component.
handleException ( $e, $line, $input = null ) Handles template parsing exception.
isClassBehaviorMethod ( ReflectionClass $class, string $method ) : boolean Checks if the given method belongs to a previously attached class behavior.
parse ( $input ) Parses a template string.
parseAttribute ( $value ) : array Parses a single attribute.
parseAttributes ( $str, $offset ) : array Parses the attributes of a tag from a string.
parseTemplateProperty ( $content, $offset )
preprocess ( $input ) : string Preprocesses the template string by including external templates
validateAttributes ( $type, $attributes )

Описание методов

__construct() публичный Метод

The template will be parsed after construction.
public __construct ( $template, $contextPath, $tplFile = null, $startingLine, $sourceTemplate = true )

configureComponent() защищенный Метод

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

configureControl() защищенный Метод

Configures a property/event of a control.
protected configureControl ( $control, $name, $value )

configureEvent() защищенный Метод

Configures an event for a control.
protected configureEvent ( $control, $name, $value, $contextControl )

configureProperty() защищенный Метод

Configures a simple property for a component.
protected configureProperty ( $component, $name, $value )

configureSubProperty() защищенный Метод

Configures a subproperty for a component.
protected configureSubProperty ( $component, $name, $value )

getContextPath() публичный Метод

public getContextPath ( ) : string
Результат string context directory path

getDirective() публичный Метод

public getDirective ( ) : array
Результат array name-value pairs declared in the directive

getHashCode() публичный Метод

public getHashCode ( ) : string
Результат string hash code that can be used to identify the template

getIncludedFiles() публичный Метод

public getIncludedFiles ( ) : array
Результат array list of included external template files

getIsSourceTemplate() публичный Метод

public getIsSourceTemplate ( ) : boolean
Результат boolean whether this template is a source template, i.e., this template is loaded from some external storage rather than from within another template.

getItems() публичный Метод

public getItems ( ) : array
Результат array the parsed template

getTemplateFile() публичный Метод

public getTemplateFile ( ) : string
Результат string template file path if available, null otherwise.

handleException() защищенный Метод

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

instantiateIn() публичный Метод

Content in the template will be instantiated as components and text strings and passed to the specified parent control.
public instantiateIn ( $tplControl, $parentControl = null )

isClassBehaviorMethod() защищенный Метод

Checks if the given method belongs to a previously attached class behavior.
protected isClassBehaviorMethod ( ReflectionClass $class, string $method ) : boolean
$class ReflectionClass
$method string
Результат boolean

parse() защищенный Метод

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.
protected parse ( $input )

parseAttribute() защищенный Метод

Parses a single attribute.
protected parseAttribute ( $value ) : array
Результат array attribute initialization

parseAttributes() защищенный Метод

Parses the attributes of a tag from a string.
protected parseAttributes ( $str, $offset ) : array
Результат array attribute values indexed by names.

parseTemplateProperty() защищенный Метод

protected parseTemplateProperty ( $content, $offset )

preprocess() защищенный Метод

Preprocesses the template string by including external templates
protected preprocess ( $input ) : string
Результат string expanded template string

validateAttributes() защищенный Метод

protected validateAttributes ( $type, $attributes )