Code

Added smarty base classes
[gosa.git] / include / smarty / plugins / function.eval.php
1 <?php
2 /**
3  * Smarty plugin
4  * @package Smarty
5  * @subpackage plugins
6  */
9 /**
10  * Smarty {eval} function plugin
11  *
12  * Type:     function<br>
13  * Name:     eval<br>
14  * Purpose:  evaluate a template variable as a template<br>
15  * @link http://smarty.php.net/manual/en/language.function.eval.php {eval}
16  *       (Smarty online manual)
17  * @author Monte Ohrt <monte at ohrt dot com>
18  * @param array
19  * @param Smarty
20  */
21 function smarty_function_eval($params, &$smarty)
22 {
24     if (!isset($params['var'])) {
25         $smarty->trigger_error("eval: missing 'var' parameter");
26         return;
27     }
29     if($params['var'] == '') {
30         return;
31     }
33     $smarty->_compile_source('evaluated template', $params['var'], $_var_compiled);
35     ob_start();
36     $smarty->_eval('?>' . $_var_compiled);
37     $_contents = ob_get_contents();
38     ob_end_clean();
40     if (!empty($params['assign'])) {
41         $smarty->assign($params['assign'], $_contents);
42     } else {
43         return $_contents;
44     }
45 }
47 /* vim: set expandtab: */
49 ?>