PHP Class SMlite, atk4

- completely remove any code from templates - make templates editable with HTML editor
Author: Romans ([email protected])
Inheritance: extends AbstractModel
Afficher le fichier Open project: atk4/atk4 Class Usage Examples

Méthodes publiques

Свойство Type Description
$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 Properties

Свойство Type Description
$tmp_template

Méthodes publiques

Méthode Description
__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 )

Method Details

__clone() public méthode

public __clone ( )

append() public méthode

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 méthode

public appendHTML ( $tag, $value )

cloneRegion() public méthode

public cloneRegion ( $tag )

debugRender() public méthode

public debugRender ( ) : string
Résultat string

debugRenderRegion() public méthode

public debugRenderRegion ( &$chunk ) : string
Résultat string

del() public méthode

public del ( $tag )

dumpTags() public méthode

Misc functions
public dumpTags ( )

eachTag() public méthode

public eachTag ( $tag, $callable )

exception() public méthode

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

findTemplate() public méthode

template loading and parsing
public findTemplate ( $template_name )

get() public méthode

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() public méthode

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
Résultat array

getTagVal() public méthode

public getTagVal ( $tag )

hasTag() public méthode

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

init() public méthode

Template creation, interface functions
public init ( )

isTopTag() public méthode

public isTopTag ( $tag ) : boolean
Résultat boolean

is_set() public méthode

public is_set ( $tag )

loadTemplate() public méthode

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

loadTemplateFromString() public méthode

public loadTemplateFromString ( string $template_string )
$template_string string

myStrTok() public méthode

public myStrTok ( &$string, string $tok ) : string
$tok string
Résultat string

parseTemplate() public méthode

public parseTemplate ( &$template, integer $level, integer $pc ) : string
$level integer
$pc integer
Résultat string

rebuildTags() public méthode

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

rebuildTagsRegion() public méthode

public rebuildTagsRegion ( &$branch )

registerTag() public méthode

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

render() public méthode

Template rendering (array -> string)
public render ( ) : string | array
Résultat string | array

renderRegion() public méthode

public renderRegion ( &$chunk ) : string | array
Résultat string | array

set() public méthode

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

setHTML() public méthode

public setHTML ( $tag, $value = null )

setMessage() public méthode

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 méthode

public tryDel ( $tag )

trySet() public méthode

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

trySetHTML() public méthode

public trySetHTML ( $tag, $value = null )

Property Details

$origin_filename public_oe property

Which file template is coming from.
public $origin_filename

$settings public_oe property

private
public $settings

$tags public_oe property

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

$template public_oe property

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

$template_type public_oe property

Type of resource to look for pathFinder
public $template_type

$tmp_template protected_oe property

protected $tmp_template

$top_tag public_oe property

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 public_oe property

list of updated tags with values.
public $updated_tag_list