/** * Constructor.. * PDOException throwable */ public function __construct($templateDirectory, $cacheDirectory, $templateExtension = 'html', $templatePrefix = '', $debug = false) { RainTPL::$tpl_dir = $templateDirectory; // template directory RainTPL::$cache_dir = $cacheDirectory; // cache directory RainTPL::$tpl_ext = $templateExtension; RainTPL::$path_replace = false; $this->rainTPL = new RainTPL(); $this->dataDispatcher = new DataDispatcher(); $this->tplDir = $templateDirectory; $this->tplExt = $templateExtension; $this->tplPrefix = $templatePrefix; $this->debug = $debug; }
<?php /* Copyright (c) 2014 Freeder * Released under a MIT License. * See the file LICENSE at the root of this repo for copying permission. */ $force_public = true; // Allow JS loading while not logged in require_once 'inc/init.php'; require_once 'inc/js.tpl.class.php'; if (!isset($_GET['script'])) { exit('error'); } $script = $_GET['script']; RainTPL::$tpl_ext = 'js'; RainTPL::$path_replace = false; $tpl = new JsTPL(); $tpl->assign('base_url', RainTPL::$base_url); $tpl->draw($script);
/** * 初始化模板 * * @since 1.0.1 * * @param bool $empty * * @return bool */ private function initTemplate($empty = false) { if ($empty) { return true; } if (file_exists(FILE_PREFIX . 'content/theme/' . THEME . '/')) { RainTPL::$tpl_dir = FILE_PREFIX . 'content/theme/' . THEME . '/'; RainTPL::$cache_dir = FILE_PREFIX . 'content/theme/' . THEME . '_cache/'; } else { RainTPL::$tpl_dir = FILE_PREFIX . 'content/theme/default/'; RainTPL::$cache_dir = FILE_PREFIX . 'content/theme/default_cache/'; } RainTPL::$tpl_ext = 'tpl.php'; RainTPL::$path_replace = false; $this->tpl = new RainTPL(); }