Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1371 | Zur aktuellen 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_red( $string, $places = 2, $locale =
18
        "de_DE", $onlySymbol = false, $incSymbol = true, $shortSymbol = false )
19
    {
20
        if ( !$locale )
21
        {
22
            $locale = "de_DE";
23
        }
24
        setlocale( LC_MONETARY, $locale );
25
        if ( $onlySymbol === true )
26
        {
27
            $erg = money_format( "%.0i", $string );
28
            preg_match_all( "/[A-Z]/", $erg, $erg );
29
            $erg = implode( "", $erg[0] );
30
        }
31
        else
32
        {
33
            if ( $incSymbol === true )
34
            {
35
                $erg = money_format( "%.{$places}i", $string );
36
            }
37
            else
38
            {
39
                $erg = money_format( "%!.{$places}i", $string );
40
            }
41
        }
42
        if ( $shortSymbol === true || $onlySymbol === true )
43
        {
44
            preg_match_all( "/[A-Z]/", $erg, $symArr );
45
            $symbol = implode( "", $symArr[0] );
46
            switch ( $symbol )
47
            {
48
                case "EUR":
49
                    $erg = str_replace( "EUR", "&euro;", $erg );
50
                    break;
51
                case "USD":
52
                    $erg = str_replace( "USD", "$", $erg );
53
            }
54
        }
55
        return $erg;
56
    }
57
    /* vim: set expandtab: */
58
?>