Class: Voot

Source Location: Program_Root/Voot.class.php

Class Overview

Voot

VOOT (Vanilla Object Oriented Templates) - A simple template class for performing basic placeholder substitution on a source file.

Author(s):

Version:

  • 1.1

Copyright:

  • 2003

Variables

Methods


Child classes:

Inherited Variables

Inherited Methods



Class Details

VOOT (Vanilla Object Oriented Templates) - A simple template class for
performing basic placeholder substitution on a source file.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

For more free PHP software visit http://andy.greyledge.net/download.php.

Tags:

[ Top ]


Class Variables

$elements =

An associative array containing element names and their corresponding
contents, to be substituted for the placeholders in the template when the
page is rendered.
For example, if your template has the placeholder
%TITLE%, you would add the following key/value pair to the $elements array:
"TITLE" => "My Page Title".

Tags:

Type: array

Overrides:

[ Top ]

$evalOnRender =

Whether or not the template contains executable PHP code. If this is set to TRUE, PHP will attempt to process the template at render time using the eval() function. As this functionality brings up some security issues, $evalOnrender is set to FALSE by the constructor.
Use the setEvalOnRender() method to change it.

Tags:

  • Var - $evalOnRender

Type: bool

Overrides:

[ Top ]

$headers =

An associative array containing HTTP header names and contents to be sent
to HTTP clients when the render() method is called without a filename
argument. Key/value pairs should be the header name and its contents; for
example, "Pragma" => "no-cache".

Tags:

Type: array

Overrides:

[ Top ]

$tempDir =

The directory in which to store temporary files created when the object's evalOnRender property is TRUE. If this property is not set when the render() method is called, VOOT will attempt to determine the OS's default temp directory (Contained in the TMP environment variable in Windows, and the TMPDIR environment variable in Linux/Unix). If neither TMP nor TMPDIR are set, VOOT will attempt to use the current directory "./". If your rendered template will contain any sensitive information such as database usernames and passwords, you should strongly consider either setting this variable to a directory that is not world-readable or keeping password information in a separate file that is not world-readable.

Tags:

  • Var - $tempDir The directory in which to temporarily store rendered templates. Unless you have set the object's evalOnRender property to TRUE, you don't need to worry about this property.

Type: string

Overrides:

[ Top ]

$template =

The contents of the chosen theme's template file.

Tags:

  • Var - $template

Type: string

Overrides:

[ Top ]


Class Methods

addHeader

void addHeader ( $headerName, $headerContents )

Adds a header to the $headers property, to be sent to the HTTP client
at render time.

Tags:

  • Access - public

Parameters:

  • string $headerName - The name of the header, for example "Pragma", or "Content-type".
  • string $headerContents - The contents of the header, for example "no-cache" or "text/html".

[ Top ]

doSubstitution

string doSubstitution ( )

Substitutes contents of the $elements property for their corresponding placeholders in the $template property, and returns the resulting string.

Tags:

  • Access - public

Parameters:

[ Top ]

getPlaceholdersFromTemplate

array getPlaceholdersFromTemplate ( )

Get a list of all placeholder names found in the object's $template
property.

Tags:

  • Return - An array containing the names of placeholders in the template, in the order they occur and with duplicates removed.
  • Access - public

Parameters:

[ Top ]

initFromTemplate

void initFromTemplate ( )

Automatically initialize elements for all placeholders found in the
template.
(Elements are initialized with an empty string, ''.)

Tags:

  • Access - public

Parameters:

[ Top ]

render

void render ( [$userFileName = null] )

Substitutes the appropriate object properties for template placeholders
and sends the results to STDOUT.

Tags:

  • Access - public

Parameters:

  • string $userFileName - The file in which to store the rendered template. Make sure the process running PHP has write permissions in the directory specified. If a filename is passed to the render() method, the contents of the object's $headers property will be ignored.

[ Top ]

setElement

void setElement ( $elementName, $elementValue )

Sets the contents of a page element, to be substituted for the corresponding placeholder when the page is rendered.
If the same placeholder appears more than once in the template, the element contents will be substituted for each instance.

Tags:

  • Access - public

Parameters:

  • string $elementName - The name of the element, such as "TITLE". (The corresponding template placeholder would be "%TITLE%".)
  • string $elementValue - The value of the element. For example, if $elementName is set to "TITLE" and $elementValue is set to "My Page Title", the text "My Page Title" will be substituted for the placeholder "%TITLE%" when the page is rendered.

[ Top ]

setEvalOnRender

void setEvalOnRender ( [$userEval = false] )

Sets the object's $evalOnRender property. If $evalOnRender is set to TRUE, VOOT will create a tempory file holding the rendered template, and then use PHP's include() function to execute it. The temporary file is deleted once it's included.

Tags:

  • Access - public

Parameters:

  • boolean $userEval -

[ Top ]

setTempDir

void setTempDir ( $userTempDir )

Sets the directory in which to store the temporary file created if the object's evalOnRender property is set to TRUE.
Make sure that the process running PHP has write permissions on whatever directory you specify here.

Tags:

  • Access - public

Parameters:

  • string $userTempDir - The directory in which to store temporary files created by VOOT.

[ Top ]

constructor Voot

void constructor Voot ( $templateFile )

The class constructor.
Attempts to open the file specified by the $templateFile parameter and store it in the object's $template property.

Tags:

  • Access - public

Parameters:

  • string $templateFile - The location of the template file. Results in an error if the file can't be accessed.

[ Top ]


Documention generated on Mon, 20 Jan 2003 11:20:48 -0500 by phpDocumentor 1.1.0