1: <?php
2: /**
3: * Smarty plugin
4: *
5: * @package Smarty
6: * @subpackage PluginsModifierCompiler
7: */
8:
9: /**
10: * Smarty default modifier plugin
11: * Type: modifier<br>
12: * Name: default<br>
13: * Purpose: designate default value for empty variables
14: *
15: * @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
16: * @author Uwe Tews
17: *
18: * @param array $params parameters
19: *
20: * @return string with compiled code
21: */
22: function smarty_modifiercompiler_default($params)
23: {
24: $output = $params[0];
25: if (!isset($params[1])) {
26: $params[1] = "''";
27: }
28:
29: array_shift($params);
30: foreach ($params as $param) {
31: $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
32: }
33:
34: return $output;
35: }
36: