/** * 模板解析 * @return bool */ public function BuildTemplate() { if (strpos('|SAE|BAE2|ACE|TXY|', '|' . $this->option['ZC_YUN_SITE'] . '|') !== false) { return false; } //初始化模板 $this->LoadTemplate(); if (strpos($this->templates['comments'], 'AjaxCommentBegin') === false) { $this->templates['comments'] = '<label id="AjaxCommentBegin"></label>' . $this->templates['comments']; } if (strpos($this->templates['comments'], 'AjaxCommentEnd') === false) { $this->templates['comments'] = $this->templates['comments'] . '<label id="AjaxCommentEnd"></label>'; } if (strpos($this->templates['comment'], 'id="cmt{$comment.ID}"') === false && strpos($this->templates['comment'], 'id=\'cmt{$comment.ID}\'') === false) { $this->templates['comment'] = '<label id="cmt{$comment.ID}"></label>' . $this->templates['comment']; } if (strpos($this->templates['commentpost'], 'inpVerify') === false && strpos($this->templates['commentpost'], '=\'verify\'') === false && strpos($this->templates['commentpost'], '="verify"') === false) { $verify = '{if $option[\'ZC_COMMENT_VERIFY_ENABLE\'] && !$user.ID}<p><input type="text" name="inpVerify" id="inpVerify" class="text" value="" size="28" tabindex="4" /> <label for="inpVerify">' . $this->lang['msg']['validcode'] . '(*)</label><img style="width:{$option[\'ZC_VERIFYCODE_WIDTH\']}px;height:{$option[\'ZC_VERIFYCODE_HEIGHT\']}px;cursor:pointer;" src="{$article.ValidCodeUrl}" alt="" title="" onclick="javascript:this.src=\'{$article.ValidCodeUrl}&tm=\'+Math.random();"/></p>{/if}'; if (strpos($this->templates['commentpost'], '<!--verify-->') !== false) { $this->templates['commentpost'] = str_replace('<!--verify-->', $verify, $this->templates['commentpost']); } elseif (strpos($this->templates['commentpost'], '</form>') !== false) { $this->templates['commentpost'] = str_replace('</form>', $verify . '</form>', $this->templates['commentpost']); } else { $this->templates['commentpost'] .= $verify; } } if (strpos($this->templates['header'], '{$header}') === false) { if (strpos($this->templates['header'], '</head>') !== false) { $this->templates['header'] = str_replace('</head>', '</head>' . '{$header}', $this->templates['header']); } elseif (strpos($this->templates['header'], '</ head>') !== false) { $this->templates['header'] = str_replace('</ head>', '</ head>' . '{$header}', $this->templates['header']); } else { $this->templates['header'] .= '{$header}'; } } if (strpos($this->templates['footer'], '{$footer}') === false) { if (strpos($this->templates['footer'], '</body>') !== false) { $this->templates['footer'] = str_replace('</body>', '{$footer}' . '</body>', $this->templates['footer']); } elseif (strpos($this->templates['footer'], '</ body>') !== false) { $this->templates['footer'] = str_replace('</ body>', '{$footer}' . '</ body>', $this->templates['footer']); } elseif (strpos($this->templates['footer'], '</html>') !== false) { $this->templates['footer'] = str_replace('</html>', '{$footer}' . '</html>', $this->templates['footer']); } elseif (strpos($this->templates['footer'], '</ html>') !== false) { $this->templates['footer'] = str_replace('</ html>', '{$footer}' . '</ html>', $this->templates['footer']); } else { $this->templates['footer'] = '{$footer}' . $this->templates['footer']; } } $dir = $this->usersdir . 'theme/' . $this->theme . '/compile/'; if (!file_exists($dir)) { @mkdir($dir, 0755, true); } $files2 = array(); foreach ($this->templates as $name => $file) { $files2[] = $dir . $name . '.php'; } //清空目标目录 $files = GetFilesInDir($dir, 'php'); $files3 = array_diff($files, $files2); foreach ($files3 as $fullname) { @unlink($fullname); } //创建模板类 $template = new Template(); $template->SetPath($dir); //模板接口 foreach ($GLOBALS['hooks']['Filter_Plugin_Zbp_BuildTemplate'] as $fpname => &$fpsignal) { $fpname($this->templates); } $template->CompileFiles($this->templates); }