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

Class: HTML_Template_PHPLIB

Source Location: /HTML_Template_PHPLIB-1.4.0a1/HTML/Template/PHPLIB.php

Class Overview


Converted PHPLIB Template class


Author(s):

Version:

  • CVS: $Id: PHPLIB.php,v 1.4 2007/10/01 15:12:07 cweiske Exp $

Variables

Methods


Child classes:

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

Inherited Variables

Inherited Methods


Class Details

[line 30]
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 36]

If set, echo assignments

Type:   bool


[ Top ]

$file = array()

[line 42]

$file[handle] = 'filename';

Type:   array


[ Top ]

$file_fallbacks = array()

[line 48]

fallback paths that should be defined in a child class

Type:   array


[ Top ]

$haltOnError =  'report'

[line 82]

'yes' => halt,

'report' => report error, continue, 'no' => ignore error quietly


Type:   string


[ Top ]

$root =  ''

[line 54]

Relative filenames are relative to this pathname

Type:   string


[ Top ]

$unknowns =  'remove'

[line 74]

'remove' => remove undefined variables

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


Type:   string


[ Top ]



Method Detail

HTML_Template_PHPLIB (Constructor)   [line 101]

HTML_Template_PHPLIB HTML_Template_PHPLIB( [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 ]

finish   [line 456]

finished, finish( string $str)

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

Parameters:

string   $str   —  String to finish

[ Top ]

get   [line 493]

string get( string $varname)

Get finished variable
  • Return: string with finished variable

Parameters:

string   $varname   —  Name of variable to get

[ Top ]

getLastError   [line 651]

boolean|string getLastError( )

Returns the last error message if any
  • Return: Last error message if any

[ Top ]

getUndefined   [line 421]

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 393]

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 372]

array getVars( )

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

[ Top ]

halt   [line 620]

bool halt( string $msg)

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

Parameters:

string   $msg   —  message to show

[ Top ]

haltMsg   [line 639]

object PEAR haltMsg( string $msg)

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

Parameters:

string   $msg   —  message to show

[ Top ]

p   [line 480]

void p( string $varname)

Print variable to the browser
  • Access: public

Parameters:

string   $varname   —  Name of variable to print

[ Top ]

parse   [line 330]

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 360]

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 310]

bool pSubst( string $handle)

Same as subst but printing the result

Parameters:

string   $handle   —  Handle of template

[ Top ]

setBlock   [line 216]

void 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.

  • Access: public

Parameters:

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

[ Top ]

setFile   [line 165]

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 ]

setRoot   [line 116]

bool setRoot( string $root)

Sets the template directory
  • Access: public

Parameters:

string   $root   —  New template directory

[ Top ]

setUnknowns   [line 143]

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 250]

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 290]

mixed subst( string $handle)

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

Parameters:

string   $handle   —  Name of handle

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:10:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.