/** * 编译处理并引入模板中间件文件 * @param 传入具体的模板文件,相对路径在 tpl/ 目录 */ private function template($file = '') { !empty($this->_data_display) && extract($this->_data_display); $url_root = FYTPL::url_root(); include FYTPL::template($file); }
private function js_compress($content, $sig = 1) { if (!$sig) { return $content; } if (empty(self::$config)) { self::$config = CONFIG::get('fytpl'); } $i = strpos($content, '{js}', 0); $j = strpos($content, '{/js}', $i + 4); $tmp = substr($content, $i + 4, $j - $i - 4); $arr = explode(';', trim($tmp)); $ct = ''; if (!$i) { return $content; } foreach ($arr as $k => $v) { $v = trim($v); if ($sig) { $ct .= file_get_contents(FYSCU_ROOT . self::$config['tpl_path'] . $v) . ' '; } else { $ct .= '<script type="text/javascript" src="/fyscu' . self::$config['tpl_path'] . $v . '"></script>'; } } if ($sig) { $file = self::$config['tpl_path'] . 'c/js_' . uniqid() . '.js'; $name = FYSCU_ROOT . $file; $path = '/fyscu' . $file; file_put_contents($name, $ct); $content = str_replace('{js}' . $tmp . '{/js}', '<script type="text/javascript" src="' . $path . '"></script>', $content); } else { $content = str_replace('{js}' . $tmp . '{/js}', $ct, $content); } return $content; }