smarty的一个封装类

来源:互联网 发布:js移除标签属性 编辑:程序博客网 时间:2024/04/29 05:19
<?php

class SmartyObject extends Smarty {
 
  function SmartyObject() {
   
    $this->Smarty();
   
    $this->template_dir = ENQUETE_HOME_DIR . 'template/web';
    $this->config_dir =  ENQUETE_HOME_DIR . 'config';
    $path= ENQUETE_HOME_DIR . "templates_c";   
    if(!file_exists($path)){
      mkdir($path);
    }
   
    // if from http server
    if(isset($_SERVER["REQUEST_URI"])){
      $uri = $_SERVER["REQUEST_URI"];
      $uri = str_replace(" ", "", $uri);
      $pos = strrpos($uri, "/");           
      $compileDir= substr($uri, 0, $pos);
     
      $dirs = split("/", $compileDir);
     
      foreach($dirs as $dir){
    if(!empty($dir)){
      $path .= DIRECTORY_SEPARATOR . $dir;
      if(!file_exists($path)){
        mkdir($path);   
      }
    }
      }     
    }
    $this->compile_dir = $path;
  }

}

?>
原创粉丝点击