4 * Project: Smarty: the PHP compiling template engine
5 * File: smarty_internal_wrapper.php
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * For questions, help, comments, discussion, etc., please join the
23 * Smarty mailing list. Send a blank e-mail to
24 * smarty-discussion-subscribe@googlegroups.com
26 * @link http://www.smarty.net/
27 * @copyright 2008 New Digital Group, Inc.
28 * @author Monte Ohrt <monte at ohrt dot com>
31 * @subpackage PluginsInternal
32 * @version 3-SVN$Rev: 3286 $
36 * Smarty Backward Compatability Wrapper
39 class Smarty_Internal_Wrapper {
43 function __construct($smarty) {
44 $this->smarty = $smarty;
48 * Converts smarty2-style function call to smarty 3-style function call
49 * This is expensive, be sure to port your code to Smarty 3!
51 * @param string $name Smarty 2 function name
52 * @param array $args Smarty 2 function args
54 function convert($name, $args) {
55 // throw notice about deprecated function
56 if($this->smarty->deprecation_notices)
57 trigger_error("function call '$name' is unknown or deprecated.",E_USER_NOTICE);
58 // get first and last part of function name
59 $name_parts = explode('_',$name,2);
60 switch($name_parts[0]) {
63 switch($name_parts[1]) {
65 return call_user_func_array(array($this->smarty,"{$name_parts[0]}Object"),$args);
66 case 'compiler_function':
67 return call_user_func_array(array($this->smarty,"{$name_parts[0]}Plugin"),array_merge(array('compiler'),$args));
69 return call_user_func_array(array($this->smarty,"{$name_parts[0]}Filter"),array_merge(array('pre'),$args));
71 return call_user_func_array(array($this->smarty,"{$name_parts[0]}Filter"),array_merge(array('post'),$args));
73 return call_user_func_array(array($this->smarty,"{$name_parts[0]}Filter"),array_merge(array('output'),$args));
75 return call_user_func_array(array($this->smarty,"{$name_parts[0]}Resource"),$args);
77 return call_user_func_array(array($this->smarty,"{$name_parts[0]}Plugin"),array_merge(array($name_parts[1]),$args));
80 switch($name_parts[1]) {
82 return call_user_func_array(array($this->smarty,'getTemplateVars'),$args);
84 return call_user_func_array(array($this->smarty,'getConfigVars'),$args);
86 return call_user_func_array(array($myobj,$name_parts[1]),$args);
89 switch($name_parts[1]) {
91 return call_user_func_array(array($this->smarty,'clearAllAssign'),$args);
93 return call_user_func_array(array($this->smarty,'clearAssign'),$args);
95 return call_user_func_array(array($this->smarty,'clearAllCache'),$args);
97 return call_user_func_array(array($this->smarty,'clearCache'),$args);
98 case 'compiled_template':
99 return call_user_func_array(array($this->smarty,'clearCompiledTemplate'),$args);
102 switch($name_parts[1]) {
104 return call_user_func_array(array($this->smarty,'configLoad'),$args);
107 switch($name_parts[1]) {
109 return call_user_func_array('trigger_error',$args);
112 switch($name_parts[1]) {
114 return call_user_func_array(array($this->smarty,'loadFilter'),$args);
117 throw new SmartyException("unknown method '$name'");
121 * trigger Smarty error
123 * @param string $error_msg
124 * @param integer $error_type
126 function trigger_error($error_msg, $error_type = E_USER_WARNING)
128 trigger_error("Smarty error: $error_msg", $error_type);