]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/class_BaseFrameworkSystem.php
doFilterFormatNumber() added
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
index e3001112979257da96a5ceca6cede76469d6416f..08f63abc3ff49c2b2701642603cc5fddc53fce0b 100644 (file)
@@ -83,6 +83,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $iteratorInstance = null;
 
         */
        private $iteratorInstance = null;
 
+       /**
+        * Instance of the list
+        */
+       private $listInstance = null;
+
        /**
         * The real class name
         */
        /**
         * The real class name
         */
@@ -880,7 +885,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        $readable = $this->getLanguageInstance()->getMessage('null_timestamp');
                } else {
                        switch ($this->getLanguageInstance()->getLanguageCode()) {
                        $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]);
                                        // Split the GMT stamp up
                                        $dateTime  = explode(' ', $timestamp  );
                                        $dateArray = explode('-', $dateTime[0]);
@@ -900,13 +905,35 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                                default: // Default is pass-through
                                        $readable = $timestamp;
                                        break;
                                default: // Default is pass-through
                                        $readable = $timestamp;
                                        break;
-                       }
+                       } // END - switch
                }
 
                // Return the stamp
                return $readable;
        }
 
                }
 
                // 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
         *
        /**
         * "Getter" for databse entry
         *
@@ -961,6 +988,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 
                // Get current array
                $fieldArray = $resultInstance->current();
 
                // Get current array
                $fieldArray = $resultInstance->current();
+               //* DEBUG: */ $this->debugOutput($fieldName.':<pre>'.print_r($fieldArray, true).'</pre>');
 
                // Does the field exist?
                if (isset($fieldArray[$fieldName])) {
 
                // Does the field exist?
                if (isset($fieldArray[$fieldName])) {
@@ -1145,7 +1173,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Idle so long with found function
                if (function_exists('time_sleep_until')) {
                        // Get current time and add idle time
                // Idle so long with found function
                if (function_exists('time_sleep_until')) {
                        // Get current time and add idle time
-                       $sleepUntil = $this->getMilliTime() + $milliSeconds / 1000;
+                       $sleepUntil = $this->getMilliTime() + abs($milliSeconds) / 1000;
 
                        // New PHP 5.1.0 function found
                        $hasSlept = time_sleep_until($sleepUntil);
 
                        // New PHP 5.1.0 function found
                        $hasSlept = time_sleep_until($sleepUntil);
@@ -1158,6 +1186,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Return result
                return $hasSlept;
        }
                // Return result
                return $hasSlept;
        }
+
+       /**
+        * Setter for the list instance
+        *
+        * @param       $listInstance   A list of Listable
+        * @return      void
+        */
+       protected final function setListInstance (Listable $listInstance) {
+               $this->listInstance = $listInstance;
+       }
+
+       /**
+        * Getter for the list instance
+        *
+        * @return      $listInstance   A list of Listable
+        */
+       protected final function getListInstance () {
+               return $this->listInstance;
+       }
 }
 
 // [EOF]
 }
 
 // [EOF]