Code

Updated password field handling
[gosa.git] / gosa-core / include / smarty / Smarty.class.php
1 <?php
3 /**
4  * Project:     Smarty: the PHP compiling template engine
5  * File:        Smarty.class.php
6  * SVN:         $Id: Smarty.class.php 3508 2010-02-26 12:58:36Z Uwe.Tews $
7  * 
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.
12  * 
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.
17  * 
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
21  * 
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
25  * 
26  * @link http://www.smarty.net/
27  * @copyright 2008 New Digital Group, Inc.
28  * @author Monte Ohrt <monte at ohrt dot com> 
29  * @author Uwe Tews 
30  * @package Smarty
31  * @version 3-SVN$Rev: 3286 $
32  */
34 /**
35  * define shorthand directory separator constant
36  */
37 if (!defined('DS')) {
38     define('DS', DIRECTORY_SEPARATOR);
39
41 /**
42  * set SMARTY_DIR to absolute path to Smarty library files.
43  * Sets SMARTY_DIR only if user application has not already defined it.
44  */
45 if (!defined('SMARTY_DIR')) {
46     define('SMARTY_DIR', dirname(__FILE__) . DS);
47
49 /**
50  * set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
51  * Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it.
52  */
53 if (!defined('SMARTY_SYSPLUGINS_DIR')) {
54     define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS);
55
56 if (!defined('SMARTY_PLUGINS_DIR')) {
57     define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS);
58
59 if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
60     define('SMARTY_RESOURCE_CHAR_SET', 'UTF-8');
61
62 if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
63     define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
64
66 /**
67  * define variable scopes
68  */
69 define('SMARTY_LOCAL_SCOPE', 0);
70 define('SMARTY_PARENT_SCOPE', 1);
71 define('SMARTY_ROOT_SCOPE', 2);
72 define('SMARTY_GLOBAL_SCOPE', 3);
74 /**
75  * define caching modes
76  */
77 define('SMARTY_CACHING_OFF', 0);
78 define('SMARTY_CACHING_LIFETIME_CURRENT', 1);
79 define('SMARTY_CACHING_LIFETIME_SAVED', 2);
81 /**
82  * This determines how Smarty handles "<?php ... ?>" tags in templates.
83  * possible values:
84  */
85 define('SMARTY_PHP_PASSTHRU', 0); //-> print tags as plain text
86 define('SMARTY_PHP_QUOTE', 1); //-> escape tags as entities
87 define('SMARTY_PHP_REMOVE', 2); //-> escape tags as entities
88 define('SMARTY_PHP_ALLOW', 3); //-> escape tags as entities
90 /**
91  * register the class autoloader
92  */
93 if (!defined('SMARTY_SPL_AUTOLOAD')) {
94     define('SMARTY_SPL_AUTOLOAD', 0);
95
97 if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) {
98     $registeredAutoLoadFunctions = spl_autoload_functions();
99     if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
100         spl_autoload_register();
101     } 
102 } else {
103     spl_autoload_register('smartyAutoload');
104
106 /**
107  * This is the main Smarty class
108  */
109 class Smarty extends Smarty_Internal_Data {
110     // smarty version
111     const SMARTY_VERSION = 'Smarty3-b8'; 
112     // auto literal on delimiters with whitspace
113     public $auto_literal = true; 
114     // display error on not assigned variables
115     public $error_unassigned = false; 
116     // template directory
117     public $template_dir = null; 
118     // default template handler
119     public $default_template_handler_func = null; 
120     // compile directory
121     public $compile_dir = null; 
122     // plugins directory
123     public $plugins_dir = null; 
124     // cache directory
125     public $cache_dir = null; 
126     // config directory
127     public $config_dir = null; 
128     // force template compiling?
129     public $force_compile = false; 
130     // check template for modifications?
131     public $compile_check = true; 
132     // use sub dirs for compiled/cached files?
133     public $use_sub_dirs = false; 
134     // compile_error?
135     public $compile_error = false; 
136     // caching enabled
137     public $caching = false; 
138     // merge compiled includea
139     public $merge_compiled_includes = false; 
140     // cache lifetime
141     public $cache_lifetime = 3600; 
142     // force cache file creation
143     public $force_cache = false; 
144     // cache_id
145     public $cache_id = null; 
146     // compile_id
147     public $compile_id = null; 
148     // template delimiters
149     public $left_delimiter = "{";
150     public $right_delimiter = "}"; 
151     // security
152     public $security_class = 'Smarty_Security';
153     public $php_handling = SMARTY_PHP_PASSTHRU;
154     public $allow_php_tag = false;
155     public $allow_php_templates = false;
156     public $security = false;
157     public $security_policy = null;
158     public $security_handler = null;
159     public $direct_access_security = true; 
160     // debug mode
161     public $debugging = false;
162     public $debugging_ctrl = 'URL';
163     public $smarty_debug_id = 'SMARTY_DEBUG';
164     public $debug_tpl = null; 
165     // When set, smarty does uses this value as error_reporting-level.
166     public $error_reporting = null; 
167     // config var settings
168     public $config_overwrite = true; //Controls whether variables with the same name overwrite each other.
169     public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean
170     public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file.                                                     
171     // config vars
172     public $config_vars = array(); 
173     // assigned tpl vars
174     public $tpl_vars = array(); 
175     // assigned global tpl vars
176     public $global_tpl_vars = array(); 
177     // dummy parent object
178     public $parent = null; 
179     // global template functions
180     public $template_functions = array(); 
181     // resource type used if none given
182     public $default_resource_type = 'file'; 
183     // caching type
184     public $caching_type = 'file'; 
185     // internal cache resource types
186     public $cache_resource_types = array('file'); 
187     // internal cache resource objects
188     public $cache_resource_objects = array(); 
189     // internal config properties
190     public $properties = array(); 
191     // config type
192     public $default_config_type = 'file'; 
193     // exception handler: array('ExceptionClass','ExceptionMethod');
194     public $exception_handler = null; 
195     // cached template objects
196     public $template_objects = null; 
197     // check If-Modified-Since headers
198     public $cache_modified_check = false; 
199     // registered plugins
200     public $registered_plugins = array(); 
201     // plugin search order
202     public $plugin_search_order = array('function', 'block', 'compiler', 'class'); 
203     // registered objects
204     public $registered_objects = array(); 
205     // registered filters
206     public $registered_filters = array(); 
207     // autoload filter
208     public $autoload_filters = array(); 
209     // status of filter on variable output
210     public $variable_filter = true; 
211     // default modifier
212     public $default_modifiers = array(); 
213     // global internal smarty  vars
214     public $_smarty_vars = array(); 
215     // start time for execution time calculation
216     public $start_time = 0; 
217     // default file permissions
218     public $_file_perms = 0644; 
219     // default dir permissions
220     public $_dir_perms = 0771; 
221     // smarty object reference
222     public $smarty = null; 
223     // block data at template inheritance
224     public $block_data = array(); 
225     // block tag hierarchy
226     public $_tag_stack = array(); 
227     // plugins
228     public $_plugins = array(); 
229     // generate deprecated function call notices?
230     public $deprecation_notices = true;
232     /**
233      * Class constructor, initializes basic smarty properties
234      */
235     public function __construct()
236     { 
237         // self reference needed by other classes methods
238         $this->smarty = $this;
240         if (is_callable('mb_internal_encoding')) {
241             mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET);
242         } 
243         $this->start_time = $this->_get_time(); 
244         // set exception handler
245         if (!empty($this->exception_handler))
246             set_exception_handler($this->exception_handler); 
247         // set default dirs
248         $this->template_dir = array('.' . DS . 'templates' . DS);
249         $this->compile_dir = '.' . DS . 'templates_c' . DS;
250         $this->plugins_dir = array(SMARTY_PLUGINS_DIR);
251         $this->cache_dir = '.' . DS . 'cache' . DS;
252         $this->config_dir = '.' . DS . 'configs' . DS;
253         $this->debug_tpl = SMARTY_DIR . 'debug.tpl';
254         if (!$this->debugging && $this->debugging_ctrl == 'URL') {
255             if (isset($_SERVER['QUERY_STRING'])) {
256                 $_query_string = $_SERVER['QUERY_STRING'];
257             } else {
258                 $_query_string = '';
259             } 
260             if (false !== strpos($_query_string, $this->smarty_debug_id)) {
261                 if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) {
262                     // enable debugging for this browser session
263                     setcookie('SMARTY_DEBUG', true);
264                     $this->debugging = true;
265                 } elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) {
266                     // disable debugging for this browser session
267                     setcookie('SMARTY_DEBUG', false);
268                     $this->debugging = false;
269                 } else {
270                     // enable debugging for this page
271                     $this->debugging = true;
272                 } 
273             } else {
274                 if (isset($_COOKIE['SMARTY_DEBUG'])) {
275                     $this->debugging = true;
276                 } 
277             } 
278         } 
279         if (isset($_SERVER['SCRIPT_NAME'])) {
280             $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
281         } 
282     } 
284     /**
285      * Class destructor
286      */
287     public function __destruct()
288     { 
289         // restore to previous exception handler, if any
290         if (!empty($this->exception_handler))
291             restore_exception_handler();
292     } 
294     /**
295      * fetches a rendered Smarty template
296      * 
297      * @param string $template the resource handle of the template file or template object
298      * @param mixed $cache_id cache id to be used with this template
299      * @param mixed $compile_id compile id to be used with this template
300      * @param object $ |null $parent next higher level of Smarty variables
301      * @return string rendered template output
302      */
303     public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false)
304     {
305         if (is_object($cache_id)) {
306             $parent = $cache_id;
307             $cache_id = null;
308         } 
309         if ($parent === null) {
310             // get default Smarty data object
311             $parent = $this;
312         } 
313         // create template object if necessary
314         ($template instanceof $this->template_class)? $_template = $template :
315         $_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent);
316         $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting)
317             ? $this->error_reporting : error_reporting() &~E_NOTICE); 
318         // obtain data for cache modified check
319         if ($this->cache_modified_check && $this->caching && $display) {
320             $_isCached = $_template->isCached() && !$_template->has_nocache_code;
321             if ($_isCached) {
322                 $_gmt_mtime = gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT';
323             } else {
324                 $_gmt_mtime = '';
325             } 
326         } 
327         // return redered template
328         if (isset($this->autoload_filters['output']) || isset($this->registered_filters['output'])) {
329             $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $this);
330         } else {
331             $_output = $_template->getRenderedTemplate();
332         } 
333         $_template->rendered_content = null;
334         error_reporting($_smarty_old_error_level); 
335         // display or fetch
336         if ($display) {
337             if ($this->caching && $this->cache_modified_check) {
338                 $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
339                 if ($_isCached && $_gmt_mtime == $_last_modified_date) {
340                     if (php_sapi_name() == 'cgi')
341                         header('Status: 304 Not Modified');
342                     else
343                         header('HTTP/1.1 304 Not Modified');
344                 } else {
345                     header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT');
346                     echo $_output;
347                 } 
348             } else {
349                 echo $_output;
350             } 
351             // debug output
352             if ($this->debugging) {
353                 Smarty_Internal_Debug::display_debug($this);
354             } 
355             return;
356         } else {
357            // return fetched content
358             return $_output;
359         } 
360     } 
362     /**
363      * displays a Smarty template
364      * 
365      * @param string $ |object $template the resource handle of the template file  or template object
366      * @param mixed $cache_id cache id to be used with this template
367      * @param mixed $compile_id compile id to be used with this template
368      * @param object $parent next higher level of Smarty variables
369      */
370     public function display($template, $cache_id = null, $compile_id = null, $parent = null)
371     { 
372         // display template
373         $this->fetch ($template, $cache_id, $compile_id, $parent, true);
374     } 
376     /**
377      * test if cache i valid
378      * 
379      * @param string $ |object $template the resource handle of the template file or template object
380      * @param mixed $cache_id cache id to be used with this template
381      * @param mixed $compile_id compile id to be used with this template
382      * @return boolean cache status
383      */
384     public function isCached($template, $cache_id = null, $compile_id = null)
385     {
386         if (!($template instanceof $this->template_class)) {
387             $template = $this->createTemplate ($template, $cache_id, $compile_id, $this);
388         } 
389         // return cache status of template
390         return $template->isCached();
391     } 
393     /**
394      * creates a data object
395      * 
396      * @param object $parent next higher level of Smarty variables
397      * @returns object data object
398      */
399     public function createData($parent = null)
400     {
401         return new Smarty_Data($parent, $this);
402     } 
404     /**
405      * creates a template object
406      * 
407      * @param string $template the resource handle of the template file
408      * @param object $parent next higher level of Smarty variables
409      * @param mixed $cache_id cache id to be used with this template
410      * @param mixed $compile_id compile id to be used with this template
411      * @returns object template object
412      */
413     public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null)
414     {
415         if (is_object($cache_id) || is_array($cache_id)) {
416             $parent = $cache_id;
417             $cache_id = null;
418         } 
419         if (is_array($parent)) {
420             $data = $parent;
421             $parent = null;
422         } else {
423             $data = null;
424         } 
425         if (!is_object($template)) {
426             // we got a template resource
427             // already in template cache?
428             $_templateId = crc32($template . $cache_id . $compile_id);
429             if (isset($this->template_objects[$_templateId]) && $this->caching) {
430                 // return cached template object
431                 $tpl = $this->template_objects[$_templateId];
432             } else {
433                 // create new template object
434                 $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
435             } 
436         } else {
437             // just return a copy of template class
438             $tpl = $template;
439         } 
440         // fill data if present
441         if (is_array($data)) {
442             // set up variable values
443             foreach ($data as $_key => $_val) {
444                 $tpl->tpl_vars[$_key] = new Smarty_variable($_val);
445             } 
446         } 
447         return $tpl;
448     } 
450     /**
451      * Loads security class and enables security
452      */
453     public function enableSecurity()
454     {
455         if (isset($this->security_class)) {
456             $this->security_policy = new $this->security_class;
457             $this->security_handler = new Smarty_Internal_Security_Handler($this);
458             $this->security = true;
459         } else {
460             throw new Exception('Property security_class is not defined');
461         } 
462     } 
464     /**
465      * Disable security
466      */
467     public function disableSecurity()
468     {
469         $this->security = true;
470     } 
472     /**
473      * Set template directory
474      * 
475      * @param string $ |array $template_dir folder(s) of template sorces
476      */
477     public function setTemplateDir($template_dir)
478     {
479         $this->template_dir = (array)$template_dir;
480         return;
481     } 
483     /**
484      * Adds template directory(s) to existing ones
485      * 
486      * @param string $ |array $template_dir folder(s) of template sources
487      */
488     public function addTemplateDir($template_dir)
489     {
490         $this->template_dir = array_merge((array)$this->template_dir, (array)$template_dir);
491         $this->template_dir = array_unique($this->template_dir);
492         return;
493     } 
495     /**
496      * Check if a template resource exists
497      * 
498      * @param string $resource_name template name
499      * @return boolean status
500      */
501     function templateExists($resource_name)
502     { 
503         // create template object
504         $tpl = new $this->template_class($resource_name, $this); 
505         // check if it does exists
506         return $tpl->isExisting();
507     } 
509     /**
510      * Takes unknown classes and loads plugin files for them
511      * class name format: Smarty_PluginType_PluginName
512      * plugin filename format: plugintype.pluginname.php
513      * 
514      * @param string $plugin_name class plugin name to load
515      * @return string |boolean filepath of loaded file or false
516      */
517     public function loadPlugin($plugin_name, $check = true)
518     { 
519         // if function or class exists, exit silently (already loaded)
520         if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false)))
521             return true; 
522         // Plugin name is expected to be: Smarty_[Type]_[Name]
523         $_plugin_name = strtolower($plugin_name);
524         $_name_parts = explode('_', $_plugin_name, 3); 
525         // class name must have three parts to be valid plugin
526         if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') {
527             throw new Exception("plugin {$plugin_name} is not a valid name format");
528             return false;
529         } 
530         // if type is "internal", get plugin from sysplugins
531         if ($_name_parts[1] == 'internal') {
532             $file = SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php';
533             if (file_exists($file)) {
534                 require_once($file);
535                 return $file;
536             } else {
537                 return false;
538             } 
539         } 
540         // plugin filename is expected to be: [type].[name].php
541         $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php"; 
542         // loop through plugin dirs and find the plugin
543         foreach((array)$this->plugins_dir as $_plugin_dir) {
544             if (strpos('/\\', substr($_plugin_dir, -1)) === false) {
545                 $_plugin_dir .= DS;
546             } 
547             $file = $_plugin_dir . $_plugin_filename;
548             if (file_exists($file)) {
549                 require_once($file);
550                 return $file;
551             } 
552         } 
553         // no plugin loaded
554         return false;
555     } 
557     /**
558      * load a filter of specified type and name
559      * 
560      * @param string $type filter type
561      * @param string $name filter name
562      * @return bool 
563      */
564     function loadFilter($type, $name)
565     {
566         $_plugin = "smarty_{$type}filter_{$name}";
567         $_filter_name = $_plugin;
568         if ($this->loadPlugin($_plugin)) {
569             if (class_exists($_plugin, false)) {
570                 $_plugin = array($_plugin, 'execute');
571             } 
572             if (is_callable($_plugin)) {
573                 return $this->registered_filters[$type][$_filter_name] = $_plugin;
574             } 
575         } 
576         throw new Exception("{$type}filter \"{$name}\" not callable");
577         return false;
578     } 
580     /**
581      * Sets the exception handler for Smarty.
582      * 
583      * @param mixed $handler function name or array with object/method names
584      * @return string previous exception handler
585      */
586     public function setExceptionHandler($handler)
587     {
588         $this->exception_handler = $handler;
589         return set_exception_handler($handler);
590     } 
592     /**
593      * trigger Smarty error
594      * 
595      * @param string $error_msg 
596      * @param integer $error_type 
597      */
598     public function trigger_error($error_msg, $error_type = E_USER_WARNING)
599     {
600         throw new Exception("Smarty error: $error_msg");
601     } 
603     /**
604      * Return internal filter name
605      * 
606      * @param callback $function_name 
607      */
608     public function _get_filter_name($function_name)
609     {
610         if (is_array($function_name)) {
611             $_class_name = (is_object($function_name[0]) ?
612                 get_class($function_name[0]) : $function_name[0]);
613             return $_class_name . '_' . $function_name[1];
614         } else {
615             return $function_name;
616         } 
617     } 
619     /**
620      * Adds directory of plugin files
621      * 
622      * @param object $smarty 
623      * @param string $ |array $ plugins folder
624      * @return 
625      */
626     function addPluginsDir($plugins_dir)
627     {
628         $this->plugins_dir = array_merge((array)$this->plugins_dir, (array)$plugins_dir);
629         $this->plugins_dir = array_unique($this->plugins_dir);
630         return;
631     } 
633     /**
634      * Returns a single or all global  variables
635      * 
636      * @param object $smarty 
637      * @param string $varname variable name or null
638      * @return string variable value or or array of variables
639      */
640     function getGlobal($varname = null)
641     {
642         if (isset($varname)) {
643             if (isset($this->global_tpl_vars[$varname])) {
644                 return $this->global_tpl_vars[$varname]->value;
645             } else {
646                 return '';
647             } 
648         } else {
649             $_result = array();
650             foreach ($this->global_tpl_vars AS $key => $var) {
651                 $_result[$key] = $var->value;
652             } 
653             return $_result;
654         } 
655     } 
657     /**
658      * return a reference to a registered object
659      * 
660      * @param string $name object name
661      * @return object 
662      */
663     function getRegisteredObject($name)
664     {
665         if (!isset($this->registered_objects[$name]))
666             throw new Exception("'$name' is not a registered object");
668         if (!is_object($this->registered_objects[$name][0]))
669             throw new Exception("registered '$name' is not an object");
671         return $this->registered_objects[$name][0];
672     } 
674     /**
675      * return name of debugging template
676      * 
677      * @return string 
678      */
679     function getDebugTemplate()
680     {
681         return $this->debug_tpl;
682     } 
684     /**
685      * set the debug template
686      * 
687      * @param string $tpl_name 
688      * @return bool 
689      */
690     function setDebugTemplate($tpl_name)
691     {
692         return $this->debug_tpl = $tpl_name;
693     } 
695     /**
696      * lazy loads (valid) property objects
697      * 
698      * @param string $name property name
699      */
700     public function __get($name)
701     {
702         if (in_array($name, array('register', 'unregister', 'utility', 'cache'))) {
703             $class = "Smarty_Internal_" . ucfirst($name);
704             $this->$name = new $class($this);
705             return $this->$name;
706         } else if ($name == '_version') {
707             // Smarty 2 BC
708             $this->_version = self::SMARTY_VERSION;
709             return $this->_version;
710         }       
711         return null;
712     } 
714     /**
715      * Takes unknown class methods and lazy loads sysplugin files for them
716      * class name format: Smarty_Method_MethodName
717      * plugin filename format: method.methodname.php
718      * 
719      * @param string $name unknown methode name
720      * @param array $args aurgument array
721      */
722     public function __call($name, $args)
723     {
724         static $camel_func;
725         if (!isset($camel_func))
726             $camel_func = create_function('$c', 'return "_" . strtolower($c[1]);'); 
727         // PHP4 call to constructor?
728         if (strtolower($name) == 'smarty') {
729             throw new Exception('Please use parent::__construct() to call parent constuctor');
730             return false;
731         } 
732         // see if this is a set/get for a property
733         $first3 = strtolower(substr($name, 0, 3));
734         if (in_array($first3, array('set', 'get')) && substr($name, 3, 1) !== '_') {
735             // try to keep case correct for future PHP 6.0 case-sensitive class methods
736             // lcfirst() not available < PHP 5.3.0, so improvise
737             $property_name = strtolower(substr($name, 3, 1)) . substr($name, 4); 
738             // convert camel case to underscored name
739             $property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name);
740             if (!property_exists($this, $property_name)) {
741                 throw new Exception("property '$property_name' does not exist.");
742                 return false;
743             } 
744             if ($first3 == 'get')
745                 return $this->$property_name;
746             else
747                 return $this->$property_name = $args[0];
748         } 
749         // Smarty Backward Compatible wrapper
750         if (!isset($this->wrapper)) {
751             $this->wrapper = new Smarty_Internal_Wrapper($this);
752         } 
753         return $this->wrapper->convert($name, $args);
755         /*
756         $name = strtolower($name);
757         if ($name == 'smarty') {
758             throw new Exception('Please use parent::__construct() to call parent constuctor');
759         } 
760         $function_name = 'smarty_method_' . $name;
761         if (!is_callable($function_name)) {
762             if (!file_exists(SMARTY_SYSPLUGINS_DIR . $function_name . '.php')) {
763                 throw new Exception('Undefined Smarty method "' . $name . '"');
764             } 
765             require_once(SMARTY_SYSPLUGINS_DIR . $function_name . '.php');
766         } 
767         return call_user_func_array($function_name, array_merge(array($this), $args));
768         */
769     } 
770
772 function smartyAutoload($class)
774     $_class = strtolower($class);
775     if (substr($_class, 0, 16) === 'smarty_internal_' || $_class == 'smarty_security') {
776         include SMARTY_SYSPLUGINS_DIR . $_class . '.php';
777     } 
778
780 ?>