예제 #1
0
 /**
  * 加载模板
  * @access public
  * @param string $tmplTemplateFile 模板文件
  * @param array  $templateVar 模板变量
  * @param string $prefix 模板标识前缀
  * @return void
  */
 public function fetch($templateFile, $templateVar, $prefix = '')
 {
     $this->tVar = $templateVar;
     $templateCacheFile = $this->loadTemplate($templateFile, $prefix);
     //[cluster] 加载模板文件
     ThinkFS::include_file($templateCacheFile, $templateVar);
 }
예제 #2
0
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     $_content = empty($_data['content']) ? $_data['file'] : $_data['content'];
     $_data['prefix'] = !empty($_data['prefix']) ? $_data['prefix'] : C('TMPL_CACHE_PREFIX');
     if ('think' == $engine) {
         // 采用Think模板引擎
         if (!empty($_data['content']) && $this->checkContentCache($_data['content'], $_data['prefix']) || $this->checkCache($_data['file'], $_data['prefix'])) {
             // 缓存有效
             //[cluster]载入模版缓存文件
             ThinkFS::include_file(C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), $_data['var']);
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_content, $_data['var'], $_data['prefix']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (class_exists($class)) {
             $tpl = new $class();
             $tpl->fetch($_content, $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
     //[cluster] 增加有用的trace信息
     trace(RUNTIME_FILE, '核心编译缓存KEY', 'DEBUG');
     trace(C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), '模板缓存KEY', 'DEBUG');
 }
예제 #3
0
// +----------------------------------------------------------------------
// | Author: luofei614 <*****@*****.**>
// +----------------------------------------------------------------------
// ThinkPHP 入口文件
//[cluster] 定义路径常量
defined('CLUSTER_PATH') or define('CLUSTER_PATH', ENGINE_PATH . 'Cluster/');
//[cluster] 提前系统目录定义
defined('IO_NAME') or define('IO_NAME', 'auto');
defined('IO_PATH') or define('IO_PATH', APP_PATH . 'IO/' . IO_NAME . '.php');
//[cluster] 建立默认应用
if (!file_exists(IO_PATH)) {
    require CLUSTER_PATH . 'build_first_app.php';
}
require IO_PATH;
//[cluster] 记录开始运行时间 移动到加载IO文件之后
$GLOBALS['_beginTime'] = microtime(TRUE);
//[cluster] 定义加载IO配置
defined('IO_TRUE_NAME') or define('IO_TRUE_NAME', IO_NAME);
require CLUSTER_PATH . 'Lib/Core/ThinkFS.class.php';
defined('RUNTIME_PATH') or define('RUNTIME_PATH', APP_PATH . 'Runtime/');
defined('APP_DEBUG') or define('APP_DEBUG', false);
// 是否调试模式
$runtime = defined('MODE_NAME') ? '~' . strtolower(MODE_NAME) . '_runtime.php' : '~runtime.php';
defined('RUNTIME_FILE') or define('RUNTIME_FILE', RUNTIME_PATH . $runtime);
if (!APP_DEBUG && ThinkFS::file_exists(RUNTIME_FILE)) {
    //[cluster] 部署模式直接载入运行缓存
    ThinkFS::include_file(RUNTIME_FILE);
} else {
    //[cluster] 加载运行时文件
    require CLUSTER_PATH . 'Common/runtime.php';
}