Pastoid

Habari PHPTAL engine (old)

The page you are looking at now is at this URL: http://pastoid.com/al4

This paste was last updated on February 5, 2009 at 1:58 am.

Pasted Coderaw

<?php
 
/**
 * Habari PHPTal template engine subclass
 *
 * Requires PHP 5.0.4 or later
 * @package Habari
 *
 * The PHPTalEngine is a subclass of the abstract TemplateEngine class
 * which uses the PHPTal templating system to handle display of template files
 *   
 */
 
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . HABARI_PATH . '/3rdparty/PHPTal');
require 'PHPTAL.php';
 
class PHPTalEngine extends TemplateEngine
{
	private $tal= null;
 
	/**
	 * Constructor for PHPTalEngine
	 * 
	 * Sets up default values for required settings.
	 */
	public function __construct()
	{
		define( 'PHPTAL_TEMPLATE_REPOSITORY', $this->template_dir );
		$this->tal= new PHPTal();
	}
 
	/**
	 * A function which outputs the result of a transposed
	 * template to the output stream
	 * 
	 * @param template  Name of template to display
	 */
	public function display( $template )
	{
		$this->tal->setTemplate( $this->template_dir . $template . '.html' );
		try {
			echo $this->tal->execute();
		}
		catch (Exception $e){
			echo $e;
		}
 
	} 
 
	/** 
	 * A function which returns the content of the transposed
	 * template as a string
	 *
	 * @param template  Name of template to fetch
	 */
	public function fetch( $template )
	{
		$this->tal->setTemplate( $this->template_dir . $template . '.html' );
		try {
			return $this->tal->execute();
		}
		catch (Exception $e){
			return $e;
		}
	}
 
	/** 
	 * Assigns a variable to the template engine for use in 
	 * constructing the template's output.
	 * 
	 * @param key name( s ) of variable
	 * @param value value of variable
	 */
	public function assign( $key, $value= '' )
	{
		$this->tal->set( $key, $value );
	}
 
	/** 
	 * Appends to an existing variable more values
	 * 
	 * @param key name of variable
	 * @param value value of variable
	 */
	public function append( $key, $value= '' )
	{
		$this->tal->set( $key, $value );
	} 
}
 
?>

Toggle wordwrap

Referring DomainHits
Unknown Referer 124
pastoid.com 9
Is this paste spam?
<Hide