PHP Classes
Icontem

File: template.lib.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of András Zoltán-Gyárfás  >  Pine template  >  template.lib.php  
File: template.lib.php
Role: Class source
Content type: text/plain
Description: Main script
Class: Pine template
Template engine that replaces tags in files
 

Contents

Class file image Download
<?php
/*
Created by Andras Zoltan-Gyarfas from Transilvania in 2007
email: azolee@gmail.com
Use this script as you wish, just please send a notice for me if you do so.
For more questions/suggestions, please contact me.
*/
class tpl
{
// public methods
    
public function display($a$wh$clr=true$ld=true)
    {
    if(
$ld) { $where=tpl::load($wh); }
    else { 
$where=$wh; }
        
$ret=$where;
        if(
is_array($a))
        {
            foreach(
$a as $k => $v)
            {
                
$ret=tpl::change($k$v$ret);
            }
        }
        if(
$clr)
        {
        return 
tpl::clear($ret);
        }
        else
        {
        return 
$ret;
        }
    }
// private methods
    
protected function load($fn)
    {
    
$ret="";
        if(
file_exists($fn))
        {
            
$ret file_get_contents($fn);
        }
        else
        {
            
$ret "";
        }
        return 
$ret;
    }
    
public function change($what$whit$where)
    {
        if(!empty(
$where))
        {
            
$ret=ereg_replace("{".strtoupper($what)."}"trim($whit), $where);
        }
        return 
$ret;
    }
    
protected function clear($c)
    {
    
$temp ereg_replace("{([A-Z0-9_]+)}","",$c);
    return 
$temp;
    }
}
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products