2002-02-27 22:30:05 +00:00
|
|
|
<?php
|
2003-04-20 21:12:13 +00:00
|
|
|
/**
|
2002-02-27 22:30:05 +00:00
|
|
|
* Smarty plugin
|
2003-04-20 21:12:13 +00:00
|
|
|
* @package Smarty
|
|
|
|
* @subpackage plugins
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Smarty {eval} function plugin
|
|
|
|
*
|
|
|
|
* Type: function<br>
|
|
|
|
* Name: eval<br>
|
|
|
|
* Purpose: evaluate a template variable as a template<br>
|
|
|
|
* @link http://smarty.php.net/manual/en/language.function.eval.php {eval}
|
|
|
|
* (Smarty online manual)
|
|
|
|
* @param array
|
|
|
|
* @param Smarty
|
2002-02-27 22:30:05 +00:00
|
|
|
*/
|
|
|
|
function smarty_function_eval($params, &$this)
|
|
|
|
{
|
|
|
|
extract($params);
|
|
|
|
|
2002-06-29 16:04:41 +00:00
|
|
|
if (!isset($var)) {
|
|
|
|
$this->trigger_error("eval: missing 'var' parameter");
|
2002-02-27 22:30:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-06-29 16:07:02 +00:00
|
|
|
if($var == '') {
|
|
|
|
return;
|
|
|
|
}
|
2002-02-27 22:30:05 +00:00
|
|
|
|
2002-02-27 22:35:34 +00:00
|
|
|
$this->_compile_template("evaluated template", $var, $source);
|
2002-02-27 22:30:05 +00:00
|
|
|
|
2003-01-08 17:34:45 +00:00
|
|
|
ob_start();
|
|
|
|
eval('?>' . $source);
|
|
|
|
$contents = ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
|
2002-02-27 22:30:05 +00:00
|
|
|
if (!empty($assign)) {
|
2003-01-08 17:34:45 +00:00
|
|
|
$this->assign($assign, $contents);
|
2002-02-27 22:30:05 +00:00
|
|
|
} else {
|
2003-01-08 17:34:45 +00:00
|
|
|
return $contents;
|
2002-02-27 22:30:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim: set expandtab: */
|
|
|
|
|
|
|
|
?>
|