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