Login   Register  
PHP Classes
elePHPant
Icontem

File: template.class.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Erick Anthony de Oliveira Carvalho  >  Simple Template System  >  template.class.php  >  Download  
File: template.class.php
Role: Class source
Content type: text/plain
Description: General file
Class: Simple Template System
Template engine based on replacing text strings
Author: By
Last change: Description
Date: 2011-06-04 20:39
Size: 1,696 bytes
 

Contents

Class file image Download
<?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->filefilesize($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."<?");
    }
}

?>