1 |
cvsjoko |
1.1 |
<?php |
2 |
joko |
1.2 |
/** |
3 |
|
|
* Smarty plugin |
4 |
|
|
* @package Smarty |
5 |
|
|
* @subpackage plugins |
6 |
|
|
*/ |
7 |
|
|
|
8 |
cvsjoko |
1.1 |
|
9 |
joko |
1.2 |
/** |
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 |
|
|
* @param array |
18 |
|
|
* @param Smarty |
19 |
cvsjoko |
1.1 |
*/ |
20 |
joko |
1.2 |
function smarty_function_eval($params, &$smarty) |
21 |
cvsjoko |
1.1 |
{ |
22 |
|
|
|
23 |
joko |
1.2 |
if (!isset($params['var'])) { |
24 |
|
|
$smarty->trigger_error("eval: missing 'var' parameter"); |
25 |
|
|
return; |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
if($params['var'] == '') { |
29 |
cvsjoko |
1.1 |
return; |
30 |
|
|
} |
31 |
joko |
1.2 |
|
32 |
|
|
$smarty->_compile_source('evaluated template', $params['var'], $_var_compiled); |
33 |
|
|
|
34 |
|
|
ob_start(); |
35 |
|
|
$smarty->_eval('?>' . $_var_compiled); |
36 |
|
|
$_contents = ob_get_contents(); |
37 |
|
|
ob_end_clean(); |
38 |
|
|
|
39 |
|
|
if (!empty($params['assign'])) { |
40 |
|
|
$smarty->assign($params['assign'], $_contents); |
41 |
cvsjoko |
1.1 |
} else { |
42 |
joko |
1.2 |
return $_contents; |
43 |
cvsjoko |
1.1 |
} |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
/* vim: set expandtab: */ |
47 |
|
|
|
48 |
|
|
?> |