PHP Класс SMlite, atk4

- completely remove any code from templates - make templates editable with HTML editor
Автор: Romans ([email protected])
Наследование: extends AbstractModel
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$origin_filename Which file template is coming from.
$settings private
$tags This array contains list of all tags found inside template.
$template This is a parsed contents of the template.
$template_type Type of resource to look for pathFinder
$top_tag When cloning region inside a template, it's tag becomes a top_tag of a new template. Since SMlite 1.1 it's present in new template and can be used.
$updated_tag_list list of updated tags with values.

Защищенные свойства (Protected)

Свойство Тип Описание
$tmp_template

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

Метод Описание
__clone ( )
append ( $tag, $value, $encode = true ) This appends static content to region refered by a tag. This function is useful when you are adding more rows to a list or table.
appendHTML ( $tag, $value )
cloneRegion ( $tag )
debugRender ( ) : string
debugRenderRegion ( &$chunk ) : string
del ( $tag )
dumpTags ( ) Misc functions
eachTag ( $tag, $callable )
exception ( $message = 'Undefined Exception', $type = null, $code = null )
findTemplate ( $template_name ) template loading and parsing
get ( $tag ) Finds tag and returns contents.
getDefaultSettings ( ) : array This function specifies default settings for SMlite. Use 2nd argument for constructor to redefine those settings.
getTagVal ( $tag )
hasTag ( $tag ) Check if tag is present inside template
init ( ) Template creation, interface functions
isTopTag ( $tag ) : boolean
is_set ( $tag )
loadTemplate ( string $template_name, string $ext = null )
loadTemplateFromString ( string $template_string )
myStrTok ( &$string, string $tok ) : string
parseTemplate ( &$template, integer $level, integer $pc ) : string
rebuildTags ( ) Rebuild tags of existing array structure
rebuildTagsRegion ( &$branch )
registerTag ( $key, $npk, &$ref )
render ( ) : string | array Template rendering (array -> string)
renderRegion ( &$chunk ) : string | array
set ( $tag, $value = null, $encode = true )
setHTML ( $tag, $value = null )
setMessage ( $tag, $args = [] ) Provided that the HTML tag contains ICU-compatible message format string, it will be localized then integrated with passed arguments.
tryDel ( $tag )
trySet ( $tag, $value = null, $encode = true )
trySetHTML ( $tag, $value = null )

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

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

public __clone ( )

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

If tag is used for several regions inside template, they all will be appended with new data.
public append ( $tag, $value, $encode = true )

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

public appendHTML ( $tag, $value )

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

public cloneRegion ( $tag )

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

public debugRender ( ) : string
Результат string

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

public debugRenderRegion ( &$chunk ) : string
Результат string

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

public del ( $tag )

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

Misc functions
public dumpTags ( )

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

public eachTag ( $tag, $callable )

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

public exception ( $message = 'Undefined Exception', $type = null, $code = null )

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

template loading and parsing
public findTemplate ( $template_name )

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

THIS FUNTION IS DANGEROUS! - if you want a rendered region, use renderRegion() - if you want a sub-template use cloneRegion() - if you want to copy part of template to other SMlite object, do not forget to call rebuildTags() if you plan to refer them. Not calling rebuildTags() will render template properly anyway. If tag is defined multiple times, first region is returned.
public get ( $tag )

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

A small note why I decided on .html extension. I want to point out that template files are and should be valid HTML documents. With .html extension those files will be properly rendered inside web browser, properly understood inside text editor or will be properly treated with wysiwyg html editors.
public getDefaultSettings ( ) : array
Результат array

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

public getTagVal ( $tag )

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

Check if tag is present inside template
public hasTag ( $tag )

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

Template creation, interface functions
public init ( )

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

public isTopTag ( $tag ) : boolean
Результат boolean

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

public is_set ( $tag )

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

public loadTemplate ( string $template_name, string $ext = null )
$template_name string
$ext string

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

public loadTemplateFromString ( string $template_string )
$template_string string

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

public myStrTok ( &$string, string $tok ) : string
$tok string
Результат string

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

public parseTemplate ( &$template, integer $level, integer $pc ) : string
$level integer
$pc integer
Результат string

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

This function walks through template and rebuilds list of tags. You need it in case you changed already parsed template.
public rebuildTags ( )

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

public rebuildTagsRegion ( &$branch )

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

public registerTag ( $key, $npk, &$ref )

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

Template rendering (array -> string)
public render ( ) : string | array
Результат string | array

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

public renderRegion ( &$chunk ) : string | array
Результат string | array

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

public set ( $tag, $value = null, $encode = true )

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

public setHTML ( $tag, $value = null )

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

Provided that the HTML tag contains ICU-compatible message format string, it will be localized then integrated with passed arguments.
public setMessage ( $tag, $args = [] )

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

public tryDel ( $tag )

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

public trySet ( $tag, $value = null, $encode = true )

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

public trySetHTML ( $tag, $value = null )

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

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

Which file template is coming from.
public $origin_filename

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

private
public $settings

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

This array contains list of all tags found inside template.
public $tags

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

This is a parsed contents of the template.
public $template

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

Type of resource to look for pathFinder
public $template_type

$tmp_template защищенное свойство

protected $tmp_template

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

When cloning region inside a template, it's tag becomes a top_tag of a new template. Since SMlite 1.1 it's present in new template and can be used.
public $top_tag

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

list of updated tags with values.
public $updated_tag_list