PHP 클래스 Horde_Template, horde

Horde_Template provides a basic template engine with tags, loops, and if conditions. However, it is also a simple interface with several essential functions: set(), fetch(), and parse(). Subclasses or decorators can implement (or delegate) these three methods, plus the options api, and easily implement other template engines (PHP code, XSLT, etc.) without requiring usage changes. Compilation code adapted from code written by Bruno Pedro . Copyright 2002-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
저자: Chuck Hagenbuch ([email protected])
저자: Michael Slusarz ([email protected])
파일 보기 프로젝트 열기: horde/horde 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_arrays array Loop tag values.
$_basepath string Directory that templates should be read from.
$_cache Horde_Cache The Horde_Cache object to use.
$_foreachMap array Foreach variable mappings.
$_foreachVar integer Foreach variable incrementor.
$_logger Horde_Log_Logger Logger.
$_options array Option values.
$_pregcache array preg_match() cache.
$_scalars array Tag (scalar) values.
$_template string Template source.
$_templateFile string Path to template source.

공개 메소드들

메소드 설명
__construct ( array $params = [] ) Constructor.
fetch ( string $filename = null ) : string Fetches a template from the specified file and return the parsed contents.
get ( string $tag ) : mixed Returns the value of a tag or loop.
getOption ( string $option ) : mixed Returns an option's value.
parse ( string $contents = null ) : string Parses all variables/tags in the template.
set ( string | array $tag, mixed $var ) Sets a tag, loop, or if variable.
setOption ( string $option, mixed $val ) Sets an option.
setTemplate ( string $template ) Set the template contents to a string.

보호된 메소드들

메소드 설명
_doReplace ( $replace ) TODO
_doSearch ( $tag, $key, $noclose = false ) TODO
_generatePHPVar ( $tag, $key ) Output the correct PHP variable string for use in template space.
_parse ( ) Parses all variables/tags in the template.
_parseAssociativeTags ( ) Parse associative tags (i.e. ).
_parseGettext ( ) Parses gettext tags.
_parseIf ( string $key = null ) Parses 'if' statements.
_parseLoop ( string $key = null ) Parses the given array for any loops or other uses of the array.
_parseTags ( string $key = null ) Replaces 'tag' tags with their PHP equivalents.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( array $params = [] )
$params array The following configuration options:
'basepath' - (string) The directory where templates are read from.
'cacheob' - (Horde_Cache) A caching object used to cache the output.
'logger' - (Horde_Log_Logger) A logger object.

_doReplace() 보호된 메소드

TODO
protected _doReplace ( $replace )

_doSearch() 보호된 메소드

TODO
protected _doSearch ( $tag, $key, $noclose = false )

_generatePHPVar() 보호된 메소드

Output the correct PHP variable string for use in template space.
protected _generatePHPVar ( $tag, $key )

_parse() 보호된 메소드

Parses all variables/tags in the template.
protected _parse ( )

_parseAssociativeTags() 보호된 메소드

Parse associative tags (i.e. ).
protected _parseAssociativeTags ( )

_parseGettext() 보호된 메소드

Parses gettext tags.
protected _parseGettext ( )

_parseIf() 보호된 메소드

Parses 'if' statements.
protected _parseIf ( string $key = null )
$key string The key prefix to parse.

_parseLoop() 보호된 메소드

Parses the given array for any loops or other uses of the array.
protected _parseLoop ( string $key = null )
$key string The key prefix to parse.

_parseTags() 보호된 메소드

Replaces 'tag' tags with their PHP equivalents.
protected _parseTags ( string $key = null )
$key string The key prefix to parse.

fetch() 공개 메소드

Fetches a template from the specified file and return the parsed contents.
public fetch ( string $filename = null ) : string
$filename string The file to fetch the template from.
리턴 string The parsed template.

get() 공개 메소드

Returns the value of a tag or loop.
public get ( string $tag ) : mixed
$tag string The tag name.
리턴 mixed The tag value or null if the tag hasn't been set yet.

getOption() 공개 메소드

Returns an option's value.
public getOption ( string $option ) : mixed
$option string The option name.
리턴 mixed The option's value.

parse() 공개 메소드

Parses all variables/tags in the template.
public parse ( string $contents = null ) : string
$contents string The unparsed template.
리턴 string The parsed template.

set() 공개 메소드

Sets a tag, loop, or if variable.
public set ( string | array $tag, mixed $var )
$tag string | array Either the tag name or a hash with tag names as keys and tag values as values.
$var mixed The value to replace the tag with.

setOption() 공개 메소드

Currently available options are:
'debug' - Output debugging information to screen
'forcecompile' - Force a compilation on every page load
'gettext' - Activate gettext detection
        
public setOption ( string $option, mixed $val )
$option string The option name.
$val mixed The option's value.

setTemplate() 공개 메소드

Set the template contents to a string.
public setTemplate ( string $template )
$template string The template text.

프로퍼티 상세

$_arrays 보호되어 있는 프로퍼티

Loop tag values.
protected array $_arrays
리턴 array

$_basepath 보호되어 있는 프로퍼티

Directory that templates should be read from.
protected string $_basepath
리턴 string

$_cache 보호되어 있는 프로퍼티

The Horde_Cache object to use.
protected Horde_Cache $_cache
리턴 Horde_Cache

$_foreachMap 보호되어 있는 프로퍼티

Foreach variable mappings.
protected array $_foreachMap
리턴 array

$_foreachVar 보호되어 있는 프로퍼티

Foreach variable incrementor.
protected int $_foreachVar
리턴 integer

$_logger 보호되어 있는 프로퍼티

Logger.
protected Horde_Log_Logger $_logger
리턴 Horde_Log_Logger

$_options 보호되어 있는 프로퍼티

Option values.
protected array $_options
리턴 array

$_pregcache 보호되어 있는 프로퍼티

preg_match() cache.
protected array $_pregcache
리턴 array

$_scalars 보호되어 있는 프로퍼티

Tag (scalar) values.
protected array $_scalars
리턴 array

$_template 보호되어 있는 프로퍼티

Template source.
protected string $_template
리턴 string

$_templateFile 보호되어 있는 프로퍼티

Path to template source.
protected string $_templateFile
리턴 string