/** * @brief 渲染处理 * @param string $viewFile 要渲染的页面 * @param string or array $rdata 要渲染的数据 */ public function renderView($viewFile, $rdata = null) { //要渲染的视图 $renderFile = $viewFile . $this->extend; //检查视图文件是否存在 if (is_file($renderFile)) { //控制器的视图(需要进行编译编译并且生成可以执行的php文件) if (stripos($renderFile, IWEB_PATH . 'web/view/') === false) { //生成文件路径 $runtimeFile = str_replace($this->getViewPath(), $this->module->getRuntimePath(), $viewFile . $this->defaultExecuteExt); //layout文件 $layoutFile = $this->getLayoutFile() . $this->extend; if (!is_file($runtimeFile) || filemtime($renderFile) > filemtime($runtimeFile) || is_file($layoutFile) && filemtime($layoutFile) > filemtime($runtimeFile)) { //获取view内容 $viewContent = file_get_contents($renderFile); //处理layout $viewContent = $this->renderLayout($layoutFile, $viewContent); //标签编译 $inputContent = $this->tagResolve($viewContent); //创建文件 $fileObj = new IFile($runtimeFile, 'w+'); $fileObj->write($inputContent); $fileObj->save(); unset($fileObj); } } else { $runtimeFile = $renderFile; } //引入编译后的视图文件 $this->requireFile($runtimeFile, $rdata); } else { return false; } }