doFilterFormatNumber() added
authorRoland Häder <roland@mxchange.org>
Sat, 22 Aug 2009 00:44:48 +0000 (00:44 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 22 Aug 2009 00:44:48 +0000 (00:44 +0000)
inc/classes/main/class_BaseFrameworkSystem.php
inc/config.php

index c085e8e4d4d9667d736f453ad14ed793f8224746..08f63abc3ff49c2b2701642603cc5fddc53fce0b 100644 (file)
@@ -885,7 +885,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        $readable = $this->getLanguageInstance()->getMessage('null_timestamp');
                } else {
                        switch ($this->getLanguageInstance()->getLanguageCode()) {
-                               case "de": // German format is a bit different to default
+                               case 'de': // German format is a bit different to default
                                        // Split the GMT stamp up
                                        $dateTime  = explode(' ', $timestamp  );
                                        $dateArray = explode('-', $dateTime[0]);
@@ -905,13 +905,35 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                                default: // Default is pass-through
                                        $readable = $timestamp;
                                        break;
-                       }
+                       } // END - switch
                }
 
                // Return the stamp
                return $readable;
        }
 
+       /**
+        * Filter a given number into a localized number
+        *
+        * @param       $value          The raw value from e.g. database
+        * @return      $localized      Localized value
+        */
+       public function doFilterFormatNumber ($value) {
+               // Generate it from config and localize depencies
+               switch ($this->getLanguageInstance()->getLanguageCode()) {
+                       case 'de': // German format is a bit different to default
+                               $localized = number_format($value, $this->getConfigInstance()->readConfig('decimals'), ',', '.');
+                               break;
+
+                       default: // US, etc.
+                               $localized = number_format($value, $this->getConfigInstance()->readConfig('decimals'), '.', ',');
+                               break;
+               } // END - switch
+
+               // Return it
+               return $localized;
+       }
+
        /**
         * "Getter" for databse entry
         *
index 3d68249aec9572bde3d78e6999e32eeecdd8b5fd..43401a44eb54b816b7f32026a03fe38ed343d804 100644 (file)
@@ -290,5 +290,8 @@ $cfg->setConfigEntry('german_date_time', "%3\$s.%2\$s.%1\$s, %4\$s:%5\$s:%6\$s")
 // CFG: PRODUCT-INSTALL-MODE
 $cfg->setConfigEntry('product_install_mode', 'debug');
 
+// CFG: DECIMALS
+$cfg->setConfigEntry('decimals', 3);
+
 // [EOF]
 ?>