Location: PHPKode > projects > Yupi cms > yupi-cms/include/class.phptemplate.php
<?php

/**
 * @author Edin.o
 * @copyright 2009
 */

class PhpTemplate
{
   var $_lang;
   var $_absolutePath;
   var $_basePath;
   
   function __construct($absolutePath= false)
   {
      $this->_absolutePath = $absolutePath;
      $this->_basePath =php_file("templates");
   }
   
   #smarty compatible var assigment
   function assign($var, $value)
   {
      $this->$var = $value;
   }
   
   function setBasePath($path)
   {
      $this->_basePath = $path;
   }
   
   
   #gets template path
   function getTemplateFile($template)
   {
       if ($this->_absolutePath){
         $file = $template;
       }else{
         $file = BuildPath($this->_basePath, $template);   
       }
       return $file;
   }
   
   function display($template)
   {
       global $ActiveUser;
       global $Confing;

       $this->_lang = Language::Get($template);
       
       $vars = get_object_vars($this);
       
       foreach($vars as $key => $value)
       {
          $$key = $value;
       } 
       
       $file = $this->getTemplateFile($template);
       
  	    include $file;
   }
   
   function fetch($template)
   {
       global $ActiveUser;
       global $Confing;
       
       $this->_lang = Language::Get($template);
       
       $vars = get_object_vars($this);
       foreach($vars as $key => $value)
       {
          $$key = $value;
       }       
      
       $file = $this->getTemplateFile($template);
             
    	 ob_start();
		   include $file;
      	$data = ob_get_contents();
   	 ob_clean();
       return $data;    
   }

}


?>
Return current item: Yupi cms