PHP Classes

File: templates/class/exp.tpl

Recommend this page to a friend!
  Classes of Vladimir  >  Templates class  >  templates/class/exp.tpl  >  Download  
File: templates/class/exp.tpl
Role: Auxiliary data
Content type: text/plain
Description: templates
Class: Templates class
Template engine that replaces variable marks
Author: By
Last change:
Date: 8 years ago
Size: 1,617 bytes


Class file image Download

class tpl {
	private $dir_tmp     = TMP_DIR; // путь к папке с шаблонами
	private $tmp = ''; // абсолютный путь к шаблону
	private $content = '';

	function __construct($site_tmp){
        $this->tmp = realpath(dirname(__FILE__). '/../../').$this->dir_tmp.'/'.$site_tmp;


    public function patch_site_tmp (){

    		return $this->tmp;
    	}die('<b>папка '.$this->tmp.' не найдена!</b>');

    public function _content($temp){
    	return $this->handler_template();

    public function content($temp,$print=true){
    		print( $this->handler_template());
    	}else{return  $this->handler_template();}

    private function load_template($path){
	     if( is_file($this->tmp.'/'.$path.'.tpl') ){
	         $this->content = file_get_contents($this->tmp.'/'.$path.'.tpl');
	     }else{die('<b>шаблон - '.$path.'.tpl не найден</b>');}

	function handler_template (){
	     preg_match_all ("/{([A-Z_]+)}/", $this->content, $matches);
	     if( is_array ($matches) ){
	        while (list(,$val) = each ($matches[0])){
	            $search[]  = "'".$val."'";
	            $val = str_replace ("}","",$val);
	            $VAL = str_replace ("{","",$val);
	            $replace[] = $GLOBALS[$VAL];
	        $search[]  = "'0'e";
	        $replace[] = '0';
	        $path = preg_replace ($search, $replace, $this->content);

	    return $path;

For more information send a message to info at phpclasses dot org.