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
파일 보기 프로젝트 열기: pradosoft/prado 1 사용 예제들

공개 메소드들

메소드 설명
__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 )