modifiercompiler.default.php 785 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Smarty plugin
  4. *
  5. * @package Smarty
  6. * @subpackage PluginsModifierCompiler
  7. */
  8. /**
  9. * Smarty default modifier plugin
  10. *
  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. * @param array $params parameters
  18. * @return string with compiled code
  19. */
  20. function smarty_modifiercompiler_default ($params, $compiler)
  21. {
  22. $output = $params[0];
  23. if (!isset($params[1])) {
  24. $params[1] = "''";
  25. }
  26. array_shift($params);
  27. foreach ($params as $param) {
  28. $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
  29. }
  30. return $output;
  31. }
  32. ?>