modifier.money_format.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2015 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 
12 /*
13 * Smarty plugin
14 * -------------------------------------------------------------
15 * File: modifier.modifier_money_format.php
16 * Type: function
17 * Name: modifier_money_format
18 * Purpose: pass a value to the PHP function money_format
19 * Usage: e.g. {$number|money_format:2:,:.}
20 * -------------------------------------------------------------
21 */
22 function smarty_modifier_money_format($number, $leftFill='0') {
23  if (function_exists('money_format')) {
24  setlocale(LC_MONETARY, 'de_DE.UTF8');
25  $format = (!empty($leftFill))?'%!#'.$leftFill.'n':'%!n';
26  return str_replace(' ','&nbsp;',money_format($format, $number));
27  }
28  else {
29  return $number;
30  }
31 }
32 ?>