PHP 클래스 SMlite, atk4

- completely remove any code from templates - make templates editable with HTML editor
저자: Romans ([email protected])
상속: extends AbstractModel
파일 보기 프로젝트 열기: atk4/atk4 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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.

보호된 프로퍼티들

프로퍼티 타입 설명
$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