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