Example #1
0
/**
 * 去掉指定文件的空白、注释,然后存储到CACHE_PATH目录中
 * @param string $file 文件名
 * @param string $prefix 上一级目录
 * @param string $source 源文件名
 */
function mpf_save_to_cache($file, $prefix, $source)
{
    $dest_file = mpf_class_to_cache_file($file, $prefix);
    if (file_exists($dest_file)) {
        return;
    }
    $dir = dirname($dest_file);
    if (!is_dir($dir)) {
        @mkdir($dir, 0775, TRUE);
    }
    file_put_contents($dest_file, @php_strip_whitespace($source));
}
Example #2
0
 /**
  * 载入组件显示页面
  */
 public function execute()
 {
     $view = $this->get_view();
     if ($view) {
         $f = mpf_classname_to_path(get_class($this)) . $view . '.phtml';
         $file = "component/" . $f;
         global $G_LOAD_PATH, $cached_files;
         if (defined('CACHE_PATH')) {
             $cf = mpf_class_to_cache_file($f, "component");
             if (file_exists($cf)) {
                 $this->render($cf);
                 return;
             }
         }
         foreach ($G_LOAD_PATH as $path) {
             if (file_exists($path . $file)) {
                 $this->render($path . $file);
                 if (defined('CACHE_PATH')) {
                     mpf_save_to_cache($f, "component", $path . $file);
                 }
                 break;
             }
         }
     }
 }