upgrade smarty to 3.1.19
parent
52885f20e0
commit
b58f365473
File diff suppressed because it is too large
Load Diff
@ -1,460 +1,467 @@
|
||||
<?php
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: SmartyBC.class.php
|
||||
* SVN: $Id: $
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @copyright 2008 New Digital Group, Inc.
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
*/
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require(dirname(__FILE__) . '/Smarty.class.php');
|
||||
|
||||
/**
|
||||
* Smarty Backward Compatability Wrapper Class
|
||||
*
|
||||
* @package Smarty
|
||||
*/
|
||||
class SmartyBC extends Smarty {
|
||||
|
||||
/**
|
||||
* Smarty 2 BC
|
||||
* @var string
|
||||
*/
|
||||
public $_version = self::SMARTY_VERSION;
|
||||
|
||||
/**
|
||||
* Initialize new SmartyBC object
|
||||
*
|
||||
* @param array $options options to set during initialization, e.g. array( 'forceCompile' => false )
|
||||
*/
|
||||
public function __construct(array $options=array())
|
||||
{
|
||||
parent::__construct($options);
|
||||
// register {php} tag
|
||||
$this->registerPlugin('block', 'php', 'smarty_php_tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for assign_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to assign
|
||||
*/
|
||||
public function assign_by_ref($tpl_var, &$value)
|
||||
{
|
||||
$this->assignByRef($tpl_var, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for append_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
*/
|
||||
public function append_by_ref($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
$this->appendByRef($tpl_var, $value, $merge);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the given assigned template variable.
|
||||
*
|
||||
* @param string $tpl_var the template variable to clear
|
||||
*/
|
||||
public function clear_assign($tpl_var)
|
||||
{
|
||||
$this->clearAssign($tpl_var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers custom function to be used in templates
|
||||
*
|
||||
* @param string $function the name of the template function
|
||||
* @param string $function_impl the name of the PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
|
||||
{
|
||||
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters custom function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('function', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @param string $object name of template object
|
||||
* @param object $object_impl the referenced PHP object to register
|
||||
* @param array $allowed list of allowed methods (empty = all)
|
||||
* @param boolean $smarty_args smarty argument format, else traditional
|
||||
* @param array $block_functs list of methods that are block format
|
||||
*/
|
||||
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
|
||||
{
|
||||
settype($allowed, 'array');
|
||||
settype($smarty_args, 'boolean');
|
||||
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters object
|
||||
*
|
||||
* @param string $object name of template object
|
||||
*/
|
||||
public function unregister_object($object)
|
||||
{
|
||||
$this->unregisterObject($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers block function to be used in templates
|
||||
*
|
||||
* @param string $block name of template block
|
||||
* @param string $block_impl PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
|
||||
{
|
||||
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters block function
|
||||
*
|
||||
* @param string $block name of template function
|
||||
*/
|
||||
public function unregister_block($block)
|
||||
{
|
||||
$this->unregisterPlugin('block', $block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
* @param string $function_impl name of PHP function to register
|
||||
* @param bool $cacheable
|
||||
*/
|
||||
public function register_compiler_function($function, $function_impl, $cacheable=true)
|
||||
{
|
||||
$this->registerPlugin('compiler', $function, $function_impl, $cacheable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_compiler_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('compiler', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers modifier to be used in templates
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
* @param string $modifier_impl name of PHP function to register
|
||||
*/
|
||||
public function register_modifier($modifier, $modifier_impl)
|
||||
{
|
||||
$this->registerPlugin('modifier', $modifier, $modifier_impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters modifier
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
*/
|
||||
public function unregister_modifier($modifier)
|
||||
{
|
||||
$this->unregisterPlugin('modifier', $modifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @param string $type name of resource
|
||||
* @param array $functions array of functions to handle resource
|
||||
*/
|
||||
public function register_resource($type, $functions)
|
||||
{
|
||||
$this->registerResource($type, $functions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a resource
|
||||
*
|
||||
* @param string $type name of resource
|
||||
*/
|
||||
public function unregister_resource($type)
|
||||
{
|
||||
$this->unregisterResource($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a prefilter function to apply
|
||||
* to a template before compiling
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_prefilter($function)
|
||||
{
|
||||
$this->registerFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a prefilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_prefilter($function)
|
||||
{
|
||||
$this->unregisterFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a postfilter function to apply
|
||||
* to a compiled template after compilation
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_postfilter($function)
|
||||
{
|
||||
$this->registerFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a postfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_postfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an output filter function to apply
|
||||
* to a template output
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_outputfilter($function)
|
||||
{
|
||||
$this->registerFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters an outputfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_outputfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* load a filter of specified type and name
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
*/
|
||||
public function load_filter($type, $name)
|
||||
{
|
||||
$this->loadFilter($type, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear cached content for the given template and cache id
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id name of cache_id
|
||||
* @param string $compile_id name of compile_id
|
||||
* @param string $exp_time expiration time
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the entire contents of cache (all templates)
|
||||
*
|
||||
* @param string $exp_time expire time
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_all_cache($exp_time = null)
|
||||
{
|
||||
return $this->clearCache(null, null, null, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* test to see if valid cache exists for this template
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id
|
||||
* @param string $compile_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_cached($tpl_file, $cache_id = null, $compile_id = null)
|
||||
{
|
||||
return $this->isCached($tpl_file, $cache_id, $compile_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all the assigned template variables.
|
||||
*/
|
||||
public function clear_all_assign()
|
||||
{
|
||||
$this->clearAllAssign();
|
||||
}
|
||||
|
||||
/**
|
||||
* clears compiled version of specified template resource,
|
||||
* or all compiled template files if one is not specified.
|
||||
* This function is for advanced use only, not normally needed.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @param string $compile_id
|
||||
* @param string $exp_time
|
||||
* @return boolean results of {@link smarty_core_rm_auto()}
|
||||
*/
|
||||
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether requested template exists.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @return boolean
|
||||
*/
|
||||
public function template_exists($tpl_file)
|
||||
{
|
||||
return $this->templateExists($tpl_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing template variables
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function get_template_vars($name=null)
|
||||
{
|
||||
return $this->getTemplateVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing config variables
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function get_config_vars($name=null)
|
||||
{
|
||||
return $this->getConfigVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* load configuration values
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $section
|
||||
* @param string $scope
|
||||
*/
|
||||
public function config_load($file, $section = null, $scope = 'global')
|
||||
{
|
||||
$this->ConfigLoad($file, $section, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @param string $name
|
||||
* @return object
|
||||
*/
|
||||
public function get_registered_object($name)
|
||||
{
|
||||
return $this->getRegisteredObject($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear configuration values
|
||||
*
|
||||
* @param string $var
|
||||
*/
|
||||
public function clear_config($var = null)
|
||||
{
|
||||
$this->clearConfig($var);
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger Smarty error
|
||||
*
|
||||
* @param string $error_msg
|
||||
* @param integer $error_type
|
||||
*/
|
||||
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||
{
|
||||
trigger_error("Smarty error: $error_msg", $error_type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty {php}{/php} block function
|
||||
*
|
||||
* @param array $params parameter list
|
||||
* @param string $content contents of the block
|
||||
* @param object $template template object
|
||||
* @param boolean &$repeat repeat flag
|
||||
* @return string content re-formatted
|
||||
*/
|
||||
function smarty_php_tag($params, $content, $template, &$repeat)
|
||||
{
|
||||
eval($content);
|
||||
return '';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: SmartyBC.class.php
|
||||
* SVN: $Id: $
|
||||
* 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
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @copyright 2008 New Digital Group, Inc.
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
*/
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(dirname(__FILE__) . '/Smarty.class.php');
|
||||
|
||||
/**
|
||||
* Smarty Backward Compatability Wrapper Class
|
||||
*
|
||||
* @package Smarty
|
||||
*/
|
||||
class SmartyBC extends Smarty
|
||||
{
|
||||
/**
|
||||
* Smarty 2 BC
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_version = self::SMARTY_VERSION;
|
||||
|
||||
/**
|
||||
* Initialize new SmartyBC object
|
||||
*
|
||||
* @param array $options options to set during initialization, e.g. array( 'forceCompile' => false )
|
||||
*/
|
||||
public function __construct(array $options = array())
|
||||
{
|
||||
parent::__construct($options);
|
||||
// register {php} tag
|
||||
$this->registerPlugin('block', 'php', 'smarty_php_tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for assign_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to assign
|
||||
*/
|
||||
public function assign_by_ref($tpl_var, &$value)
|
||||
{
|
||||
$this->assignByRef($tpl_var, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for append_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
*/
|
||||
public function append_by_ref($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
$this->appendByRef($tpl_var, $value, $merge);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the given assigned template variable.
|
||||
*
|
||||
* @param string $tpl_var the template variable to clear
|
||||
*/
|
||||
public function clear_assign($tpl_var)
|
||||
{
|
||||
$this->clearAssign($tpl_var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers custom function to be used in templates
|
||||
*
|
||||
* @param string $function the name of the template function
|
||||
* @param string $function_impl the name of the PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null)
|
||||
{
|
||||
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters custom function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('function', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @param string $object name of template object
|
||||
* @param object $object_impl the referenced PHP object to register
|
||||
* @param array $allowed list of allowed methods (empty = all)
|
||||
* @param boolean $smarty_args smarty argument format, else traditional
|
||||
* @param array $block_methods list of methods that are block format
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @internal param array $block_functs list of methods that are block format
|
||||
*/
|
||||
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
|
||||
{
|
||||
settype($allowed, 'array');
|
||||
settype($smarty_args, 'boolean');
|
||||
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters object
|
||||
*
|
||||
* @param string $object name of template object
|
||||
*/
|
||||
public function unregister_object($object)
|
||||
{
|
||||
$this->unregisterObject($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers block function to be used in templates
|
||||
*
|
||||
* @param string $block name of template block
|
||||
* @param string $block_impl PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null)
|
||||
{
|
||||
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters block function
|
||||
*
|
||||
* @param string $block name of template function
|
||||
*/
|
||||
public function unregister_block($block)
|
||||
{
|
||||
$this->unregisterPlugin('block', $block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
* @param string $function_impl name of PHP function to register
|
||||
* @param bool $cacheable
|
||||
*/
|
||||
public function register_compiler_function($function, $function_impl, $cacheable = true)
|
||||
{
|
||||
$this->registerPlugin('compiler', $function, $function_impl, $cacheable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_compiler_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('compiler', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers modifier to be used in templates
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
* @param string $modifier_impl name of PHP function to register
|
||||
*/
|
||||
public function register_modifier($modifier, $modifier_impl)
|
||||
{
|
||||
$this->registerPlugin('modifier', $modifier, $modifier_impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters modifier
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
*/
|
||||
public function unregister_modifier($modifier)
|
||||
{
|
||||
$this->unregisterPlugin('modifier', $modifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @param string $type name of resource
|
||||
* @param array $functions array of functions to handle resource
|
||||
*/
|
||||
public function register_resource($type, $functions)
|
||||
{
|
||||
$this->registerResource($type, $functions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a resource
|
||||
*
|
||||
* @param string $type name of resource
|
||||
*/
|
||||
public function unregister_resource($type)
|
||||
{
|
||||
$this->unregisterResource($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a prefilter function to apply
|
||||
* to a template before compiling
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_prefilter($function)
|
||||
{
|
||||
$this->registerFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a prefilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_prefilter($function)
|
||||
{
|
||||
$this->unregisterFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a postfilter function to apply
|
||||
* to a compiled template after compilation
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_postfilter($function)
|
||||
{
|
||||
$this->registerFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a postfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_postfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an output filter function to apply
|
||||
* to a template output
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_outputfilter($function)
|
||||
{
|
||||
$this->registerFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters an outputfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_outputfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* load a filter of specified type and name
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
*/
|
||||
public function load_filter($type, $name)
|
||||
{
|
||||
$this->loadFilter($type, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear cached content for the given template and cache id
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id name of cache_id
|
||||
* @param string $compile_id name of compile_id
|
||||
* @param string $exp_time expiration time
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the entire contents of cache (all templates)
|
||||
*
|
||||
* @param string $exp_time expire time
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_all_cache($exp_time = null)
|
||||
{
|
||||
return $this->clearCache(null, null, null, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* test to see if valid cache exists for this template
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id
|
||||
* @param string $compile_id
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_cached($tpl_file, $cache_id = null, $compile_id = null)
|
||||
{
|
||||
return $this->isCached($tpl_file, $cache_id, $compile_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all the assigned template variables.
|
||||
*/
|
||||
public function clear_all_assign()
|
||||
{
|
||||
$this->clearAllAssign();
|
||||
}
|
||||
|
||||
/**
|
||||
* clears compiled version of specified template resource,
|
||||
* or all compiled template files if one is not specified.
|
||||
* This function is for advanced use only, not normally needed.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @param string $compile_id
|
||||
* @param string $exp_time
|
||||
*
|
||||
* @return boolean results of {@link smarty_core_rm_auto()}
|
||||
*/
|
||||
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether requested template exists.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function template_exists($tpl_file)
|
||||
{
|
||||
return $this->templateExists($tpl_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing template variables
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_template_vars($name = null)
|
||||
{
|
||||
return $this->getTemplateVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing config variables
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_config_vars($name = null)
|
||||
{
|
||||
return $this->getConfigVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* load configuration values
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $section
|
||||
* @param string $scope
|
||||
*/
|
||||
public function config_load($file, $section = null, $scope = 'global')
|
||||
{
|
||||
$this->ConfigLoad($file, $section, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function get_registered_object($name)
|
||||
{
|
||||
return $this->getRegisteredObject($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear configuration values
|
||||
*
|
||||
* @param string $var
|
||||
*/
|
||||
public function clear_config($var = null)
|
||||
{
|
||||
$this->clearConfig($var);
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger Smarty error
|
||||
*
|
||||
* @param string $error_msg
|
||||
* @param integer $error_type
|
||||
*/
|
||||
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||
{
|
||||
trigger_error("Smarty error: $error_msg", $error_type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty {php}{/php} block function
|
||||
*
|
||||
* @param array $params parameter list
|
||||
* @param string $content contents of the block
|
||||
* @param object $template template object
|
||||
* @param boolean &$repeat repeat flag
|
||||
*
|
||||
* @return string content re-formatted
|
||||
*/
|
||||
function smarty_php_tag($params, $content, $template, &$repeat)
|
||||
{
|
||||
eval($content);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
@ -1,133 +1,137 @@
|
||||
{capture name='_smarty_debug' assign=debug_output}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Smarty Debug Console</title>
|
||||
<style type="text/css">
|
||||
{literal}
|
||||
body, h1, h2, td, th, p {
|
||||
font-family: sans-serif;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
margin: 1px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
text-align: left;
|
||||
padding: 2px;
|
||||
background-color: #f0c040;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background-color: #9B410E;
|
||||
color: white;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 2px;
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
|
||||
body {
|
||||
background: black;
|
||||
}
|
||||
|
||||
p, table, div {
|
||||
background: #f0ead8;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
th, td {
|
||||
font-family: monospace;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
td {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.odd {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.even {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.exectime {
|
||||
font-size: 0.8em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#table_assigned_vars th {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
#table_config_vars th {
|
||||
color: maroon;
|
||||
}
|
||||
{/literal}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var nofilter}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||
|
||||
{if !empty($template_data)}
|
||||
<h2>included templates & config files (load time in seconds)</h2>
|
||||
|
||||
<div>
|
||||
{foreach $template_data as $template}
|
||||
<font color=brown>{$template.name}</font>
|
||||
<span class="exectime">
|
||||
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Smarty Debug Console</title>
|
||||
<style type="text/css">
|
||||
{literal}
|
||||
body, h1, h2, td, th, p {
|
||||
font-family: sans-serif;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
margin: 1px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
text-align: left;
|
||||
padding: 2px;
|
||||
background-color: #f0c040;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background-color: #9B410E;
|
||||
color: white;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 2px;
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
|
||||
body {
|
||||
background: black;
|
||||
}
|
||||
|
||||
p, table, div {
|
||||
background: #f0ead8;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
th, td {
|
||||
font-family: monospace;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
td {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.odd {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.even {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.exectime {
|
||||
font-size: 0.8em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#table_assigned_vars th {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
#table_config_vars th {
|
||||
color: maroon;
|
||||
}
|
||||
|
||||
{/literal}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Smarty Debug Console
|
||||
- {if isset($template_name)}{$template_name|debug_print_var nofilter}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||
|
||||
{if !empty($template_data)}
|
||||
<h2>included templates & config files (load time in seconds)</h2>
|
||||
<div>
|
||||
{foreach $template_data as $template}
|
||||
<font color=brown>{$template.name}</font>
|
||||
<span class="exectime">
|
||||
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}
|
||||
)
|
||||
</span>
|
||||
<br>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<h2>assigned template variables</h2>
|
||||
|
||||
<table id="table_assigned_vars">
|
||||
{foreach $assigned_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<th>${$vars@key|escape:'html'}</th>
|
||||
<td>{$vars|debug_print_var nofilter}</td></tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
<h2>assigned config file variables (outer template scope)</h2>
|
||||
|
||||
<table id="table_config_vars">
|
||||
{foreach $config_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<th>{$vars@key|escape:'html'}</th>
|
||||
<td>{$vars|debug_print_var nofilter}</td></tr>
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
<br>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<h2>assigned template variables</h2>
|
||||
|
||||
<table id="table_assigned_vars">
|
||||
{foreach $assigned_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<th>${$vars@key|escape:'html'}</th>
|
||||
<td>{$vars|debug_print_var nofilter}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
<h2>assigned config file variables (outer template scope)</h2>
|
||||
|
||||
<table id="table_config_vars">
|
||||
{foreach $config_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<th>{$vars@key|escape:'html'}</th>
|
||||
<td>{$vars|debug_print_var nofilter}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
{/capture}
|
||||
<script type="text/javascript">
|
||||
{$id = $template_name|default:''|md5}
|
||||
_smarty_console = window.open("","console{$id}","width=680,height=600,resizable,scrollbars=yes");
|
||||
{$id = $template_name|default:''|md5}
|
||||
_smarty_console = window.open("", "console{$id}", "width=680,height=600,resizable,scrollbars=yes");
|
||||
_smarty_console.document.write("{$debug_output|escape:'javascript' nofilter}");
|
||||
_smarty_console.document.close();
|
||||
</script>
|
||||
|
@ -1,87 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* This plugin is only for Smarty2 BC
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {math} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: math<br>
|
||||
* Purpose: handle math computations in template
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
|
||||
* (Smarty online manual)
|
||||
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function smarty_function_math($params, $template)
|
||||
{
|
||||
static $_allowed_funcs = array(
|
||||
'int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
|
||||
'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true,
|
||||
'rand' => true, 'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true ,'tan' => true
|
||||
'int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
|
||||
'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true,
|
||||
'rand' => true, 'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true, 'tan' => true
|
||||
);
|
||||
// be sure equation parameter is present
|
||||
if (empty($params['equation'])) {
|
||||
trigger_error("math: missing equation parameter",E_USER_WARNING);
|
||||
trigger_error("math: missing equation parameter", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$equation = $params['equation'];
|
||||
|
||||
// make sure parenthesis are balanced
|
||||
if (substr_count($equation,"(") != substr_count($equation,")")) {
|
||||
trigger_error("math: unbalanced parenthesis",E_USER_WARNING);
|
||||
if (substr_count($equation, "(") != substr_count($equation, ")")) {
|
||||
trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// match all vars in equation, make sure all are passed
|
||||
preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match);
|
||||
preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!", $equation, $match);
|
||||
|
||||
foreach($match[1] as $curr_var) {
|
||||
foreach ($match[1] as $curr_var) {
|
||||
if ($curr_var && !isset($params[$curr_var]) && !isset($_allowed_funcs[$curr_var])) {
|
||||
trigger_error("math: function call $curr_var not allowed",E_USER_WARNING);
|
||||
trigger_error("math: function call $curr_var not allowed", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($params as $key => $val) {
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key != "equation" && $key != "format" && $key != "assign") {
|
||||
// make sure value is not empty
|
||||
if (strlen($val)==0) {
|
||||
trigger_error("math: parameter $key is empty",E_USER_WARNING);
|
||||
if (strlen($val) == 0) {
|
||||
trigger_error("math: parameter $key is empty", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
if (!is_numeric($val)) {
|
||||
trigger_error("math: parameter $key: is not numeric",E_USER_WARNING);
|
||||
trigger_error("math: parameter $key: is not numeric", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
|
||||
}
|
||||
}
|
||||
$smarty_math_result = null;
|
||||
eval("\$smarty_math_result = ".$equation.";");
|
||||
eval("\$smarty_math_result = " . $equation . ";");
|
||||
|
||||
if (empty($params['format'])) {
|
||||
if (empty($params['assign'])) {
|
||||
return $smarty_math_result;
|
||||
} else {
|
||||
$template->assign($params['assign'],$smarty_math_result);
|
||||
$template->assign($params['assign'], $smarty_math_result);
|
||||
}
|
||||
} else {
|
||||
if (empty($params['assign'])){
|
||||
printf($params['format'],$smarty_math_result);
|
||||
if (empty($params['assign'])) {
|
||||
printf($params['format'], $smarty_math_result);
|
||||
} else {
|
||||
$template->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
|
||||
$template->assign($params['assign'], sprintf($params['format'], $smarty_math_result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,33 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty replace modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: replace<br>
|
||||
* Purpose: simple search/replace
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param string $search text to search for
|
||||
* @param string $replace replacement text
|
||||
* @return string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_replace($string, $search, $replace)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
|
||||
return smarty_mb_str_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
return str_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
?>
|
||||
return str_replace($search, $replace, $string);
|
||||
}
|
||||
|
@ -1,27 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty spacify modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: spacify<br>
|
||||
* Purpose: add spaces between characters in a string
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param string $spacify_char string to insert between characters.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||
{
|
||||
// well… what about charsets besides latin and UTF-8?
|
||||
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||
}
|
||||
|
||||
?>
|
||||
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY));
|
||||
}
|
||||
|
@ -1,30 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty cat modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: cat<br>
|
||||
* Date: Feb 24, 2003<br>
|
||||
* Purpose: catenate a value to a variable<br>
|
||||
* Input: string to catenate<br>
|
||||
* Example: {$var|cat:"foo"}
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_cat($params, $compiler)
|
||||
{
|
||||
return '('.implode(').(', $params).')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty cat modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: cat<br>
|
||||
* Date: Feb 24, 2003<br>
|
||||
* Purpose: catenate a value to a variable<br>
|
||||
* Input: string to catenate<br>
|
||||
* Example: {$var|cat:"foo"}
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_cat($params)
|
||||
{
|
||||
return '(' . implode(').(', $params) . ')';
|
||||
}
|
||||
|
@ -1,33 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_characters modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_characteres<br>
|
||||
* Purpose: count the number of characters in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_characters($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1]) || $params[1] != 'true') {
|
||||
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)';
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strlen(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strlen(' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_characters modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: count_characteres<br>
|
||||
* Purpose: count the number of characters in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_characters($params)
|
||||
{
|
||||
if (!isset($params[1]) || $params[1] != 'true') {
|
||||
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)';
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strlen(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strlen(' . $params[0] . ')';
|
||||
}
|
||||
|
@ -1,28 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_paragraphs modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_paragraphs<br>
|
||||
* Purpose: count the number of paragraphs in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_paragraphs (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_paragraphs($params, $compiler)
|
||||
{
|
||||
// count \r or \n characters
|
||||
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_paragraphs modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: count_paragraphs<br>
|
||||
* Purpose: count the number of paragraphs in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_paragraphs (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_paragraphs($params)
|
||||
{
|
||||
// count \r or \n characters
|
||||
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)';
|
||||
}
|
||||
|
@ -1,28 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_sentences modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_sentences
|
||||
* Purpose: count the number of sentences in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_sentences (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_sentences($params, $compiler)
|
||||
{
|
||||
// find periods, question marks, exclamation marks with a word before but not after.
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_sentences modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: count_sentences
|
||||
* Purpose: count the number of sentences in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_sentences (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_sentences($params)
|
||||
{
|
||||
// find periods, question marks, exclamation marks with a word before but not after.
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';
|
||||
}
|
||||
|
@ -1,32 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_words modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_words<br>
|
||||
* Purpose: count the number of words in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_words($params, $compiler)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'str_word_count(' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_words modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: count_words<br>
|
||||
* Purpose: count the number of words in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_words($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'str_word_count(' . $params[0] . ')';
|
||||
}
|
||||
|
@ -1,35 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty default modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: default<br>
|
||||
* Purpose: designate default value for empty variables
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_default ($params, $compiler)
|
||||
{
|
||||
$output = $params[0];
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "''";
|
||||
}
|
||||
|
||||
array_shift($params);
|
||||
foreach ($params as $param) {
|
||||
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty default modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: default<br>
|
||||
* Purpose: designate default value for empty variables
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_default($params)
|
||||
{
|
||||
$output = $params[0];
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "''";
|
||||
}
|
||||
|
||||
array_shift($params);
|
||||
foreach ($params as $param) {
|
||||
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
@ -1,125 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once( SMARTY_PLUGINS_DIR .'shared.literal_compiler_param.php' );
|
||||
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: escape<br>
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||
* @author Rodney Rehm
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, $compiler)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
|
||||
try {
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||
$double_encode = smarty_literal_compiler_param($params, 3, true);
|
||||
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
return 'htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
} else if ($double_encode) {
|
||||
return 'htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else if ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
}
|
||||
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'htmlentities('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
} else if ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'htmlentities('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
|
||||
case 'url':
|
||||
return 'rawurlencode(' . $params[0] . ')';
|
||||
|
||||
case 'urlpathinfo':
|
||||
return 'str_replace("%2F", "/", rawurlencode(' . $params[0] . '))';
|
||||
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[0] . ')';
|
||||
|
||||
case 'javascript':
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
return 'strtr(' . $params[0] . ', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
||||
|
||||
}
|
||||
} catch(SmartyException $e) {
|
||||
// pass through to regular plugin fallback
|
||||
}
|
||||
|
||||
// could not optimize |escape call, so fallback to regular plugin
|
||||
if ($compiler->tag_nocache | $compiler->nocache) {
|
||||
$compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
|
||||
$compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||
} else {
|
||||
$compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
|
||||
$compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||
}
|
||||
return 'smarty_modifier_escape(' . join( ', ', $params ) . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
|
||||
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: escape<br>
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, $compiler)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
|
||||
try {
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||
$double_encode = smarty_literal_compiler_param($params, 3, true);
|
||||
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
return 'htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
return 'htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
}
|
||||
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'htmlentities('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'htmlentities('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
|
||||
case 'url':
|
||||
return 'rawurlencode(' . $params[0] . ')';
|
||||
|
||||
case 'urlpathinfo':
|
||||
return 'str_replace("%2F", "/", rawurlencode(' . $params[0] . '))';
|
||||
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[0] . ')';
|
||||
|
||||
case 'javascript':
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
return 'strtr(' . $params[0] . ', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
||||
}
|
||||
}
|
||||
catch (SmartyException $e) {
|
||||
// pass through to regular plugin fallback
|
||||
}
|
||||
|
||||
// could not optimize |escape call, so fallback to regular plugin
|
||||
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
|
||||
$compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||
} else {
|
||||
$compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||
}
|
||||
|
||||
return 'smarty_modifier_escape(' . join(', ', $params) . ')';
|
||||
}
|
||||
|
@ -1,34 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty from_charset modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: from_charset<br>
|
||||
* Purpose: convert character encoding from $charset to internal encoding
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_from_charset($params, $compiler)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
}
|
||||
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
}
|
||||
|
||||
return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty from_charset modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: from_charset<br>
|
||||
* Purpose: convert character encoding from $charset to internal encoding
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_from_charset($params)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
}
|
||||
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
}
|
||||
|
||||
return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')';
|
||||
}
|
||||
|
@ -1,32 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty indent modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: indent<br>
|
||||
* Purpose: indent lines of text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_indent($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 4;
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = "' '";
|
||||
}
|
||||
return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty indent modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: indent<br>
|
||||
* Purpose: indent lines of text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_indent($params)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 4;
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = "' '";
|
||||
}
|
||||
|
||||
return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')';
|
||||
}
|
||||
|
@ -1,31 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty lower modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: lower<br>
|
||||
* Purpose: convert string to lowercase
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_lower($params, $compiler)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ;
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtolower(' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty lower modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: lower<br>
|
||||
* Purpose: convert string to lowercase
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_lower($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtolower(' . $params[0] . ')';
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty noprint modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: noprint<br>
|
||||
* Purpose: return an empty string
|
||||
*
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_noprint($params, $compiler)
|
||||
{
|
||||
return "''";
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty noprint modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: noprint<br>
|
||||
* Purpose: return an empty string
|
||||
*
|
||||
* @author Uwe Tews
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_noprint()
|
||||
{
|
||||
return "''";
|
||||
}
|
||||
|
@ -1,26 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty string_format modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: string_format<br>
|
||||
* Purpose: format strings via sprintf
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_string_format($params, $compiler)
|
||||
{
|
||||
return 'sprintf(' . $params[1] . ',' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty string_format modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: string_format<br>
|
||||
* Purpose: format strings via sprintf
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_string_format($params)
|
||||
{
|
||||
return 'sprintf(' . $params[1] . ',' . $params[0] . ')';
|
||||
}
|
||||
|
@ -1,33 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty strip modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: strip<br>
|
||||
* Purpose: Replace all repeated spaces, newlines, tabs
|
||||
* with a single space or supplied replacement string.<br>
|
||||
* Example: {$var|strip} {$var|strip:" "}<br>
|
||||
* Date: September 25th, 2002
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_strip($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "' '";
|
||||
}
|
||||
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty strip modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: strip<br>
|
||||
* Purpose: Replace all repeated spaces, newlines, tabs
|
||||
* with a single space or supplied replacement string.<br>
|
||||
* Example: {$var|strip} {$var|strip:" "}<br>
|
||||
* Date: September 25th, 2002
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_strip($params)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "' '";
|
||||
}
|
||||
|
||||
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||
}
|
||||
|
@ -1,33 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty strip_tags modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: strip_tags<br>
|
||||
* Purpose: strip html tags from text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_strip_tags($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = true;
|
||||
}
|
||||
if ($params[1] === true) {
|
||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
||||
} else {
|
||||
return 'strip_tags(' . $params[0] . ')';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty strip_tags modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: strip_tags<br>
|
||||
* Purpose: strip html tags from text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_strip_tags($params)
|
||||
{
|
||||
if (!isset($params[1]) || $params[1] === true || trim($params[1], '"') == 'true') {
|
||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
||||
} else {
|
||||
return 'strip_tags(' . $params[0] . ')';
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty to_charset modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: to_charset<br>
|
||||
* Purpose: convert character encoding from internal encoding to $charset
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_to_charset($params, $compiler)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
}
|
||||
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
}
|
||||
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty to_charset modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: to_charset<br>
|
||||
* Purpose: convert character encoding from internal encoding to $charset
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_to_charset($params)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
}
|
||||
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
}
|
||||
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
|
||||
}
|
||||
|
@ -1,51 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty unescape modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: unescape<br>
|
||||
* Purpose: unescape html entities
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_unescape($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 'html';
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
} else {
|
||||
$params[2] = "'" . $params[2] . "'";
|
||||
}
|
||||
|
||||
switch (trim($params[1], '"\'')) {
|
||||
case 'entity':
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
|
||||
}
|
||||
|
||||
return 'html_entity_decode(' . $params[0] . ', ENT_NOQUOTES, ' . $params[2] . ')';
|
||||
|
||||
case 'html':
|
||||
return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)';
|
||||
|
||||
case 'url':
|
||||
return 'rawurldecode(' . $params[0] . ')';
|
||||
|
||||
default:
|
||||
return $params[0];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty unescape modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: unescape<br>
|
||||
* Purpose: unescape html entities
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_unescape($params)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 'html';
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
} else {
|
||||
$params[2] = "'" . $params[2] . "'";
|
||||
}
|
||||
|
||||
switch (trim($params[1], '"\'')) {
|
||||
case 'entity':
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
|
||||
}
|
||||
|
||||
return 'html_entity_decode(' . $params[0] . ', ENT_NOQUOTES, ' . $params[2] . ')';
|
||||
|
||||
case 'html':
|
||||
return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)';
|
||||
|
||||
case 'url':
|
||||
return 'rawurldecode(' . $params[0] . ')';
|
||||
|
||||
default:
|
||||
return $params[0];
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty upper modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: lower<br>
|
||||
* Purpose: convert string to uppercase
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_upper($params, $compiler)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ;
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtoupper(' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty upper modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: lower<br>
|
||||
* Purpose: convert string to uppercase
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_upper($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtoupper(' . $params[0] . ')';
|
||||
}
|
||||
|
@ -1,46 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty wordwrap modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: wordwrap<br>
|
||||
* Purpose: wrap a string of text at a given length
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_wordwrap($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 80;
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = '"\n"';
|
||||
}
|
||||
if (!isset($params[3])) {
|
||||
$params[3] = 'false';
|
||||
}
|
||||
$function = 'wordwrap';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($compiler->tag_nocache | $compiler->nocache) {
|
||||
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php';
|
||||
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
|
||||
} else {
|
||||
$compiler->template->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php';
|
||||
$compiler->template->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
|
||||
}
|
||||
$function = 'smarty_mb_wordwrap';
|
||||
}
|
||||
return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty wordwrap modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: wordwrap<br>
|
||||
* Purpose: wrap a string of text at a given length
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_wordwrap($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 80;
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = '"\n"';
|
||||
}
|
||||
if (!isset($params[3])) {
|
||||
$params[3] = 'false';
|
||||
}
|
||||
$function = 'wordwrap';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
|
||||
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
|
||||
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
|
||||
} else {
|
||||
$compiler->template->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
|
||||
$compiler->template->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
|
||||
}
|
||||
$function = 'smarty_mb_wordwrap';
|
||||
}
|
||||
|
||||
return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')';
|
||||
}
|
||||
|
@ -1,77 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break
|
||||
*
|
||||
* Compiles the {break} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('levels');
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('levels');
|
||||
|
||||
/**
|
||||
* Compiles code for the {break} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
|
||||
}
|
||||
|
||||
if (isset($_attr['levels'])) {
|
||||
if (!is_numeric($_attr['levels'])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', $compiler->lex->taglineno);
|
||||
}
|
||||
$_levels = $_attr['levels'];
|
||||
} else {
|
||||
$_levels = 1;
|
||||
}
|
||||
$level_count = $_levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) {
|
||||
$level_count--;
|
||||
}
|
||||
$stack_count--;
|
||||
}
|
||||
if ($level_count != 0) {
|
||||
$compiler->trigger_template_error("cannot break {$_levels} level(s)", $compiler->lex->taglineno);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
return "<?php break {$_levels}?>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break
|
||||
* Compiles the {break} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('levels');
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('levels');
|
||||
|
||||
/**
|
||||
* Compiles code for the {break} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
|
||||
}
|
||||
|
||||
if (isset($_attr['levels'])) {
|
||||
if (!is_numeric($_attr['levels'])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', $compiler->lex->taglineno);
|
||||
}
|
||||
$_levels = $_attr['levels'];
|
||||
} else {
|
||||
$_levels = 1;
|
||||
}
|
||||
$level_count = $_levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) {
|
||||
$level_count --;
|
||||
}
|
||||
$stack_count --;
|
||||
}
|
||||
if ($level_count != 0) {
|
||||
$compiler->trigger_template_error("cannot break {$_levels} level(s)", $compiler->lex->taglineno);
|
||||
}
|
||||
|
||||
return "<?php break {$_levels}?>";
|
||||
}
|
||||
}
|
||||
|
@ -1,78 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Continue
|
||||
*
|
||||
* Compiles the {continue} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Continue Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('levels');
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('levels');
|
||||
|
||||
/**
|
||||
* Compiles code for the {continue} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
|
||||
}
|
||||
|
||||
if (isset($_attr['levels'])) {
|
||||
if (!is_numeric($_attr['levels'])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', $compiler->lex->taglineno);
|
||||
}
|
||||
$_levels = $_attr['levels'];
|
||||
} else {
|
||||
$_levels = 1;
|
||||
}
|
||||
$level_count = $_levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) {
|
||||
$level_count--;
|
||||
}
|
||||
$stack_count--;
|
||||
}
|
||||
if ($level_count != 0) {
|
||||
$compiler->trigger_template_error("cannot continue {$_levels} level(s)", $compiler->lex->taglineno);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
return "<?php continue {$_levels}?>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Continue
|
||||
* Compiles the {continue} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Continue Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('levels');
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('levels');
|
||||
|
||||
/**
|
||||
* Compiles code for the {continue} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
|
||||
}
|
||||
|
||||
if (isset($_attr['levels'])) {
|
||||
if (!is_numeric($_attr['levels'])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', $compiler->lex->taglineno);
|
||||
}
|
||||
$_levels = $_attr['levels'];
|
||||
} else {
|
||||
$_levels = 1;
|
||||
}
|
||||
$level_count = $_levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) {
|
||||
$level_count --;
|
||||
}
|
||||
$stack_count --;
|
||||
}
|
||||
if ($level_count != 0) {
|
||||
$compiler->trigger_template_error("cannot continue {$_levels} level(s)", $compiler->lex->taglineno);
|
||||
}
|
||||
|
||||
return "<?php continue {$_levels}?>";
|
||||
}
|
||||
}
|
||||
|
@ -1,133 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile extend
|
||||
*
|
||||
* Compiles the {extends} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
* Smarty Internal Plugin Compile extend
|
||||
* Compiles the {extends} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile extend Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
|
||||
|
||||
* Smarty Internal Plugin Compile extend Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('file');
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('file');
|
||||
/**
|
||||
* mbstring.overload flag
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $mbstring_overload = 0;
|
||||
|
||||
/**
|
||||
* Compiles code for the {extends} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return string compiled code
|
||||
*/
|
||||
* Compiles code for the {extends} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||
$this->_rdl = preg_quote($compiler->smarty->right_delimiter);
|
||||
$this->_ldl = preg_quote($compiler->smarty->left_delimiter);
|
||||
if (!$compiler->smarty->auto_literal) {
|
||||
$al = '\s*';
|
||||
} else {
|
||||
$al = '';
|
||||
}
|
||||
$filepath = $compiler->template->source->filepath;
|
||||
$this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
|
||||
}
|
||||
|
||||
$_smarty_tpl = $compiler->template;
|
||||
$include_file = null;
|
||||
if (strpos($_attr['file'], '$_tmp') !== false) {
|
||||
$compiler->trigger_template_error('illegal value for file attribute', $compiler->lex->taglineno);
|
||||
}
|
||||
eval('$include_file = ' . $_attr['file'] . ';');
|
||||
|
||||
$name = $_attr['file'];
|
||||
/** @var Smarty_Internal_Template $_smarty_tpl
|
||||
* used in evaluated code
|
||||
*/
|
||||
$_smarty_tpl = $compiler->template;
|
||||
eval("\$tpl_name = $name;");
|
||||
// create template object
|
||||
$_template = new $compiler->smarty->template_class($include_file, $compiler->smarty, $compiler->template);
|
||||
// save file dependency
|
||||
if (isset($_is_stringy[$_template->source->type])) {
|
||||
$template_sha1 = sha1($include_file);
|
||||
} else {
|
||||
$template_sha1 = sha1($_template->source->filepath);
|
||||
}
|
||||
if (isset($compiler->template->properties['file_dependency'][$template_sha1])) {
|
||||
$compiler->trigger_template_error("illegal recursive call of \"{$include_file}\"", $compiler->lex->line - 1);
|
||||
$_template = new $compiler->smarty->template_class($tpl_name, $compiler->smarty, $compiler->template);
|
||||
// check for recursion
|
||||
$uid = $_template->source->uid;
|
||||
if (isset($compiler->extends_uid[$uid])) {
|
||||
$compiler->trigger_template_error("illegal recursive call of \"$include_file\"", $compiler->lex->line - 1);
|
||||
}
|
||||
$compiler->template->properties['file_dependency'][$template_sha1] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
|
||||
$_content = ($this->mbstring_overload ? mb_substr($compiler->lex->data, $compiler->lex->counter - 1, 20000000, 'latin1') : substr($compiler->lex->data, $compiler->lex->counter - 1));
|
||||
if (preg_match_all("!({$this->_ldl}{$al}block\s(.+?)\s*{$this->_rdl})!", $_content, $s) !=
|
||||
preg_match_all("!({$this->_ldl}{$al}/block\s*{$this->_rdl})!", $_content, $c)) {
|
||||
$compiler->trigger_template_error('unmatched {block} {/block} pairs');
|
||||
}
|
||||
preg_match_all("!{$this->_ldl}{$al}block\s(.+?)\s*{$this->_rdl}|{$this->_ldl}{$al}/block\s*{$this->_rdl}|{$this->_ldl}\*([\S\s]*?)\*{$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
|
||||
$_result_count = count($_result[0]);
|
||||
$_start = 0;
|
||||
while ($_start+1 < $_result_count) {
|
||||
$_end = 0;
|
||||
$_level = 1;
|
||||
if (($this->mbstring_overload ? mb_substr($_result[0][$_start][0],0,mb_strlen($compiler->smarty->left_delimiter,'latin1')+1, 'latin1') : substr($_result[0][$_start][0],0,strlen($compiler->smarty->left_delimiter)+1)) == $compiler->smarty->left_delimiter.'*') {
|
||||
$_start++;
|
||||
continue;
|
||||
}
|
||||
while ($_level != 0) {
|
||||
$_end++;
|
||||
if (($this->mbstring_overload ? mb_substr($_result[0][$_start + $_end][0],0,mb_strlen($compiler->smarty->left_delimiter,'latin1')+1, 'latin1') : substr($_result[0][$_start + $_end][0],0,strlen($compiler->smarty->left_delimiter)+1)) == $compiler->smarty->left_delimiter.'*') {
|
||||
continue;
|
||||
}
|
||||
if (!strpos($_result[0][$_start + $_end][0], '/')) {
|
||||
$_level++;
|
||||
} else {
|
||||
$_level--;
|
||||
$compiler->extends_uid[$uid] = true;
|
||||
if (empty($_template->source->components)) {
|
||||
array_unshift($compiler->sources, $_template->source);
|
||||
} else {
|
||||
foreach ($_template->source->components as $source) {
|
||||
array_unshift($compiler->sources, $source);
|
||||
$uid = $source->uid;
|
||||
if (isset($compiler->extends_uid[$uid])) {
|
||||
$compiler->trigger_template_error("illegal recursive call of \"{$source->filepath}\"", $compiler->lex->line - 1);
|
||||
}
|
||||
$compiler->extends_uid[$uid] = true;
|
||||
}
|
||||
$_block_content = str_replace($compiler->smarty->left_delimiter . '$smarty.block.parent' . $compiler->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%',
|
||||
($this->mbstring_overload ? mb_substr($_content, $_result[0][$_start][1] + mb_strlen($_result[0][$_start][0], 'latin1'), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + mb_strlen($_result[0][$_start][0], 'latin1'), 'latin1') : substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0]))));
|
||||
Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $compiler->template, $filepath);
|
||||
$_start = $_start + $_end + 1;
|
||||
}
|
||||
if ($_template->source->type == 'extends') {
|
||||
$_template->block_data = $compiler->template->block_data;
|
||||
}
|
||||
$compiler->template->source->content = $_template->source->content;
|
||||
if ($_template->source->type == 'extends') {
|
||||
$compiler->template->block_data = $_template->block_data;
|
||||
foreach ($_template->source->components as $key => $component) {
|
||||
$compiler->template->properties['file_dependency'][$key] = array($component->filepath, $component->timestamp, $component->type);
|
||||
}
|
||||
}
|
||||
$compiler->template->source->filepath = $_template->source->filepath;
|
||||
$compiler->abort_and_recompile = true;
|
||||
unset ($_template);
|
||||
$compiler->inheritance_child = true;
|
||||
$compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBODY);
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,140 +1,139 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Modifier
|
||||
*
|
||||
* Compiles code for modifier execution
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Modifier Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase {
|
||||
|
||||
/**
|
||||
* Compiles code for modifier execution
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$output = $parameter['value'];
|
||||
// loop over list of modifiers
|
||||
foreach ($parameter['modifierlist'] as $single_modifier) {
|
||||
$modifier = $single_modifier[0];
|
||||
$single_modifier[0] = $output;
|
||||
$params = implode(',', $single_modifier);
|
||||
// check if we know already the type of modifier
|
||||
if (isset($compiler->known_modifier_type[$modifier])) {
|
||||
$modifier_types = array($compiler->known_modifier_type[$modifier]);
|
||||
} else {
|
||||
$modifier_types = array(1, 2, 3, 4, 5, 6);
|
||||
}
|
||||
foreach ($modifier_types as $type) {
|
||||
switch ($type) {
|
||||
case 1:
|
||||
// registered modifier
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) {
|
||||
$function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
} else {
|
||||
if (is_object($function[0])) {
|
||||
$output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
|
||||
} else {
|
||||
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
|
||||
}
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// registered modifier compiler
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) {
|
||||
$output = call_user_func($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0], $single_modifier, $compiler->smarty);
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// modifiercompiler plugin
|
||||
if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
|
||||
$plugin = 'smarty_modifiercompiler_' . $modifier;
|
||||
$output = $plugin($single_modifier, $compiler);
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// modifier plugin
|
||||
if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
|
||||
$output = "{$function}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
// PHP function
|
||||
if (is_callable($modifier)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) {
|
||||
$output = "{$modifier}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
// default plugin handler
|
||||
if (isset($compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier]) || (is_callable($compiler->smarty->default_plugin_handler_func) && $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))) {
|
||||
$function = $compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
} else {
|
||||
if (is_object($function[0])) {
|
||||
$output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
|
||||
} else {
|
||||
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($compiler->template->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) || isset($compiler->template->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file'])) {
|
||||
// was a plugin
|
||||
$compiler->known_modifier_type[$modifier] = 4;
|
||||
} else {
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
}
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($compiler->known_modifier_type[$modifier])) {
|
||||
$compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Modifier
|
||||
* Compiles code for modifier execution
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Modifier Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for modifier execution
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$output = $parameter['value'];
|
||||
// loop over list of modifiers
|
||||
foreach ($parameter['modifierlist'] as $single_modifier) {
|
||||
$modifier = $single_modifier[0];
|
||||
$single_modifier[0] = $output;
|
||||
$params = implode(',', $single_modifier);
|
||||
// check if we know already the type of modifier
|
||||
if (isset($compiler->known_modifier_type[$modifier])) {
|
||||
$modifier_types = array($compiler->known_modifier_type[$modifier]);
|
||||
} else {
|
||||
$modifier_types = array(1, 2, 3, 4, 5, 6);
|
||||
}
|
||||
foreach ($modifier_types as $type) {
|
||||
switch ($type) {
|
||||
case 1:
|
||||
// registered modifier
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) {
|
||||
$function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
} else {
|
||||
if (is_object($function[0])) {
|
||||
$output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
|
||||
} else {
|
||||
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
|
||||
}
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// registered modifier compiler
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) {
|
||||
$output = call_user_func($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0], $single_modifier, $compiler->smarty);
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// modifiercompiler plugin
|
||||
if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
|
||||
$plugin = 'smarty_modifiercompiler_' . $modifier;
|
||||
$output = $plugin($single_modifier, $compiler);
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// modifier plugin
|
||||
if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
|
||||
$output = "{$function}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
// PHP function
|
||||
if (is_callable($modifier)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) {
|
||||
$output = "{$modifier}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
// default plugin handler
|
||||
if (isset($compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier]) || (is_callable($compiler->smarty->default_plugin_handler_func) && $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))) {
|
||||
$function = $compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
} else {
|
||||
if (is_object($function[0])) {
|
||||
$output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
|
||||
} else {
|
||||
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($compiler->template->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) || isset($compiler->template->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file'])) {
|
||||
// was a plugin
|
||||
$compiler->known_modifier_type[$modifier] = 4;
|
||||
} else {
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
}
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($compiler->known_modifier_type[$modifier])) {
|
||||
$compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
@ -1,113 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Registered Block
|
||||
*
|
||||
* Compiles code for the execution of a registered block function
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Registered Block Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_CompileBase {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
/**
|
||||
* Compiles code for the execution of a block function
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @param string $tag name of block function
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter, $tag)
|
||||
{
|
||||
if (!isset($tag[5]) || substr($tag,-5) != 'close') {
|
||||
// opening tag of block plugin
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache']) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
unset($_attr['nocache']);
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag];
|
||||
} else {
|
||||
$tag_info = $compiler->default_handler_plugins[Smarty::PLUGIN_BLOCK][$tag];
|
||||
}
|
||||
// convert attributes into parameter array string
|
||||
$_paramsArray = array();
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
if (is_int($_key)) {
|
||||
$_paramsArray[] = "$_key=>$_value";
|
||||
} elseif ($compiler->template->caching && in_array($_key,$tag_info[2])) {
|
||||
$_value = str_replace("'","^#^",$_value);
|
||||
$_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
|
||||
} else {
|
||||
$_paramsArray[] = "'$_key'=>$_value";
|
||||
}
|
||||
}
|
||||
$_params = 'array(' . implode(",", $_paramsArray) . ')';
|
||||
|
||||
$this->openTag($compiler, $tag, array($_params, $compiler->nocache));
|
||||
// maybe nocache because of nocache variables or nocache plugin
|
||||
$compiler->nocache = !$tag_info[1] | $compiler->nocache | $compiler->tag_nocache;
|
||||
$function = $tag_info[0];
|
||||
// compile code
|
||||
if (!is_array($function)) {
|
||||
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
|
||||
} else if (is_object($function[0])) {
|
||||
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo \$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]->{$function[1]}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
|
||||
} else {
|
||||
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function[0]}::{$function[1]}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
|
||||
}
|
||||
} else {
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
$base_tag = substr($tag, 0, -5);
|
||||
// closing tag of block plugin, restore nocache
|
||||
list($_params, $compiler->nocache) = $this->closeTag($compiler, $base_tag);
|
||||
// This tag does create output
|
||||
$compiler->has_output = true;
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$base_tag])) {
|
||||
$function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$base_tag][0];
|
||||
} else {
|
||||
$function = $compiler->default_handler_plugins[Smarty::PLUGIN_BLOCK][$base_tag][0];
|
||||
}
|
||||
// compile code
|
||||
if (!isset($parameter['modifier_list'])) {
|
||||
$mod_pre = $mod_post ='';
|
||||
} else {
|
||||
$mod_pre = ' ob_start(); ';
|
||||
$mod_post = 'echo '.$compiler->compileTag('private_modifier',array(),array('modifierlist'=>$parameter['modifier_list'],'value'=>'ob_get_clean()')).';';
|
||||
}
|
||||
if (!is_array($function)) {
|
||||
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;".$mod_pre." echo {$function}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat);".$mod_post." } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||
} else if (is_object($function[0])) {
|
||||
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;".$mod_pre." echo \$_smarty_tpl->smarty->registered_plugins['block']['{$base_tag}'][0][0]->{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); ".$mod_post."} array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||
} else {
|
||||
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;".$mod_pre." echo {$function[0]}::{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); ".$mod_post."} array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||
}
|
||||
}
|
||||
return $output . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Registered Block
|
||||
* Compiles code for the execution of a registered block function
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Registered Block Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
/**
|
||||
* Compiles code for the execution of a block function
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @param string $tag name of block function
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter, $tag)
|
||||
{
|
||||
if (!isset($tag[5]) || substr($tag, - 5) != 'close') {
|
||||
// opening tag of block plugin
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache']) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
unset($_attr['nocache']);
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag];
|
||||
} else {
|
||||
$tag_info = $compiler->default_handler_plugins[Smarty::PLUGIN_BLOCK][$tag];
|
||||
}
|
||||
// convert attributes into parameter array string
|
||||
$_paramsArray = array();
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
if (is_int($_key)) {
|
||||
$_paramsArray[] = "$_key=>$_value";
|
||||
} elseif ($compiler->template->caching && in_array($_key, $tag_info[2])) {
|
||||
$_value = str_replace("'", "^#^", $_value);
|
||||
$_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
|
||||
} else {
|
||||
$_paramsArray[] = "'$_key'=>$_value";
|
||||
}
|
||||
}
|
||||
$_params = 'array(' . implode(",", $_paramsArray) . ')';
|
||||
|
||||
$this->openTag($compiler, $tag, array($_params, $compiler->nocache));
|
||||
// maybe nocache because of nocache variables or nocache plugin
|
||||
$compiler->nocache = !$tag_info[1] | $compiler->nocache | $compiler->tag_nocache;
|
||||
$function = $tag_info[0];
|
||||
// compile code
|
||||
if (!is_array($function)) {
|
||||
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
|
||||
} elseif (is_object($function[0])) {
|
||||
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo \$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]->{$function[1]}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
|
||||
} else {
|
||||
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function[0]}::{$function[1]}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
|
||||
}
|
||||
} else {
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
$base_tag = substr($tag, 0, - 5);
|
||||
// closing tag of block plugin, restore nocache
|
||||
list($_params, $compiler->nocache) = $this->closeTag($compiler, $base_tag);
|
||||
// This tag does create output
|
||||
$compiler->has_output = true;
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$base_tag])) {
|
||||
$function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$base_tag][0];
|
||||
} else {
|
||||
$function = $compiler->default_handler_plugins[Smarty::PLUGIN_BLOCK][$base_tag][0];
|
||||
}
|
||||
// compile code
|
||||
if (!isset($parameter['modifier_list'])) {
|
||||
$mod_pre = $mod_post = '';
|
||||
} else {
|
||||
$mod_pre = ' ob_start(); ';
|
||||
$mod_post = 'echo ' . $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifier_list'], 'value' => 'ob_get_clean()')) . ';';
|
||||
}
|
||||
if (!is_array($function)) {
|
||||
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre . " echo {$function}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat);" . $mod_post . " } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||
} elseif (is_object($function[0])) {
|
||||
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre . " echo \$_smarty_tpl->smarty->registered_plugins['block']['{$base_tag}'][0][0]->{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . $mod_post . "} array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||
} else {
|
||||
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre . " echo {$function[0]}::{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . $mod_post . "} array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||
}
|
||||
}
|
||||
|
||||
return $output . "\n";
|
||||
}
|
||||
}
|
||||
|
@ -1,81 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Registered Function
|
||||
*
|
||||
* Compiles code for the execution of a registered function
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Registered Function Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
/**
|
||||
* Compiles code for the execution of a registered function
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @param string $tag name of function
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter, $tag)
|
||||
{
|
||||
// This tag does create output
|
||||
$compiler->has_output = true;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache']) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
unset($_attr['nocache']);
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag];
|
||||
} else {
|
||||
$tag_info = $compiler->default_handler_plugins[Smarty::PLUGIN_FUNCTION][$tag];
|
||||
}
|
||||
// not cachable?
|
||||
$compiler->tag_nocache = $compiler->tag_nocache || !$tag_info[1];
|
||||
// convert attributes into parameter array string
|
||||
$_paramsArray = array();
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
if (is_int($_key)) {
|
||||
$_paramsArray[] = "$_key=>$_value";
|
||||
} elseif ($compiler->template->caching && in_array($_key,$tag_info[2])) {
|
||||
$_value = str_replace("'","^#^",$_value);
|
||||
$_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
|
||||
} else {
|
||||
$_paramsArray[] = "'$_key'=>$_value";
|
||||
}
|
||||
}
|
||||
$_params = 'array(' . implode(",", $_paramsArray) . ')';
|
||||
$function = $tag_info[0];
|
||||
// compile code
|
||||
if (!is_array($function)) {
|
||||
$output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";
|
||||
} else if (is_object($function[0])) {
|
||||
$output = "<?php echo \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0][0]->{$function[1]}({$_params},\$_smarty_tpl);?>\n";
|
||||
} else {
|
||||
$output = "<?php echo {$function[0]}::{$function[1]}({$_params},\$_smarty_tpl);?>\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Registered Function
|
||||
* Compiles code for the execution of a registered function
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Registered Function Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
/**
|
||||
* Compiles code for the execution of a registered function
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @param string $tag name of function
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter, $tag)
|
||||
{
|
||||
// This tag does create output
|
||||
$compiler->has_output = true;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache']) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
unset($_attr['nocache']);
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag];
|
||||
} else {
|
||||
$tag_info = $compiler->default_handler_plugins[Smarty::PLUGIN_FUNCTION][$tag];
|
||||
}
|
||||
// not cachable?
|
||||
$compiler->tag_nocache = $compiler->tag_nocache || !$tag_info[1];
|
||||
// convert attributes into parameter array string
|
||||
$_paramsArray = array();
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
if (is_int($_key)) {
|
||||
$_paramsArray[] = "$_key=>$_value";
|
||||
} elseif ($compiler->template->caching && in_array($_key, $tag_info[2])) {
|
||||
$_value = str_replace("'", "^#^", $_value);
|
||||
$_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
|
||||
} else {
|
||||
$_paramsArray[] = "'$_key'=>$_value";
|
||||
}
|
||||
}
|
||||
$_params = 'array(' . implode(",", $_paramsArray) . ')';
|
||||
$function = $tag_info[0];
|
||||
// compile code
|
||||
if (!is_array($function)) {
|
||||
$output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";
|
||||
} elseif (is_object($function[0])) {
|
||||
$output = "<?php echo \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0][0]->{$function[1]}({$_params},\$_smarty_tpl);?>\n";
|
||||
} else {
|
||||
$output = "<?php echo {$function[0]}::{$function[1]}({$_params},\$_smarty_tpl);?>\n";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
@ -1,72 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Setfilter
|
||||
*
|
||||
* Compiles code for setfilter tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Setfilter Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase {
|
||||
|
||||
/**
|
||||
* Compiles code for setfilter tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
$compiler->variable_filter_stack[] = $compiler->template->variable_filters;
|
||||
$compiler->template->variable_filters = $parameter['modifier_list'];
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Setfilterclose Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase {
|
||||
|
||||
/**
|
||||
* Compiles code for the {/setfilter} tag
|
||||
*
|
||||
* This tag does not generate compiled output. It resets variable filter.
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// reset variable filter to previous state
|
||||
if (count($compiler->variable_filter_stack)) {
|
||||
$compiler->template->variable_filters = array_pop($compiler->variable_filter_stack);
|
||||
} else {
|
||||
$compiler->template->variable_filters = array();
|
||||
}
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Setfilter
|
||||
* Compiles code for setfilter tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Setfilter Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for setfilter tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
$compiler->variable_filter_stack[] = $compiler->template->variable_filters;
|
||||
$compiler->template->variable_filters = $parameter['modifier_list'];
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Setfilterclose Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/setfilter} tag
|
||||
* This tag does not generate compiled output. It resets variable filter.
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// reset variable filter to previous state
|
||||
if (count($compiler->variable_filter_stack)) {
|
||||
$compiler->template->variable_filters = array_pop($compiler->variable_filter_stack);
|
||||
} else {
|
||||
$compiler->template->variable_filters = array();
|
||||
}
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,55 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Function Call Handler
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class does call function defined with the {function} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
*/
|
||||
class Smarty_Internal_Function_Call_Handler {
|
||||
|
||||
/**
|
||||
* This function handles calls to template functions defined by {function}
|
||||
* It does create a PHP function at the first call
|
||||
*
|
||||
* @param string $_name template function name
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param array $_params Smarty variables passed as call parameter
|
||||
* @param string $_hash nocache hash value
|
||||
* @param bool $_nocache nocache flag
|
||||
*/
|
||||
public static function call($_name, Smarty_Internal_Template $_template, $_params, $_hash, $_nocache)
|
||||
{
|
||||
if ($_nocache) {
|
||||
$_function = "smarty_template_function_{$_name}_nocache";
|
||||
} else {
|
||||
$_function = "smarty_template_function_{$_hash}_{$_name}";
|
||||
}
|
||||
if (!is_callable($_function)) {
|
||||
$_code = "function {$_function}(\$_smarty_tpl,\$params) {
|
||||
\$saved_tpl_vars = \$_smarty_tpl->tpl_vars;
|
||||
foreach (\$_smarty_tpl->smarty->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);};
|
||||
foreach (\$params as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}?>";
|
||||
if ($_nocache) {
|
||||
$_code .= preg_replace(array("!<\?php echo \\'/\*%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/|/\*/%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/\\';\?>!",
|
||||
"!\\\'!"), array('', "'"), $_template->smarty->template_functions[$_name]['compiled']);
|
||||
$_template->smarty->template_functions[$_name]['called_nocache'] = true;
|
||||
} else {
|
||||
$_code .= preg_replace("/{$_template->smarty->template_functions[$_name]['nocache_hash']}/", $_template->properties['nocache_hash'], $_template->smarty->template_functions[$_name]['compiled']);
|
||||
}
|
||||
$_code .= "<?php \$_smarty_tpl->tpl_vars = \$saved_tpl_vars;}";
|
||||
eval($_code);
|
||||
}
|
||||
$_function($_template, $_params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Function Call Handler
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class does call function defined with the {function} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
*/
|
||||
class Smarty_Internal_Function_Call_Handler
|
||||
{
|
||||
/**
|
||||
* This function handles calls to template functions defined by {function}
|
||||
* It does create a PHP function at the first call
|
||||
*
|
||||
* @param string $_name template function name
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param array $_params Smarty variables passed as call parameter
|
||||
* @param string $_hash nocache hash value
|
||||
* @param bool $_nocache nocache flag
|
||||
*/
|
||||
public static function call($_name, Smarty_Internal_Template $_template, $_params, $_hash, $_nocache)
|
||||
{
|
||||
if ($_nocache) {
|
||||
$_function = "smarty_template_function_{$_name}_nocache";
|
||||
} else {
|
||||
$_function = "smarty_template_function_{$_hash}_{$_name}";
|
||||
}
|
||||
if (!is_callable($_function)) {
|
||||
$_code = "function {$_function}(\$_smarty_tpl,\$params) {
|
||||
\$saved_tpl_vars = \$_smarty_tpl->tpl_vars;
|
||||
foreach (\$_smarty_tpl->smarty->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);};
|
||||
foreach (\$params as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}?>";
|
||||
if ($_nocache) {
|
||||
$_code .= preg_replace(array("!<\?php echo \\'/\*%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/|/\*/%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/\\';\?>!",
|
||||
"!\\\'!"), array('', "'"), $_template->smarty->template_functions[$_name]['compiled']);
|
||||
$_template->smarty->template_functions[$_name]['called_nocache'] = true;
|
||||
} else {
|
||||
$_code .= preg_replace("/{$_template->smarty->template_functions[$_name]['nocache_hash']}/", $_template->properties['nocache_hash'], $_template->smarty->template_functions[$_name]['compiled']);
|
||||
}
|
||||
$_code .= "<?php \$_smarty_tpl->tpl_vars = \$saved_tpl_vars;}";
|
||||
eval($_code);
|
||||
}
|
||||
$_function($_template, $_params);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue