[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_compile_private_print_expression.php
1 <?php
2 /**
3 * Smarty Internal Plugin Compile Print Expression
4 *
5 * Compiles any tag which will output an expression or variable
6 *
7 * @package Smarty
8 * @subpackage Compiler
9 * @author Uwe Tews
10 */
11 /**
12 * Smarty Internal Plugin Compile Print Expression Class
13 */
14 class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_CompileBase {
15 /**
16 * Compiles code for gererting output from any expression
17 *
18 * @param array $args array with attributes from parser
19 * @param object $compiler compiler object
20 * @return string compiled code
21 */
22 public function compile($args, $compiler)
23 {
24 $this->compiler = $compiler;
25 $this->required_attributes = array('value');
26 $this->optional_attributes = array('assign', 'nocache', 'filter', 'nofilter');
27 // check and get attributes
28 $_attr = $this->_get_attributes($args);
30 if (isset($_attr['nocache'])) {
31 if ($_attr['nocache'] == 'true') {
32 $this->compiler->tag_nocache = true;
33 }
34 }
36 if (!isset($_attr['filter'])) {
37 $_attr['filter'] = 'null';
38 }
39 if (isset($_attr['nofilter'])) {
40 if ($_attr['nofilter'] == 'true') {
41 $_attr['filter'] = 'false';
42 }
43 }
45 if (isset($_attr['assign'])) {
46 // assign output to variable
47 $output = '<?php $_smarty_tpl->assign(' . $_attr['assign'] . ',' . $_attr['value'] . ');?>';
48 } else {
49 // display value
50 $this->compiler->has_output = true;
51 if (isset($this->compiler->smarty->registered_filters['variable'])) {
52 $output = '<?php echo Smarty_Internal_Filter_Handler::runFilter(\'variable\', ' . $_attr['value'] . ',$_smarty_tpl->smarty, $_smarty_tpl, ' . $_attr['filter'] . ');?>';
53 } else {
54 $output = '<?php echo ' . $_attr['value'] . ';?>';
55 }
56 }
57 return $output;
58 }
59 }
61 ?>