Location: PHPKode > scripts > Template Generation > template-generation/classTPL.php
<?          /*
+-------------------------------------------------------------------------------+
|   name Template Gereation Class                                               |
|   file: classTPL.php                                                          |
|   vaersion 2006/feb/07                                                        |
|   Released under the terms and conditions of the GNU General Public License   |
|   For more details: http://gnu.org                                            |
|                                                                               |
|   Test on these System Configuration:                                         |
|       Apache/2.0.55 (Win32) PHP/5.1.2 + MySQL/5.0.15                          |
|       Apache/2.0.52 (Unix)  PHP/4.3.9 + MySQL/4.0.21                          |
|       Apache/2.0.52 (Unix)  PHP/5.0.2 + MySQL/4.0.21                          |
+-------------------------------------------------------------------------------+
            */
if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME'])) {      #disable direct view of this file
		exit('This file can not be accessed directly...');
}else{
class ClassTPL {
var $page;
var $extension = ".php";        #extension for the include file

function Page($template = 'default.tpl') {      #set the default tpl file
	$this->start = $this->Page_utime();	
		if (file_exists($template))
			$this->page = join('', file($template));
			else
		die("Template file $template not found.");
	}

function Page_parse($file) {
		ob_start();
		define("FILE", $file);
		include (FILE);           #security fix
		$this->buffer = ob_get_contents();
		ob_end_clean();
		return $file;         #Win fix
	}

function Page_replace_tags($tags = array()) {
		if (sizeof($tags) > 0)
			foreach ($tags as $tag => $data) {
				$data = (file_exists($data)) ? $this->Page_parse($data) : $data;
				$this->page = eregi_replace('{' . $tag . '}', $data, $this->page );
				$this->end = $this->Page_utime();
			}
	}

function Page_utime() {
		$time = explode( " ", microtime());
		$usec = (double)$time[0];
		$sec = (double)$time[1];
		return $sec + $usec;
	}
    
function Page_output() {
		echo $this->page;
	}
            /*
+-----------------------------------------------------------------------+
|   Create a include function, it`s no necessary.                       |
+-----------------------------------------------------------------------+
            */
function includion($filepath, $filename) {
	$path = "./" . $filepath . "/";        #create a path to the filename
	$incs = $path.$filename.$this->extension;      #create the filename
	 define("INC", $incs);
	include(INC);      #include the filename
	return $filepath;
	}
}
		}
?>
Return current item: Template Generation