PHP Класс GiTemplate, atk4

- completely remove any code from templates - speed up template parsing and manipulation speed
Автор: Romans ([email protected])
Наследование: extends AbstractModel, implements ArrayAccess
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$default_exception string
$origin_filename Which file template is loaded from.
$settings array Settings are populated from the configuration file, if found.
$tags array This array contains list of all tags found inside template implementing faster access when manipulating the template.
$template array This is a parsed contents of the template organized inside an array. This structure makes it very simple to modify any part of the array.
$template_file
$template_source
$template_type
$top_tags

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

Метод Описание
__clone ( )
_getDumpTags ( &$template )
append ( $tag, $value, $encode = true ) Add more content inside a tag.
appendHTML ( $tag, $value )
cloneRegion ( $tag )
del ( $tag ) Empty contents of specified region. If region contains sub-hierarchy, it will be also removed.
dumpTags ( )
eachTag ( $tag, $callable )
exception ( string $message = 'Undefined Exception', string $type = null, string $code = null ) : Exception_Template Returns relevant exception class. Use this method with "throw".
findTemplate ( $template_name ) template loading and parsing
get ( $tag ) Get value of the tag. Note that this may contain an array if tag contains a structure.
getDefaultSettings ( ) This function specifies default settings for SMlite.
getTagRef ( $tag, &$template ) This is a helper method which populates an array pointing to the place in the template referenced by a said tag.
getTagRefList ( $tag, &$template ) For methods which execute action on several tags, this method will return array of templates. You can then iterate through the array and update all the template values.
hasTag ( $tag ) Checks if template has defined a specified tag.
init ( ) Template creation, interface functions
isTopTag ( string $tag ) : boolean Returns true if specified tag is a top-tag of the template.
is_set ( $tag ) Obsolete due to inconsistent naming.
loadTemplate ( $template_name, $ext = null )
loadTemplateFromString ( string $str ) Initialize current template from the supplied string.
offsetExists ( $name ) {{{ ArrayAccess support
offsetGet ( $name )
offsetSet ( $name, $val )
offsetUnset ( $name )
parseTemplate ( $str )
parseTemplateRecursive ( &$input, &$template )
rebuildTags ( )
rebuildTagsRegion ( &$template )
recursiveRender ( &$template )
regTag ( $tag )
reload ( ) Causes the template to be refreshed from it's original source
render ( $region = null )
renderRegion ( &$chunk )
set ( $tag, $value = null, $encode = true ) This function will replace region refered by $tag to a new content.
setHTML ( $tag, $value = null )
tryDel ( $tag ) Similar to del() but won't throw exception if tag is not present.
trySet ( $tag, $value = null, $encode = true ) Check if tag is present inside template. If it does, execute set(); See documentation for set().
trySetHTML ( $tag, $value = null ) Attempt to set value of a tag to a HTML variable. The value is inserted as-is, while regular set() would HTML-encode the values to avoid injection.

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

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

public __clone ( )

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

public _getDumpTags ( &$template )

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

Add more content inside a tag.
public append ( $tag, $value, $encode = true )

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

public appendHTML ( $tag, $value )

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

public cloneRegion ( $tag )

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

TODO: This does not dispose of the tags which were previously inside the region. This causes some severe pitfalls for the users and ideally must be checked and proper errors must be generated.
public del ( $tag )

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

public dumpTags ( )

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

public eachTag ( $tag, $callable )

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

Returns relevant exception class. Use this method with "throw".
public exception ( string $message = 'Undefined Exception', string $type = null, string $code = null ) : Exception_Template
$message string Static text of exception.
$type string Exception class or class postfix
$code string Optional error code
Результат Exception_Template

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

template loading and parsing
public findTemplate ( $template_name )

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

Get value of the tag. Note that this may contain an array if tag contains a structure.
public get ( $tag )

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

This function specifies default settings for SMlite.
public getDefaultSettings ( )

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

Because there might be multiple tags and getTagRef is returning only one template, it will return the first occurence: {greeting}hello{/}, {greeting}world{/} calling getTagRef('greeting',$template) will point second argument towards &array('hello');
public getTagRef ( $tag, &$template )

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

{greeting}hello{/}, {greeting}world{/} calling getTagRefList('greeting',$template) will point second argument towards array(&array('hello'),&array('world')); If $tag is specified as array, then $templates will contain all occurences of all tags from the array.
public getTagRefList ( $tag, &$template )

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

Checks if template has defined a specified tag.
public hasTag ( $tag )

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

Template creation, interface functions
public init ( )

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

Since Agile Toolkit 4.3 this tag is always called _top
public isTopTag ( string $tag ) : boolean
$tag string
Результат boolean

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

Obsolete due to inconsistent naming.
public is_set ( $tag )

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

public loadTemplate ( $template_name, $ext = null )

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

Initialize current template from the supplied string.
public loadTemplateFromString ( string $str )
$str string

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

{{{ ArrayAccess support
public offsetExists ( $name )

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

public offsetGet ( $name )

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

public offsetSet ( $name, $val )

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

public offsetUnset ( $name )

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

public parseTemplate ( $str )

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

public parseTemplateRecursive ( &$input, &$template )

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

public rebuildTags ( )

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

public rebuildTagsRegion ( &$template )

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

public recursiveRender ( &$template )

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

public regTag ( $tag )

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

Causes the template to be refreshed from it's original source
public reload ( )

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

public render ( $region = null )

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

public renderRegion ( &$chunk )

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

If tag is found inside template several times, all occurences are replaced. ALTERNATIVE USE(2) of this function is to pass associative array as a single argument. This will assign multiple tags with one call. Sample use is: set($_GET); would read and set multiple region values from $_GET array.
public set ( $tag, $value = null, $encode = true )

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

public setHTML ( $tag, $value = null )

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

Similar to del() but won't throw exception if tag is not present.
public tryDel ( $tag )

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

Check if tag is present inside template. If it does, execute set(); See documentation for set().
public trySet ( $tag, $value = null, $encode = true )

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

Attempt to set value of a tag to a HTML variable. The value is inserted as-is, while regular set() would HTML-encode the values to avoid injection.
public trySetHTML ( $tag, $value = null )

Описание свойств

$default_exception публичное свойство

public string $default_exception
Результат string

$origin_filename публичное свойство

Which file template is loaded from.
public $origin_filename

$settings публичное свойство

Settings are populated from the configuration file, if found.
public array $settings
Результат array

$tags публичное свойство

This array contains list of all tags found inside template implementing faster access when manipulating the template.
public array $tags
Результат array

$template публичное свойство

This is a parsed contents of the template organized inside an array. This structure makes it very simple to modify any part of the array.
public array $template
Результат array

$template_file публичное свойство

public $template_file

$template_source публичное свойство

public $template_source

$template_type публичное свойство

public $template_type

$top_tags публичное свойство

public $top_tags