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