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