You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.8 KiB
PHTML
72 lines
1.8 KiB
PHTML
14 years ago
|
<?php
|
||
|
/**
|
||
|
* Smarty Internal Plugin Compile Eval
|
||
13 years ago
|
* Compiles the {eval} tag.
|
||
|
*
|
||
10 years ago
|
* @package Smarty
|
||
14 years ago
|
* @subpackage Compiler
|
||
10 years ago
|
* @author Uwe Tews
|
||
14 years ago
|
*/
|
||
|
|
||
|
/**
|
||
|
* Smarty Internal Plugin Compile Eval Class
|
||
13 years ago
|
*
|
||
10 years ago
|
* @package Smarty
|
||
13 years ago
|
* @subpackage Compiler
|
||
|
*/
|
||
11 years ago
|
class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase
|
||
|
{
|
||
13 years ago
|
/**
|
||
|
* Attribute definition: Overwrites base class.
|
||
|
*
|
||
|
* @var array
|
||
|
* @see Smarty_Internal_CompileBase
|
||
|
*/
|
||
14 years ago
|
public $required_attributes = array('var');
|
||
7 years ago
|
|
||
13 years ago
|
/**
|
||
|
* Attribute definition: Overwrites base class.
|
||
|
*
|
||
|
* @var array
|
||
|
* @see Smarty_Internal_CompileBase
|
||
|
*/
|
||
|
public $optional_attributes = array('assign');
|
||
7 years ago
|
|
||
13 years ago
|
/**
|
||
|
* Attribute definition: Overwrites base class.
|
||
|
*
|
||
|
* @var array
|
||
|
* @see Smarty_Internal_CompileBase
|
||
|
*/
|
||
10 years ago
|
public $shorttag_order = array('var', 'assign');
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Compiles code for the {eval} tag
|
||
13 years ago
|
*
|
||
11 years ago
|
* @param array $args array with attributes from parser
|
||
|
* @param object $compiler compiler object
|
||
10 years ago
|
*
|
||
14 years ago
|
* @return string compiled code
|
||
|
*/
|
||
|
public function compile($args, $compiler)
|
||
|
{
|
||
|
// check and get attributes
|
||
13 years ago
|
$_attr = $this->getAttributes($compiler, $args);
|
||
7 years ago
|
if (isset($_attr[ 'assign' ])) {
|
||
10 years ago
|
// output will be stored in a smarty variable instead of being displayed
|
||
7 years ago
|
$_assign = $_attr[ 'assign' ];
|
||
14 years ago
|
}
|
||
13 years ago
|
|
||
14 years ago
|
// create template object
|
||
7 years ago
|
$_output = "\$_template = new {$compiler->smarty->template_class}('eval:'.{$_attr[ 'var' ]}, \$_smarty_tpl->smarty, \$_smarty_tpl);";
|
||
13 years ago
|
//was there an assign attribute?
|
||
14 years ago
|
if (isset($_assign)) {
|
||
13 years ago
|
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());";
|
||
14 years ago
|
} else {
|
||
7 years ago
|
$_output .= 'echo $_template->fetch();';
|
||
13 years ago
|
}
|
||
11 years ago
|
|
||
14 years ago
|
return "<?php $_output ?>";
|
||
13 years ago
|
}
|
||
|
}
|