/** * 获取tpl内容 * @param $lang */ private static function getContents($lang) { if (self::$contents === null) { $path = TXApp::$base_root . DS . 'language' . DS . $lang . '.php'; self::$contents = is_readable($path) ? require $path : []; } }
/** * 获得模板渲染后的内容 * @return string * @throws TXException */ public function getContent() { //防XSS注入 foreach ($this->objects as &$object) { if (is_string($object)) { $object = $this->encode($object); } elseif (is_array($object)) { $object = new TXArray($object); } } unset($object); $this->objects['PRM'] = new TXArray($this->params); extract($this->objects); ob_start(); //include template $lang = TXLanguage::getLanguage(); $file = sprintf('%s/template/%s%s.tpl.php', TXApp::$app_root, $this->view, $lang ? '.' . $lang : ""); if (!is_readable($file)) { $file = sprintf('%s/template/%s.tpl.php', TXApp::$app_root, $this->view); } if (!is_readable($file)) { throw new TXException(2005, $this->view); } include $file; TXLogger::showLogs(); $content = ob_get_clean(); return $content; }