【php开源代码栏目提醒】:网学会员在php开源代码频道为大家收集整理了class.template.php提供大家参考,希望对大家有所帮助!
<?php
/*
* Project: Smarty-Light, a smarter template engine
* File: class.template.php
* Author: Paul Lockaby <paul@paullockaby.com>
* Version: 2.2.8
* Copyright: 2003,2004,2005 by Paul Lockaby
* Credit: This work is a light version of Smarty: the
PHP compiling
* template engine, v2.5.0-CVS. Smarty was originally
* programmed by Monte Ohrt and Andrei Zmievski and can be
* found at http://smarty.php.net
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* You may contact the author of Smarty-Light by e-mail at:
* paul@paullockaby.com
*
* The latest version of Smarty-Light can be obtained from:
* http://www.paullockaby.com/projects/smarty-light
*
*/
class template {
// public configuration variables
var $left_tag = "{*"; // the left delimiter for template tags
var $right_tag = "*}"; // the right delimiter for template tags
var $cache = false; // whether or not to allow caching of files
var $force_compile = true; // force a compile regardless of saved state
var $template_dir = "templates"; // where the templates are to be found
var $plugin_dir = "plugins"; // where the plugins are to be found
var $compile_dir = "compiled"; // the directory to store the compiled files in
var $config_dir = "templates"; // where the config files are
var $cache_dir = "cached"; // where cache files are stored
var $config_overwrite = false;
var $config_booleanize = true;
var $config_fix_new_lines = true;
var $config_read_hidden = true;
var $cache_lifetime = 0; // how long the file in cache should be considered "fresh"
// private internal variables
var $_vars = array(); // stores all internal assigned variables
var $_confs = array(); // stores all internal config variables
var $_plugins = array(); // stores all internal plugins
var $_linenum = 0; // the current line number in the file we are processing
var $_file = ""; // the current file we are processing
var $_config_obj = null;
var $_compile_obj = null;
var $_cache_id = null;
var $_cache_dir = ""; // stores where this specific file is going to be cached
var $_cache_info = array('config' => array(), 'template' => array());
var $_sl_md5 = '39fc70570b8b60cbc1b85839bf242aff';
function assign($key, $value = null) {
if (is_array($key)) {
foreach($key as $var => $val)
if ($var != "" && !is_numeric($var))
$this->_vars[$var] = $val;
} else {
if ($key != "" && !is_numeric($key))
$this->_vars[$key] = $value;
}
}
function assign_config($key, $value = null) {
if (is_array($key)) {
foreach($key as $var => $val)
if ($var != "" && !is_numeric($var))
$this->_confs[$var] = $val;
} else {
if ($key != "" && !is_numeric($key))
$this->_confs[$key] = $value;
}
}
function clear($key = null) {
if ($key == null) {
$this->_vars = array();
} else {
if (is_array($key)) {
foreach($id as $index => $value)
if (in_array($value, $this->_vars))
unset($this->_vars[$index]);
} else {
if (in_array($key, $this->_vars))
unset($this->_vars[$index]);
}
}
}
function clear_config($key = null) {
if ($key == null) {
$this->_conf = array();
} else {
if (is_array($key)) {
foreach($key as $index => $value)
if (in_array($value, $this->_conf))
unset($this->_conf[$index]);
} else {
if (in_array($key, $this->_conf))
unset($this->_conf[$key]);
}
}
}
function &get_vars($key = null) {
if ($key == null) {
return $this->_vars;
} else {
if (isset($this->_vars[$key]))
return $this->_vars[$key];
else
return null;
}
}
function &get_config_vars($key = null) {
if ($key == null) {
return $this->_confs;
} else {
if (isset($this->_confs[$key]))
return $this->_confs[$key];
else
return null;
}
}
function clear_compiled($file = null) {
$this->_destroy_dir($file, null, $this->_get_dir