<?php
// A simple templating class
class Template
{
private $template_string = "";
private $template_file = "";
private $token_key = Array();
private $token_value = Array();
private function loadTemplateFile()
{
$this->template_string = file_get_contents( $this->template_file );
}
function setToken($token, $value)
{
$this->token_key[] = "{" . strtoupper($token) . "}" ;
$this->token_value[] = $value;
}
function removeToken($token)
{
$index = array_search( "{" . strtoupper($token) . "}" , $this->token_key );
if( $index !== false )
{
unset( $this->token_value[$index] );
unset( $this->token_key[$index] );
}
}
function show()
{
$show_string = str_replace($this->token_key, $this->token_value, $this->template_string);
print($show_string);
}
function __construct($template_file)
{
$this->template_file = $template_file;
$this->loadTemplateFile();
}
function __destruct()
{
}
}
?>