equal
deleted
inserted
replaced
|
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 $output = $params[0]; |
|
24 if (!isset($params[1])) { |
|
25 $params[1] = "''"; |
|
26 } |
|
27 |
|
28 array_shift($params); |
|
29 foreach ($params as $param) { |
|
30 $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)'; |
|
31 } |
|
32 |
|
33 return $output; |
|
34 } |