Update smarty from 3.0.5 to 3.0.7
See http://smarty-php.googlecode.com/svn/trunk/distribution/change_log.txt for a list of all changes. New files: libs/sysplugins/smarty_internal_get_include_path.php libs/plugins/shared.mb_str_replace.php Deleted files (no longer shipped with smarty): libs/plugins/function.popup.php libs/plugins/function.popup_init.php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@972 a1433add-5e2c-0410-b055-b7f2511e0802pull/2/head
parent
476035efd1
commit
82778dba1e
@ -1,118 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {popup} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: popup<br>
|
||||
* Purpose: make text pop up in windows via overlib
|
||||
* @link http://smarty.php.net/manual/en/language.function.popup.php {popup}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $params parameters
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_popup($params, $template)
|
||||
{
|
||||
$append = '';
|
||||
foreach ($params as $_key=>$_value) {
|
||||
switch ($_key) {
|
||||
case 'text':
|
||||
case 'trigger':
|
||||
case 'function':
|
||||
case 'inarray':
|
||||
$$_key = (string)$_value;
|
||||
if ($_key == 'function' || $_key == 'inarray')
|
||||
$append .= ',' . strtoupper($_key) . ",'$_value'";
|
||||
break;
|
||||
|
||||
case 'caption':
|
||||
case 'closetext':
|
||||
case 'status':
|
||||
$append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'";
|
||||
break;
|
||||
|
||||
case 'fgcolor':
|
||||
case 'bgcolor':
|
||||
case 'textcolor':
|
||||
case 'capcolor':
|
||||
case 'closecolor':
|
||||
case 'textfont':
|
||||
case 'captionfont':
|
||||
case 'closefont':
|
||||
case 'fgbackground':
|
||||
case 'bgbackground':
|
||||
case 'caparray':
|
||||
case 'capicon':
|
||||
case 'background':
|
||||
case 'frame':
|
||||
$append .= ',' . strtoupper($_key) . ",'$_value'";
|
||||
break;
|
||||
|
||||
case 'textsize':
|
||||
case 'captionsize':
|
||||
case 'closesize':
|
||||
case 'width':
|
||||
case 'height':
|
||||
case 'border':
|
||||
case 'offsetx':
|
||||
case 'offsety':
|
||||
case 'snapx':
|
||||
case 'snapy':
|
||||
case 'fixx':
|
||||
case 'fixy':
|
||||
case 'padx':
|
||||
case 'pady':
|
||||
case 'timeout':
|
||||
case 'delay':
|
||||
$append .= ',' . strtoupper($_key) . ",$_value";
|
||||
break;
|
||||
|
||||
case 'sticky':
|
||||
case 'left':
|
||||
case 'right':
|
||||
case 'center':
|
||||
case 'above':
|
||||
case 'below':
|
||||
case 'noclose':
|
||||
case 'autostatus':
|
||||
case 'autostatuscap':
|
||||
case 'fullhtml':
|
||||
case 'hauto':
|
||||
case 'vauto':
|
||||
case 'mouseoff':
|
||||
case 'followmouse':
|
||||
case 'closeclick':
|
||||
case 'wrap':
|
||||
if ($_value) $append .= ',' . strtoupper($_key);
|
||||
break;
|
||||
|
||||
default:
|
||||
trigger_error("[popup] unknown parameter $_key", E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($text) && !isset($inarray) && empty($function)) {
|
||||
trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required",E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($trigger)) { $trigger = "onmouseover"; }
|
||||
|
||||
$retval = $trigger . '="return overlib(\''.preg_replace(array("!'!",'!"!',"![\r\n]!"),array("\'","\'",'\r'),$text).'\'';
|
||||
$retval .= $append . ');"';
|
||||
if ($trigger == 'onmouseover')
|
||||
$retval .= ' onmouseout="nd();"';
|
||||
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
?>
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {popup_init} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: popup_init<br>
|
||||
* Purpose: initialize overlib
|
||||
* @link http://smarty.php.net/manual/en/language.function.popup.init.php {popup_init}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $params parameters
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
*/
|
||||
|
||||
function smarty_function_popup_init($params, $template)
|
||||
{
|
||||
$zindex = 1000;
|
||||
|
||||
if (!empty($params['zindex'])) {
|
||||
$zindex = $params['zindex'];
|
||||
}
|
||||
|
||||
if (!empty($params['src'])) {
|
||||
return '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>' . "\n"
|
||||
. '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>' . "\n";
|
||||
} else {
|
||||
trigger_error("popup_init: missing src parameter",E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
if(!function_exists('smarty_mb_str_replace')) {
|
||||
function smarty_mb_str_replace($search, $replace, $subject, &$count=0) {
|
||||
if (!is_array($search) && is_array($replace)) {
|
||||
return false;
|
||||
}
|
||||
if (is_array($subject)) {
|
||||
// call mb_replace for each single string in $subject
|
||||
foreach ($subject as &$string) {
|
||||
$string = &smarty_mb_str_replace($search, $replace, $string, $c);
|
||||
$count += $c;
|
||||
}
|
||||
} elseif (is_array($search)) {
|
||||
if (!is_array($replace)) {
|
||||
foreach ($search as &$string) {
|
||||
$subject = smarty_mb_str_replace($string, $replace, $subject, $c);
|
||||
$count += $c;
|
||||
}
|
||||
} else {
|
||||
$n = max(count($search), count($replace));
|
||||
while ($n--) {
|
||||
$subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c);
|
||||
$count += $c;
|
||||
next($search);
|
||||
next($replace);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$parts = mb_split(preg_quote($search), $subject);
|
||||
$count = count($parts)-1;
|
||||
$subject = implode($replace, $parts);
|
||||
}
|
||||
return $subject;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,133 +1,170 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Debug
|
||||
*
|
||||
* Class to collect data for the Smarty Debugging Consol
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Debug
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
* Smarty Internal Plugin Debug
|
||||
*
|
||||
* Class to collect data for the Smarty Debugging Consol
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Debug
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Debug Class
|
||||
*/
|
||||
* Smarty Internal Plugin Debug Class
|
||||
*/
|
||||
class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||
// template data
|
||||
static $template_data = array();
|
||||
// template data
|
||||
static $template_data = array();
|
||||
|
||||
/**
|
||||
* Start logging of compile time
|
||||
*/
|
||||
public static function start_compile($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['start_time'] = microtime(true);
|
||||
}
|
||||
/**
|
||||
* Start logging of compile time
|
||||
*/
|
||||
public static function start_compile($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['start_time'] = microtime(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* End logging of compile time
|
||||
*/
|
||||
public static function end_compile($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['compile_time'] += microtime(true) - self::$template_data[$key]['start_time'];
|
||||
}
|
||||
/**
|
||||
* End logging of compile time
|
||||
*/
|
||||
public static function end_compile($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['compile_time'] += microtime(true) - self::$template_data[$key]['start_time'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Start logging of render time
|
||||
*/
|
||||
public static function start_render($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['start_time'] = microtime(true);
|
||||
}
|
||||
/**
|
||||
* Start logging of render time
|
||||
*/
|
||||
public static function start_render($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['start_time'] = microtime(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* End logging of compile time
|
||||
*/
|
||||
public static function end_render($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['render_time'] += microtime(true) - self::$template_data[$key]['start_time'];
|
||||
}
|
||||
/**
|
||||
* End logging of compile time
|
||||
*/
|
||||
public static function end_render($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['render_time'] += microtime(true) - self::$template_data[$key]['start_time'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Start logging of cache time
|
||||
*/
|
||||
public static function start_cache($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['start_time'] = microtime(true);
|
||||
}
|
||||
/**
|
||||
* Start logging of cache time
|
||||
*/
|
||||
public static function start_cache($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['start_time'] = microtime(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* End logging of cache time
|
||||
*/
|
||||
public static function end_cache($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['cache_time'] += microtime(true) - self::$template_data[$key]['start_time'];
|
||||
}
|
||||
/**
|
||||
* Opens a window for the Smarty Debugging Consol and display the data
|
||||
*/
|
||||
public static function display_debug($obj)
|
||||
{
|
||||
// prepare information of assigned variables
|
||||
$ptr = $obj;
|
||||
while (isset($ptr->parent)) {
|
||||
$ptr = $ptr->parent;
|
||||
}
|
||||
if ($obj instanceof Smarty) {
|
||||
$smarty = $obj;
|
||||
} else {
|
||||
$smarty = $obj->smarty;
|
||||
}
|
||||
$_assigned_vars = $ptr->tpl_vars;
|
||||
ksort($_assigned_vars);
|
||||
$_config_vars = $ptr->config_vars;
|
||||
ksort($_config_vars);
|
||||
$ldelim = $smarty->left_delimiter;
|
||||
$rdelim = $smarty->right_delimiter;
|
||||
$smarty->left_delimiter = '{';
|
||||
$smarty->right_delimiter = '}';
|
||||
$_template = new Smarty_Internal_Template ($smarty->debug_tpl, $smarty);
|
||||
$_template->caching = false;
|
||||
$_template->force_compile = false;
|
||||
$_template->disableSecurity();
|
||||
$_template->cache_id = null;
|
||||
$_template->compile_id = null;
|
||||
$_template->assign('template_data', self::$template_data);
|
||||
$_template->assign('assigned_vars', $_assigned_vars);
|
||||
$_template->assign('config_vars', $_config_vars);
|
||||
$_template->assign('execution_time', microtime(true) - $smarty->start_time);
|
||||
echo $smarty->fetch($_template);
|
||||
$smarty->left_delimiter = $ldelim;
|
||||
$smarty->right_delimiter = $rdelim;
|
||||
}
|
||||
/**
|
||||
* End logging of cache time
|
||||
*/
|
||||
public static function end_cache($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['cache_time'] += microtime(true) - self::$template_data[$key]['start_time'];
|
||||
}
|
||||
/**
|
||||
* Opens a window for the Smarty Debugging Consol and display the data
|
||||
*/
|
||||
public static function display_debug($obj)
|
||||
{
|
||||
// prepare information of assigned variables
|
||||
$ptr = self::get_debug_vars($obj);
|
||||
if ($obj instanceof Smarty) {
|
||||
$smarty = $obj;
|
||||
} else {
|
||||
$smarty = $obj->smarty;
|
||||
}
|
||||
$_assigned_vars = $ptr->tpl_vars;
|
||||
ksort($_assigned_vars);
|
||||
$_config_vars = $ptr->config_vars;
|
||||
ksort($_config_vars);
|
||||
$ldelim = $smarty->left_delimiter;
|
||||
$rdelim = $smarty->right_delimiter;
|
||||
$smarty->left_delimiter = '{';
|
||||
$smarty->right_delimiter = '}';
|
||||
$_template = new Smarty_Internal_Template ($smarty->debug_tpl, $smarty);
|
||||
$_template->caching = false;
|
||||
$_template->force_compile = false;
|
||||
$_template->disableSecurity();
|
||||
$_template->cache_id = null;
|
||||
$_template->compile_id = null;
|
||||
if ($obj instanceof Smarty_Internal_Template) {
|
||||
$_template->assign('template_name',$obj->resource_type.':'.$obj->resource_name);
|
||||
}
|
||||
if ($obj instanceof Smarty) {
|
||||
$_template->assign('template_data', self::$template_data);
|
||||
} else {
|
||||
$_template->assign('template_data', null);
|
||||
}
|
||||
$_template->assign('assigned_vars', $_assigned_vars);
|
||||
$_template->assign('config_vars', $_config_vars);
|
||||
$_template->assign('execution_time', microtime(true) - $smarty->start_time);
|
||||
echo $_template->getRenderedTemplate();
|
||||
$smarty->left_delimiter = $ldelim;
|
||||
$smarty->right_delimiter = $rdelim;
|
||||
}
|
||||
/*
|
||||
* Recursively gets variables from all template/data scopes
|
||||
*/
|
||||
public static function get_debug_vars($obj)
|
||||
{
|
||||
$config_vars = $obj->config_vars;
|
||||
$tpl_vars = array();
|
||||
foreach ($obj->tpl_vars as $key => $var) {
|
||||
$tpl_vars[$key] = clone $var;
|
||||
if ($obj instanceof Smarty_Internal_Template) {
|
||||
$tpl_vars[$key]->scope = $obj->resource_type.':'.$obj->resource_name;
|
||||
} elseif ($obj instanceof Smarty_Data) {
|
||||
$tpl_vars[$key]->scope = 'Data object';
|
||||
} else {
|
||||
$tpl_vars[$key]->scope = 'Smarty root';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get_key
|
||||
*/
|
||||
static function get_key($template)
|
||||
{
|
||||
// calculate Uid if not already done
|
||||
if ($template->templateUid == '') {
|
||||
$template->getTemplateFilepath();
|
||||
}
|
||||
$key = $template->templateUid;
|
||||
if (isset(self::$template_data[$key])) {
|
||||
return $key;
|
||||
} else {
|
||||
self::$template_data[$key]['name'] = $template->getTemplateFilepath();
|
||||
self::$template_data[$key]['compile_time'] = 0;
|
||||
self::$template_data[$key]['render_time'] = 0;
|
||||
self::$template_data[$key]['cache_time'] = 0;
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($obj->parent)) {
|
||||
$parent = self::get_debug_vars($obj->parent);
|
||||
$tpl_vars = array_merge($parent->tpl_vars, $tpl_vars);
|
||||
$config_vars = array_merge($parent->config_vars, $config_vars);
|
||||
} else {
|
||||
foreach (Smarty::$global_tpl_vars as $name => $var) {
|
||||
if (!array_key_exists($name, $tpl_vars)) {
|
||||
$clone = clone $var;
|
||||
$clone->scope = 'Global';
|
||||
$tpl_vars[$name] = $clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (object) array('tpl_vars' => $tpl_vars, 'config_vars' => $config_vars);
|
||||
}
|
||||
|
||||
/**
|
||||
* get_key
|
||||
*/
|
||||
static function get_key($template)
|
||||
{
|
||||
// calculate Uid if not already done
|
||||
if ($template->templateUid == '') {
|
||||
$template->getTemplateFilepath();
|
||||
}
|
||||
$key = $template->templateUid;
|
||||
if (isset(self::$template_data[$key])) {
|
||||
return $key;
|
||||
} else {
|
||||
self::$template_data[$key]['name'] = $template->getTemplateFilepath();
|
||||
self::$template_data[$key]['compile_time'] = 0;
|
||||
self::$template_data[$key]['render_time'] = 0;
|
||||
self::$template_data[$key]['cache_time'] = 0;
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty read include path plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Monte Ohrt
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Read Include Path Class
|
||||
*/
|
||||
class Smarty_Internal_Get_Include_Path {
|
||||
/**
|
||||
* Return full file path from PHP include_path
|
||||
*
|
||||
* @param string $filepath filepath
|
||||
* @return mixed full filepath or false
|
||||
*/
|
||||
public static function getIncludePath($filepath)
|
||||
{
|
||||
static $_path_array = null;
|
||||
|
||||
if(!isset($_path_array)) {
|
||||
$_ini_include_path = ini_get('include_path');
|
||||
|
||||
if(strstr($_ini_include_path,';')) {
|
||||
// windows pathnames
|
||||
$_path_array = explode(';',$_ini_include_path);
|
||||
} else {
|
||||
$_path_array = explode(':',$_ini_include_path);
|
||||
}
|
||||
}
|
||||
foreach ($_path_array as $_include_path) {
|
||||
if (file_exists($_include_path . DS . $filepath)) {
|
||||
return $_include_path . DS . $filepath;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue