<?php
// -- Simple Template System
// -- Powered by Erick-Master
// -- CTM TEAM Softwares
// -- www.ctmts.com.br
// -- erick-master@ctmts.com.br
// -- 29/04/2011
// -- template.class.php
class template
{
//---------------------------------------------------------
// Main Arguments
//---------------------------------------------------------
private $file = NULL; // -- Load File
private $content = NULL; // -- File Loaded
private $tags = array(); // -- Tags Added
private $count = 0; // -- Loop of Tags
//---------------------------------------------------------
// Load File
// @param = Directory from file
// @return = NULL
//---------------------------------------------------------
public function fread($archive)
{
$this->file = @fopen($archive, "r");
$this->content = @fread($this->file, filesize($archive));
if(!$this->file) exit("Error open: {$archive}");
if(!$this->content) exit("Error read: {$archive}");
}
//---------------------------------------------------------
// Add Tag
// @name = Namr
// @value = Value
// Example: {BLABLA} = "BLEBLE"
//---------------------------------------------------------
public function set($name, $value)
{
$this->tags[$this->count++] = array("name" => $name, "value" => $value);
}
//---------------------------------------------------------
// Show Template
// @param = NULL
// @return = NULL
//---------------------------------------------------------
public function show()
{
foreach($this->tags as $tags)
$this->content = str_replace("{".$tags['name']."}", $tags['value'], $this->content);
eval("?>".$this->content."<?");
}
}
?>
|