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

Class: Template_PHPLIB

Source Location: /htdocs/js/phplayersmenu/lib/PHPLIB.php

Class Overview


Converted PHPLIB Template class


Author(s):

Version:

  • 1.0

Methods



Class Details

[line 28]
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>




Tags:

version:  1.0
author:  Bjoern Schotte <bjoern@rent-a-phpwizard.de>
author:  Martin Jansen <mj@php.net> (PEAR conformance)


[ Top ]


Class Methods


constructor Template_PHPLIB [line 96]

Template_PHPLIB Template_PHPLIB( [string $root = "."], [string $unknowns = "remove"], [array $fallback = ""])

Constructor



Tags:

access:  public


Parameters:

string   $root   template root directory
string   $unknowns   how to handle unknown variables
array   $fallback   fallback paths

[ Top ]

method finish [line 409]

finished, finish( string $str)

Finish string



Tags:

return:  i.e. substituted string
access:  public


Parameters:

string   $str   string to finish

[ Top ]

method get [line 442]

string get( string $varname)

Get finished variable



Tags:

return:  string with finished variable


Parameters:

string   $varname   variable to get

[ Top ]

method getUndefined [line 375]

mixed getUndefined( string $handle)

Get undefined values of a handle



Tags:

return:  false if an error occured or the undefined values
access:  public


Parameters:

string   $handle   handle name

[ Top ]

method getVar [line 349]

mixed getVar( mixed $varname)

Return one or more specific variable(s) with their values.



Tags:

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 ]

method getVars [line 331]

array getVars( )

Return all defined variables and their values



Tags:

return:  with all defined variables and their values
access:  public


[ Top ]

method halt [line 538]

bool halt( string $msg)

Error function. Halt template system with message to show



Tags:

access:  public


Parameters:

string   $msg   message to show

[ Top ]

method haltMsg [line 561]

object PEAR haltMsg( string $msg)

printf error message to show



Tags:

return:  error object
access:  public


Parameters:

string   $msg   message to show

[ Top ]

method p [line 430]

void p( string $varname)

Print variable to the browser



Tags:

access:  public


Parameters:

string   $varname   name of variable to print

[ Top ]

method parse [line 291]

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.




Tags:

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 ]

method pParse [line 319]

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

Same as parse, but printing it.



Tags:

access:  public


Parameters:

string   $handle   handle which should be parsed
string   $target   target to parse into
   $append  

[ Top ]

method pSubst [line 272]

bool pSubst( string $handle)

Same as subst but printing the result



Tags:

return:  always false
access:  public


Parameters:

string   $handle   handle of template

[ Top ]

method setBlock [line 196]

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.




Tags:

access:  public


Parameters:

string   $parent   parent handle
string   $handle   block name handle
string   $name   variable substitution name

[ Top ]

method setFile [line 155]

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.




Tags:

access:  public


Parameters:

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

[ Top ]

method setRoot [line 110]

bool setRoot( string $root)

Sets the template directory



Tags:

access:  public


Parameters:

string   $root   new template directory

[ Top ]

method setUnknowns [line 135]

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




Tags:

access:  public


Parameters:

string   $unknowns   unknowns

[ Top ]

method setVar [line 224]

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

Set corresponding substitutions for placeholders



Tags:

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 ]

method subst [line 254]

mixed subst( string $handle)

Substitute variables in handle $handle



Tags:

return:  string substituted content of handle
access:  public


Parameters:

string   $handle   name of handle

[ Top ]


Documentation generated on Sun, 30 Dec 2007 17:50:26 -0800 by phpDocumentor 1.3.1