コード例 #1
0
ファイル: functions.php プロジェクト: uedcw/webstory
/**
 * 导入文件,对php原生require_once的封装和扩展
 * @param string $file 文件名
 * @param string $prefix 上一级目录
 * @return boolean
 */
function mpf_require_file($file, $prefix = "lib")
{
    global $G_LOAD_PATH;
    if (defined('CACHE_PATH') && $prefix != "lib") {
        $f = mpf_class_to_cache_file($file, $prefix);
        if (file_exists($f)) {
            if (!mpf_required_files($file, $prefix)) {
                require_once "{$f}";
            }
            return true;
        }
    }
    foreach ($G_LOAD_PATH as $path) {
        if (file_exists("{$path}{$prefix}/{$file}")) {
            if (!defined('CACHE_PATH') || !mpf_required_files($file, $prefix)) {
                require_once "{$path}{$prefix}/{$file}";
                if (defined('CACHE_PATH') && $prefix != "lib") {
                    mpf_save_to_cache($file, $prefix, "{$path}{$prefix}/{$file}");
                }
            }
            return true;
        }
    }
    return false;
}
コード例 #2
0
ファイル: Component.php プロジェクト: uedcw/webstory
 /**
  * 载入组件显示页面
  */
 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;
             }
         }
     }
 }