3 * Smarty Internal Plugin Compile Print Expression
5 * Compiles any tag which will output an expression or variable
13 * Smarty Internal Plugin Compile Print Expression Class
15 class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_CompileBase {
16 // attribute definitions
17 public $optional_attributes = array('assign');
18 public $option_flags = array('nocache', 'nofilter');
21 * Compiles code for gererting output from any expression
23 * @param array $args array with attributes from parser
24 * @param object $compiler compiler object
25 * @param array $parameter array with compilation parameter
26 * @return string compiled code
28 public function compile($args, $compiler, $parameter)
30 $this->compiler = $compiler;
31 // check and get attributes
32 $_attr = $this->_get_attributes($args);
34 if ($_attr['nocache'] === true) {
35 $this->compiler->tag_nocache = true;
38 if ($_attr['nofilter'] === true) {
45 if (isset($_attr['assign'])) {
46 // assign output to variable
47 $output = "<?php \$_smarty_tpl->assign({$_attr['assign']},{$parameter['value']});?>";
50 if (!$_attr['nofilter'] && isset($this->compiler->smarty->registered_filters['variable'])) {
51 $output = "Smarty_Internal_Filter_Handler::runFilter('variable', {$parameter['value']}, \$_smarty_tpl, {$_filter})";
53 $output = $parameter['value'];
55 if (!$_attr['nofilter'] && !empty($this->compiler->smarty->default_modifiers)) {
56 $modifierlist = array();
57 foreach ($this->compiler->smarty->default_modifiers as $key => $single_default_modifier) {
58 preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/', $single_default_modifier, $mod_array);
59 for ($i = 0, $count = count($mod_array[0]);$i < $count;$i++) {
60 if ($mod_array[0][$i] != ':') {
61 $modifierlist[$key][] = $mod_array[0][$i];
65 $output = $this->compiler->compileTag('private_modifier', array(), array('modifierlist' => $modifierlist, 'value' => $output));
67 if (!empty($parameter['modifierlist'])) {
68 $output = $this->compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifierlist'], 'value' => $output));
70 $this->compiler->has_output = true;
71 $output = "<?php echo {$output};?>";