2009-03-22 16:09:05 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2010-05-06 00:11:30 +00:00
|
|
|
* Smarty Internal Plugin Compile Print Expression
|
|
|
|
*
|
|
|
|
* Compiles any tag which will output an expression or variable
|
|
|
|
*
|
|
|
|
* @package Smarty
|
|
|
|
* @subpackage Compiler
|
|
|
|
* @author Uwe Tews
|
|
|
|
*/
|
2010-08-17 15:39:51 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-05-06 00:11:30 +00:00
|
|
|
* Smarty Internal Plugin Compile Print Expression Class
|
|
|
|
*/
|
2009-12-27 15:06:49 +00:00
|
|
|
class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_CompileBase {
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-05-06 00:11:30 +00:00
|
|
|
* Compiles code for gererting output from any expression
|
|
|
|
*
|
|
|
|
* @param array $args array with attributes from parser
|
|
|
|
* @param object $compiler compiler object
|
|
|
|
* @return string compiled code
|
|
|
|
*/
|
2009-03-22 16:09:05 +00:00
|
|
|
public function compile($args, $compiler)
|
|
|
|
{
|
2009-04-10 01:15:53 +00:00
|
|
|
$this->compiler = $compiler;
|
2010-10-25 18:53:43 +00:00
|
|
|
$this->optional_attributes = array('assign');
|
2009-03-22 16:09:05 +00:00
|
|
|
$this->required_attributes = array('value');
|
2010-10-25 18:53:43 +00:00
|
|
|
$this->optional_attributes = array('assign', 'nocache', 'nofilter', 'modifierlist');
|
2009-03-22 16:09:05 +00:00
|
|
|
// check and get attributes
|
2010-10-25 18:53:43 +00:00
|
|
|
$_attr = $this->_get_attributes($args);
|
|
|
|
// nocache option
|
2009-03-22 16:09:05 +00:00
|
|
|
if (isset($_attr['nocache'])) {
|
|
|
|
if ($_attr['nocache'] == 'true') {
|
2009-04-28 15:37:13 +00:00
|
|
|
$this->compiler->tag_nocache = true;
|
2009-03-22 16:09:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-25 18:53:43 +00:00
|
|
|
// filter handling
|
2009-09-29 21:40:30 +00:00
|
|
|
if (isset($_attr['nofilter'])) {
|
2010-10-25 18:53:43 +00:00
|
|
|
$_filter = 'false';
|
|
|
|
} else {
|
|
|
|
$_filter = 'true';
|
2009-09-29 21:40:30 +00:00
|
|
|
}
|
2009-04-10 01:15:53 +00:00
|
|
|
|
2010-10-25 18:53:43 +00:00
|
|
|
// compiled output
|
2009-03-22 16:09:05 +00:00
|
|
|
if (isset($_attr['assign'])) {
|
|
|
|
// assign output to variable
|
2010-10-25 18:53:43 +00:00
|
|
|
$output = "<?php \$_smarty_tpl->assign({$_attr['assign']},{$_attr['value']});?>";
|
2009-03-22 16:09:05 +00:00
|
|
|
} else {
|
|
|
|
// display value
|
2009-10-20 17:09:22 +00:00
|
|
|
if (isset($this->compiler->smarty->registered_filters['variable'])) {
|
2010-10-25 18:53:43 +00:00
|
|
|
$output = "Smarty_Internal_Filter_Handler::runFilter('variable', {$_attr['value']},\$_smarty_tpl->smarty, \$_smarty_tpl, {$_filter})";
|
2009-10-20 17:09:22 +00:00
|
|
|
} else {
|
2010-05-06 00:11:30 +00:00
|
|
|
$output = $_attr['value'];
|
2009-10-20 17:09:22 +00:00
|
|
|
}
|
2010-10-25 18:53:43 +00:00
|
|
|
if (!isset($_attr['nofilter']) && !empty($this->compiler->smarty->default_modifiers)) {
|
|
|
|
$modifierlist = array();
|
|
|
|
foreach ($this->compiler->smarty->default_modifiers as $key => $single_default_modifier) {
|
|
|
|
preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/', $single_default_modifier, $mod_array);
|
|
|
|
for ($i = 0, $count = count($mod_array[0]);$i < $count;$i++) {
|
|
|
|
if ($mod_array[0][$i] != ':') {
|
|
|
|
$modifierlist[$key][] = $mod_array[0][$i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$output = $this->compiler->compileTag('private_modifier', array('modifierlist' => $modifierlist, 'value' => $output));
|
2010-07-23 12:53:04 +00:00
|
|
|
}
|
2010-10-25 18:53:43 +00:00
|
|
|
if (!empty($_attr['modifierlist'])) {
|
2010-07-23 12:53:04 +00:00
|
|
|
$output = $this->compiler->compileTag('private_modifier', array('modifierlist' => $_attr['modifierlist'], 'value' => $output));
|
2010-05-06 00:11:30 +00:00
|
|
|
}
|
2010-10-25 18:53:43 +00:00
|
|
|
$this->compiler->has_output = true;
|
|
|
|
$output = "<?php echo {$output};?>";
|
2009-03-22 16:09:05 +00:00
|
|
|
}
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-29 15:41:01 +00:00
|
|
|
?>
|