Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
115 lars 1
<?php
2
    /*
3
    * Smarty plugin
4
    *
5
    -------------------------------------------------------------
6
    * File:     modifier.money_format.php
7
    * Type:     modifier
8
    * Name:     money_format
9
    * Version:  1.0
10
    * Date:     Feb 8th, 2003
11
    * Purpose:  pass value to PHP money_format() and return result
12
    * Install:  Drop into the plugin directory.
13
    * Author:   Michael L. Fladischer <mfladischer@abis.co.at>
14
    *
15
    -------------------------------------------------------------
16
    */
17
    function smarty_modifier_money_format( $string, $places = 2 )
18
    {
19
        if ( !isset( $_SESSION["locale"] ) )
20
        {
21
            $_SESSION["locale"] = "de_DE";
22
        }
23
        setlocale( LC_MONETARY, $_SESSION["locale"] );
24
        if ( phpversion() >= "7.0" )
25
        {
26
            $fmt = new \NumberFormatter( $_SESSION["locale"], NumberFormatter::CURRENCY );
27
            $erg = $fmt->formatCurrency( $string, "EUR" );
28
        }
29
        else
30
        {
31
            $erg = money_format( "%.{$places}i", $string );
32
        }
33
        return $erg;
34
    }
35
 
36
    /* vim: set expandtab: */