]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/class_BaseFrameworkSystem.php
Fixed criteria handling
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
index d8e2e330cff94a270e2cc0374e0f7d597ca95668..679e5e4af81ee8c9586a6afcdb22c62702362ebc 100644 (file)
@@ -163,6 +163,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $visitorInstance = NULL;
 
+       /**
+        * DHT instance
+        */
+       private $dhtInstance = NULL;
+
        /**
         * An instance of a database wrapper class
         */
@@ -992,19 +997,19 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        }
 
        /**
-        * Setter for BaseDatabaseWrapper instance
+        * Setter for DatabaseWrapper instance
         *
-        * @param       $wrapperInstance        An instance of an BaseDatabaseWrapper
+        * @param       $wrapperInstance        An instance of an DatabaseWrapper
         * @return      void
         */
-       public final function setWrapperInstance (BaseDatabaseWrapper $wrapperInstance) {
+       public final function setWrapperInstance (DatabaseWrapper $wrapperInstance) {
                $this->wrapperInstance = $wrapperInstance;
        }
 
        /**
-        * Getter for BaseDatabaseWrapper instance
+        * Getter for DatabaseWrapper instance
         *
-        * @return      $wrapperInstance        An instance of an BaseDatabaseWrapper
+        * @return      $wrapperInstance        An instance of an DatabaseWrapper
         */
        public final function getWrapperInstance () {
                return $this->wrapperInstance;
@@ -1145,6 +1150,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $this->visitorInstance;
        }
 
+       /**
+        * Setter for DHT instance
+        *
+        * @param       $dhtInstance    A Distributable instance
+        * @return      void
+        */
+       protected final function setDhtInstance (Distributable $dhtInstance) {
+               $this->dhtInstance = $dhtInstance;
+       }
+
+       /**
+        * Getter for DHT instance
+        *
+        * @return      $dhtInstance    A Distributable instance
+        */
+       protected final function getDhtInstance () {
+               return $this->dhtInstance;
+       }
+
        /**
         * Setter for raw package Data
         *
@@ -1388,7 +1412,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @param       $doExit         Whether exit the program (true is default)
         * @return      void
         */
-       public function debugBackTrace ($message = '', $doExit = true) {
+       public function debugBackTrace ($message = '', $doExit = TRUE) {
                // Sorry, there is no other way getting this nice backtrace
                if (!empty($message)) {
                        // Output message
@@ -1827,8 +1851,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        }
 
        /**
-        * Converts even very large decimal numbers, also with negative sign, to a
-        * hexadecimal string.
+        * Converts even very large decimal numbers, also signed, to a hexadecimal
+        * string.
         *
         * This work is based on comment #97756 on php.net documentation page at:
         * <http://de.php.net/manual/en/function.hexdec.php#97756>
@@ -1851,18 +1875,20 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Encode the decimal number into a hexadecimal string
                $hex = '';
                do {
-                       $hex = self::$dechex[($dec % 16)] . $hex;
-                       $dec /= 16;
+                       $hex = self::$dechex[($dec % (2 ^ 4))] . $hex;
+                       $dec /= (2 ^ 4);
                } while ($dec >= 1);
 
                /*
-                * We need hexadecimal strings with leading zeros if the length cannot
-                * be divided by 2
+                * Leading zeros are required for hex-decimal "numbers". In some
+                * situations more leading zeros are wanted, so check for both
+                * conditions.
                 */
                if ($maxLength > 0) {
                        // Prepend more zeros
-                       $hex = $this->prependStringToString($hex, '0', $maxLength);
+                       $hex = str_pad($hex, $maxLength, '0', STR_PAD_LEFT);
                } elseif ((strlen($hex) % 2) != 0) {
+                       // Only make string's length dividable by 2
                        $hex = '0' . $hex;
                }
 
@@ -1930,41 +1956,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $asc;
        }
 
-       /**
-        * Prepends a given string $prepend to $str with a given total length
-        *
-        * @param       $str            Given original string which should be prepended
-        * @param       $prepend        The string to prepend
-        * @param       $length         Total length of the final string
-        * @return      $strFinal       Final prepended string
-        */
-       protected function prependStringToString ($str, $prepend, $length) {
-               // Set final string to original string by default
-               $strFinal = $str;
-
-               // Can it devided
-               if (strlen($str) < $length) {
-                       // Difference between total length and length of original string
-                       $diff = $length - strlen($str);
-
-                       // Prepend the string
-                       $prepend = str_repeat($prepend, ($diff / strlen($prepend) + 1));
-
-                       // Make sure it will definedly fit
-                       assert(strlen($prepend) >= $diff);
-
-                       // Cut it a little down
-                       $prepend = substr($prepend, 0, $diff);
-                       //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('prepend('.strlen($prepend).')='.$prepend.',diff='.$diff.',length='.$length);
-
-                       // Construct the final prepended string
-                       $strFinal = $prepend . $str;
-               } // END - if
-
-               // Return it
-               return $strFinal;
-       }
-
        /**
         * Checks whether the given encoded data was encoded with Base64
         *