function TemplateLite($templateFile, $templateVar, $charset, $varPrefix = '') { $templateFile = substr($templateFile, strlen(TMPL_PATH)); include_once "class.template.php"; $tpl = new Template_Lite(); $tpl->template_dir = TMPL_PATH; $tpl->compile_dir = CACHE_PATH; $tpl->cache_dir = TEMP_PATH; $tpl->assign($templateVar); $tpl->display($templateFile); return; }
function render_template($template_name, $assign_vars = array()) { // Initialize the template object. $tpl = new Template_Lite(); // template directory $tpl->template_dir = TEMPLATE_PATH; // compile directory $tpl->compile_dir = COMPILED_TEMPLATE_PATH; // loop over the vars, assigning each. foreach ($assign_vars as $lname => $lvalue) { $tpl->assign($lname, $lvalue); } // call the template $rendered = $tpl->fetch($template_name); return $rendered; }
/** * @see RO_Flow_Work::_run() * * @return RO_Flow_Work */ protected function _run() { $this->_setNext('NEXT'); if (!isset($this->_data['_VIEW_DATA_'])) { return; } $data = $this->_data['_VIEW_DATA_']; $tpl = str_replace('_', DIRECTORY_SEPARATOR, $this->_data['_VIEW_']) . $this->_params['suffix']; $tplite = new Template_Lite(); $tplite->template_dir = $this->_params['tpl_path']; $tplite->compile_dir = $this->_params['tplc_path']; $tplite->cache = false; $tplite->force_compile = true; $tplite->assign($data); $tplite->display($tpl); }
/** * 渲染模板输出 * @access public * @param string $templateFile 模板文件名 * @param array $var 模板变量 * @return void */ public function fetch($templateFile, $var) { vendor("TemplateLite.class#template"); $templateFile = substr($templateFile, strlen(THEME_PATH)); $tpl = new \Template_Lite(); $tpl->template_dir = THEME_PATH; $tpl->compile_dir = CACHE_PATH; $tpl->cache_dir = TEMP_PATH; if (C('TMPL_ENGINE_CONFIG')) { $config = C('TMPL_ENGINE_CONFIG'); foreach ($config as $key => $val) { $tpl->{$key} = $val; } } $tpl->assign($var); $tpl->display($templateFile); }
public function __construct() { parent::__construct(); $this->cache = false; $this->compile_dir = CACHE_ROOT . '/compiled'; $this->template_dir = ROOT . '/templates'; $this->compile_check = true; $this->reserved_template_varname = 'tpl'; $this->assign('www_url', WWW_URL); $this->assign('self_url', Utils::getSelfUrl()); $this->assign('self_url_no_qs', Utils::getSelfUrl(true)); $this->assign('is_logged', false); }
/** * 构造函数 * * @return FLEA_View_Lite */ function FLEA_View_Lite() { parent::Template_Lite(); $viewConfig = FLEA::getAppInf('viewConfig'); if (is_array($viewConfig)) { foreach ($viewConfig as $key => $value) { if (isset($this->{$key})) { $this->{$key} = $value; } } } FLEA::loadClass('FLEA_View_SmartyHelper'); new FLEA_View_SmartyHelper($this); }
<?php /* * 74cms 初始化smarty引擎 * ============================================================================ * 版权所有: 骑士网络,并保留所有权利。 * 网站地址: http://www.74cms.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ */ if (!defined('IN_QISHI')) { die('Access Denied!'); } include_once QISHI_ROOT_PATH . 'include/template_lite/class.template.php'; $smarty = new Template_Lite(); $smarty->compile_dir = QISHI_ROOT_PATH . 'temp/templates_c'; $smarty->template_dir = ADMIN_ROOT_PATH . "templates/default/"; $smarty->cache_dir = QISHI_ROOT_PATH . 'temp/caches'; $smarty->reserved_template_varname = "smarty"; $smarty->cache = false; $smarty->left_delimiter = "{#"; $smarty->right_delimiter = "#}"; $smarty->force_compile = false; $smarty->assign('_PLUG', $_PLUG); $smarty->assign('QISHI', $_CFG); $smarty->assign('QISHI_VERSION', QISHI_VERSION . "." . QISHI_RELEASE);
/* * 74cms 计划任务 清除缓存 * ============================================================================ * 版权所有: 骑士网络,并保留所有权利。 * 网站地址: http://www.74cms.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ */ if (!defined('IN_QISHI')) { die('Access Denied!'); } global $_CFG; include_once QISHI_ROOT_PATH . 'include/template_lite/class.template.php'; $cronstpl = new Template_Lite(); $cronstpl->cache_dir = QISHI_ROOT_PATH . 'temp/caches/' . $_CFG['template_dir']; $cronstpl->compile_dir = QISHI_ROOT_PATH . 'temp/templates_c/' . $_CFG['template_dir']; $cronstpl->template_dir = QISHI_ROOT_PATH . 'templates/' . $_CFG['template_dir']; $cronstpl->cache = true; $cronstpl->clear_all_cache(); //删除微信扫描缓存文件 deldir(QISHI_ROOT_PATH . "data/weixin/"); function deldir($dir) { //删除目录下的文件: $dh = opendir($dir); while ($file = readdir($dh)) { if ($file != "." && $file != "..") { $fullpath = $dir . "/" . $file; if (!is_dir($fullpath)) {
<?php /* * 74cms 初始化模版引擎 * ============================================================================ * 版权所有: 骑士网络,并保留所有权利。 * 网站地址: http://www.74cms.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ */ if (!defined('IN_QISHI')) { die('Access Denied!'); } include_once QISHI_ROOT_PATH . 'include/template_lite/class.template.php'; $smarty = new Template_Lite(); $smarty->cache_dir = QISHI_ROOT_PATH . 'temp/caches/' . $_CFG['template_dir']; $smarty->compile_dir = QISHI_ROOT_PATH . 'temp/templates_c/' . $_CFG['template_dir']; $smarty->template_dir = QISHI_ROOT_PATH . 'templates/' . $_CFG['template_dir']; $smarty->reserved_template_varname = "smarty"; $smarty->left_delimiter = "{#"; $smarty->right_delimiter = "#}"; $smarty->force_compile = false; $smarty->assign('_PLUG', $_PLUG); $smarty->assign('QISHI', $_CFG); $smarty->assign('page_select', $page_select);
/** * Call Template_lite display/fetch method (depends on @param $display) * * @param string $resource_name * @param string $theme - null - define by the current controller, * what theme will be load (admin or user) * 'user' - load template from $this->user_theme * 'admin' - load template from $this->admin_theme * @param mixed (boolean/string) $module * true - search for the template file in the module views * false - search for the template file in the general views * string - module name * @param integer $cache_id cache identifier * @param boolean $display output to browser * @return string */ public function view($resource_name, $theme_type = null, $module = true, $cache_id = null, $display = true, $system_messages = true) { if (!isset($this->CI)) { $this->CI =& get_instance(); } ///// preview mode if (!empty($_SESSION['change_color_scheme'])) { $preview_theme = $_SESSION["preview_theme"]; $preview_scheme = $_SESSION["preview_scheme"]; } else { $preview_theme = ''; $preview_scheme = ''; } $module_name = $module === true ? $this->CI->router->class : $module; $theme_data = $this->CI->pg_theme->format_theme_settings($module_name, $theme_type, $preview_theme, $preview_scheme); if (strpos($resource_name, '.') === false) { $resource_name .= '.tpl'; } $img_folder_old = isset($this->_vars['img_folder']) ? $this->_vars['img_folder'] : ''; $css_folder_old = isset($this->_vars['css_folder']) ? $this->_vars['css_folder'] : ''; $logo_settings_old = isset($this->_vars['logo_settings']) ? $this->_vars['logo_settings'] : ''; $this->assign("color_scheme", $preview_scheme ?: $theme_data["scheme"]); $this->assign("img_folder", $theme_data["img_path"]); $this->assign("css_folder", $theme_data["css_path"]); $this->assign("logo_settings", $theme_data["logo"]); $this->assign("mini_logo_settings", $theme_data["mini_logo"]); $this->assign("js_folder", APPLICATION_FOLDER . 'js/'); //// language if (INSTALL_MODULE_DONE) { $language_data = $this->CI->pg_language->get_lang_by_id($this->CI->pg_language->current_lang_id); $this->assign("_LANG", $language_data); // Direction mark (&rtm; | <m;) $this->assign("DM", DM); $this->assign("DEMO_MODE", DEMO_MODE); if (DEMO_MODE) { $this->CI->config->load('demo_data', TRUE); $login_settings = $this->CI->config->item('login_settings', 'demo_data'); $this->assign("demo_login_settings", $login_settings); $demo_user_type = $this->CI->session->userdata("demo_user_type"); if (!$demo_user_type) { $demo_user_type = "user"; } $this->assign("demo_user_type", $demo_user_type); $this->assign("demo_user_type_login_settings", $login_settings[$demo_user_type]); $copyright = $this->CI->config->item('copyright', 'demo_data'); $this->assign("demo_copyright", $copyright); } $this->assign("auth_type", $this->CI->session->userdata("auth_type")); } if ($system_messages) { $predefined["error"] = $this->CI->system_messages->get_messages('error'); $predefined["info"] = $this->CI->system_messages->get_messages('info'); $predefined["success"] = $this->CI->system_messages->get_messages('success'); $predefined["header"] = $this->CI->system_messages->get_data('header'); $predefined["subheader"] = $this->CI->system_messages->get_data('subheader'); $predefined["help"] = $this->CI->system_messages->get_data('help'); $predefined["back_link"] = $this->CI->system_messages->get_data('back_link'); $this->assign("_PREDEFINED", $predefined); } if ($module !== false) { static $modules = array(); if (isset($modules[$module . '_' . $resource_name])) { $resource_name = $modules[$module . '_' . $resource_name]; } else { $resource_key = $resource_name; if (!empty($language_data)) { $module_lang_css = $theme_data["css_module_path"] . "style-" . $language_data["rtl"] . ".css"; if (file_exists(SITE_PHYSICAL_PATH . $module_lang_css)) { $this->CI->pg_theme->add_css($module_lang_css); } } $module_css = $theme_data["css_module_path"] . "style.css"; if (file_exists(SITE_PHYSICAL_PATH . $module_css)) { $this->CI->pg_theme->add_css($module_css); } $this->assign("module_tpl_path_relative", base_url() . $theme_data["theme_module_path"]); $this->assign("module_path_relative", site_url() . ($this->CI->router->is_admin_class ? 'admin/' : '') . ($module === true ? $this->CI->router->class : $module) . '/'); if (file_exists(SITE_PHYSICAL_PATH . $theme_data["theme_module_path"] . $resource_name)) { $resource_name = SITE_PHYSICAL_PATH . $theme_data["theme_module_path"] . $resource_name; } elseif (file_exists(SITE_PHYSICAL_PATH . $theme_data["theme_path"] . $resource_name)) { $resource_name = SITE_PHYSICAL_PATH . $theme_data["theme_path"] . $resource_name; } elseif (file_exists($this->template_dir . $resource_name)) { $resource_name = $this->template_dir . $resource_name; } else { log_message('error', 'File "' . $resource_name . '" does not exist'); return false; } $modules[$module . '_' . $resource_key] = $resource_name; } } else { $resource_name = SITE_PHYSICAL_PATH . $theme_data["theme_path"] . $resource_name; } if (!$display) { $content = parent::fetch($resource_name, $cache_id, $display); if ($img_folder_old) { $this->assign("img_folder", $img_folder_old); } if ($css_folder_old) { $this->assign("css_folder", $css_folder_old); } if ($logo_settings_old) { $this->assign("logo_settings", $logo_settings_old); } return $content; } else { if ($img_folder_old) { $this->assign("img_folder", $img_folder_old); } if ($css_folder_old) { $this->assign("css_folder", $css_folder_old); } if ($logo_settings_old) { $this->assign("logo_settings", $logo_settings_old); } parent::fetch($resource_name, $cache_id, $display); } }
<?php $timeparts = explode(" ", microtime()); $starttime = $timeparts[1] . substr($timeparts[0], 1); require "../src/class.template.php"; $tpl = new Template_Lite(); $tpl->force_compile = true; $tpl->compile_check = true; $tpl->cache = false; $tpl->cache_lifetime = 3600; $tpl->config_overwrite = false; $tpl->assign("Name", "Fred Irving Johnathan Bradley Peppergill"); $tpl->assign("FirstName", array("John", "Mary", "James", "Henry")); $tpl->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), array("phone" => "555-5555", "fax" => "555-4444", "cell" => "555-3333"))); $tpl->assign("bold", array("up", "down", "left", "right")); $tpl->assign("lala", array("up" => "first entry", "down" => "last entry")); $tpl->display("index.tpl"); $timeparts = explode(" ", microtime()); $endtime = $timeparts[1] . substr($timeparts[0], 1); echo bcsub($endtime, $starttime, 6);