HTML_Template_PHPLIB
[ class tree: HTML_Template_PHPLIB ] [ index: HTML_Template_PHPLIB ] [ all elements ]

Class: HTML_Template_PHPLIB

Source Location: /HTML_Template_PHPLIB-1.6.1/HTML/Template/PHPLIB.php

Class Overview


Converted PHPLIB Template class


Author(s):

Variables

Methods


Child classes:

myT
Converted PHPLIB Template class
Template_PHPLIB
Backwards-compatibility for HTML_Template_PHPLIB.

Inherited Variables

Inherited Methods


Class Details

[line 34]
Converted PHPLIB Template class

For those who want to use PHPLIB's fine template class, here's a PEAR conforming class with the original PHPLIB template code from phplib-stable CVS. Original author was Kristian Koehntopp <kris@koehntopp.de>



[ Top ]


Class Variables

$debug =  false

[line 40]

If set, echo assignments

Type:   bool


[ Top ]

$file = array()

[line 46]

$file[handle] = 'filename';

Type:   array


[ Top ]

$file_fallbacks = array()

[line 52]

Fallback paths that should be defined in a child class

Type:   array


[ Top ]

$haltOnError =  'report'

[line 98]

'yes' => halt,

'report' => report error, continue, return false 'return' => return PEAR_Error object, 'no' => ignore error quietly, return false from functions


Type:   string


[ Top ]

$illegals =  ''

[line 89]

Characters that are not allowed in variable names.

Need to be preg_quote'd.


Type:   string


[ Top ]

$root =  ''

[line 58]

Relative filenames are relative to this pathname

Type:   string


[ Top ]

$unknowns =  'remove'

[line 79]

'remove' => remove undefined variables 'comment' => replace undefined variables with comments 'keep' => keep undefined variables

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 117]

HTML_Template_PHPLIB __construct( [string $root = '.'], [string $unknowns = 'remove'], [array $fallback = ''])

Constructor
  • Access: public

Parameters:

string   $root   —  Template root directory
string   $unknowns   —  How to handle unknown variables
array   $fallback   —  Fallback paths

[ Top ]

clearVar   [line 136]

void clearVar( array|string $var)

Clears a variable (sets its content to "")
  • Access: public

Parameters:

array|string   $var   —  Variable name to clear, or array name

[ Top ]

exists   [line 178]

boolean exists( string|array $var)

Checks if the given variable exists.

When an array is given, it is checked if all variables exist.

  • Return: True if the variable exists

Parameters:

string|array   $var   —  Variable to check

[ Top ]

finish   [line 566]

finished, finish( string $str)

Finish string
  • Return: i.e. substituted string
  • Access: public

Parameters:

string   $str   —  String to finish

[ Top ]

get   [line 608]

string get( string $varname)

Get finished variable
  • Return: string with finished variable

Parameters:

string   $varname   —  Name of variable to get

[ Top ]

getLastError   [line 791]

boolean|string getLastError( )

Returns the last error message if any
  • Return: Last error message if any, false if none.

[ Top ]

getUndefined   [line 530]

mixed getUndefined( string $handle)

Get undefined values of a handle
  • Return: False if an error occured or the array of undefined values
  • Access: public

Parameters:

string   $handle   —  Handle name

[ Top ]

getVar   [line 503]

mixed getVar( mixed $varname)

Return one or more specific variable(s) with their values.
  • Return: Array of variable names with their values or value of one specific variable
  • Access: public

Parameters:

mixed   $varname   —  Array with variable names or one variable name as a string

[ Top ]

getVars   [line 483]

array getVars( )

Return all defined variables and their values
  • Return: with all defined variables and their values
  • Access: public

[ Top ]

halt   [line 738]

bool halt( string $msg)

Error function. Halt template system with message to show
  • Access: public

Parameters:

string   $msg   —  message to show

[ Top ]

haltMsg   [line 776]

object PEAR haltMsg( string $msg, [string $mode = null], [string $level = null])

Printf error message to show
  • Return: error object
  • Access: public

Parameters:

string   $msg   —  Message to show
string   $mode   —  PEAR error mode, i.e. PEAR_ERROR_RETURN
string   $level   —  Internal error level when $mode is PEAR_ERROR_TRIGGER

[ Top ]

isError   [line 808]

boolean isError( mixed $val)

Checks if the given value is an error
  • Return: True if it is an error

Parameters:

mixed   $val   —  Some value

[ Top ]

p   [line 595]

void p( string $varname)

Print variable to the browser
  • Access: public

Parameters:

string   $varname   —  Name of variable to print

[ Top ]

parse   [line 442]

string parse( string $target, string $handle, [boolean $append = false])

Parse handle into target

Parses handle $handle into $target, eventually appending handle at $target if $append is defined as TRUE.

  • Return: parsed handle
  • Access: public

Parameters:

string   $target   —  Target handle to parse into
string   $handle   —  Which handle should be parsed
boolean   $append   —  Append it to $target or not?

[ Top ]

pParse   [line 471]

bool pParse( string $target, string $handle, [should $append = false])

Same as parse, but printing it.

Parameters:

string   $target   —  Target to parse into
string   $handle   —  Handle which should be parsed
should   $append   —  If $handle shall be appended to $target?

[ Top ]

pSubst   [line 422]

bool pSubst( string $handle)

Same as subst but printing the result

Parameters:

string   $handle   —  Handle of template

[ Top ]

setBlock   [line 323]

mixed setBlock( string $parent, string $handle, [string $name = ''])

Set a block in the appropriate template handle

By setting a block like that:

&lt;!-- BEGIN blockname --&gt; html code &lt;!-- END blockname --&gt;

you can easily do repeating HTML code, i.e. output database data nice formatted into a HTML table where each DB row is placed into a HTML table row which is defined in this block. It extracts the template $handle from $parent and places variable {$name} instead.

  • Return: True if all went well
  • Access: public

Parameters:

string   $parent   —  Parent handle
string   $handle   —  Block name handle
string   $name   —  Variable substitution name

[ Top ]

setFile   [line 266]

bool setFile( mixed $handle, [string $filename = ''])

Set appropriate template files

With this method you set the template files you want to use. Either you supply an associative array with key/value pairs where the key is the handle for the filname and the value is the filename itself, or you define $handle as the file name handle and $filename as the filename if you want to define only one template.

  • Return: True if file could be loaded
  • Access: public

Parameters:

mixed   $handle   —  Handle for a filename or array with handle/name value pairs
string   $filename   —  Name of template file

[ Top ]

setIllegals   [line 243]

void setIllegals( string $illegals)

Set characters that are not allowed in variable names.

Normal illegal characters like space, tab, newline are automatically there and do not have to be mentioned here.


Parameters:

string   $illegals   —  String of characters not allowed in template variable names.

[ Top ]

setRoot   [line 199]

bool setRoot( string $root)

Sets the template directory
  • Access: public

Parameters:

string   $root   —  New template directory

[ Top ]

setUnknowns   [line 225]

void setUnknowns( [string $unknowns = 'keep'])

What to do with unknown variables

Three possible values:

  • 'remove' will remove unknown variables (don't use this if you define CSS in your page)
  • 'comment' will replace undefined variables with comments
  • 'keep' will keep undefined variables as-is

  • Access: public

Parameters:

string   $unknowns   —  Unknowns

[ Top ]

setVar   [line 363]

void setVar( string $varname, [string $value = ''], [boolean $append = false])

Set corresponding substitutions for placeholders
  • Access: public

Parameters:

string   $varname   —  Name of a variable that is to be defined or an array of variables with value substitution as key/value pairs
string   $value   —  Value of that variable
boolean   $append   —  If true, the value is appended to the variable's existing value

[ Top ]

subst   [line 402]

mixed subst( string $handle)

Substitute variables in handle $handle
  • Return: String substituted content of handle
  • Access: public

Parameters:

string   $handle   —  Name of handle

[ Top ]

unsetVar   [line 156]

void unsetVar( array|string $var)

Unsets a variable completly
  • Access: public

Parameters:

array|string   $var   —  Variable name to clear, or array of names

[ Top ]


Documentation generated on Tue, 10 Dec 2019 05:16:06 -0500 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.