X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fclass_BaseFrameworkSystem.php;h=9c1cf4ca8ce05f6277bb79c3bf323a92de74a010;hp=0eaddce17e5e361d872b15c72af8c3551ee0ee73;hb=33779a34a2a112c3a9a2447ed0a17d296c49b244;hpb=a34a10c85ac693d6d2c183258eb36deb353d003e
diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php
index 0eaddce1..9c1cf4ca 100644
--- a/inc/classes/main/class_BaseFrameworkSystem.php
+++ b/inc/classes/main/class_BaseFrameworkSystem.php
@@ -134,15 +134,35 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
private $helperInstance = null;
/**
- * An instance of a source
+ * An instance of a Sourceable class
*/
private $sourceInstance = null;
+ /**
+ * An instance of a InputStreamable class
+ */
+ private $inputStreamInstance = null;
+
+ /**
+ * An instance of a OutputStreamable class
+ */
+ private $outputStreamInstance = null;
+
+ /**
+ * Networkable handler instance
+ */
+ private $handlerInstance = null;
+
/**
* The real class name
*/
private $realClass = 'BaseFrameworkSystem';
+ /**
+ * An instance of a database wrapper class
+ */
+ private $wrapperInstance = null;
+
/**
* Thousands seperator
*/
@@ -166,6 +186,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
/***********************
* Exception codes.... *
***********************/
+
// @todo Try to clean these constants up
const EXCEPTION_IS_NULL_POINTER = 0x001;
const EXCEPTION_IS_NO_OBJECT = 0x002;
@@ -212,6 +233,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
const EXCEPTION_ATTRIBUTES_ARE_MISSING = 0x02b;
const EXCEPTION_ARRAY_ELEMENTS_MISSING = 0x02c;
const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED = 0x02d;
+ const EXCEPTION_UNSPPORTED_OPERATION = 0x02e;
const EXCEPTION_MISSING_ELEMENT = 0x030;
const EXCEPTION_HEADERS_ALREADY_SENT = 0x031;
const EXCEPTION_DEFAULT_CONTROLLER_GONE = 0x032;
@@ -224,6 +246,46 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039;
const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x040;
+ // Hexadecimal->Decimal translation array
+ private static $hexdec = array(
+ '0' => 0,
+ '1' => 1,
+ '2' => 2,
+ '3' => 3,
+ '4' => 4,
+ '5' => 5,
+ '6' => 6,
+ '7' => 7,
+ '8' => 8,
+ '9' => 9,
+ 'a' => 10,
+ 'b' => 11,
+ 'c' => 12,
+ 'd' => 13,
+ 'e' => 14,
+ 'f' => 15
+ );
+
+ // Decimal->hexadecimal translation array
+ private static $dechex = array(
+ 0 => '0',
+ 1 => '1',
+ 2 => '2',
+ 3 => '3',
+ 4 => '4',
+ 5 => '5',
+ 6 => '6',
+ 7 => '7',
+ 8 => '8',
+ 9 => '9',
+ 10 => 'a',
+ 11 => 'b',
+ 12 => 'c',
+ 13 => 'd',
+ 14 => 'e',
+ 15 => 'f'
+ );
+
/**
* Protected super constructor
*
@@ -328,7 +390,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @return void
*/
public final function __set ($name, $value) {
- $this->debugOutput(sprintf("Tried to set a missing field. name=%s, value[%s]=%s",
+ $this->debugBackTrace(sprintf("Tried to set a missing field. name=%s, value[%s]=%s",
$name,
gettype($value),
$value
@@ -342,7 +404,19 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @return void
*/
public final function __get ($name) {
- $this->debugOutput(sprintf("Tried to get a missing field. name=%s",
+ $this->debugBackTrace(sprintf("Tried to get a missing field. name=%s",
+ $name
+ ));
+ }
+
+ /**
+ * Magic function to catch unsetting of missing fields/attributes
+ *
+ * @param $name Name of the field/attribute
+ * @return void
+ */
+ public final function __unset ($name) {
+ $this->debugBackTrace(sprintf("Tried to unset a missing field. name=%s",
$name
));
}
@@ -862,10 +936,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
/**
* Outputs a debug backtrace and stops further script execution
*
+ * @param $message An optional message to output
* @return void
*/
- public function debugBackTrace () {
+ public function debugBackTrace ($message = '') {
// Sorry, there is no other way getting this nice backtrace
+ if (!empty($message)) {
+ // Output message
+ printf("Message: %s
\n", $message);
+ } // END - if
+
print("
\n"); debug_print_backtrace(); print(""); @@ -1293,8 +1373,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Get current time and add idle time $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, ignore errors + $hasSlept = @time_sleep_until($sleepUntil); } else { // My Sun Station doesn't have that function even with latest PHP // package. :( @@ -1506,12 +1586,60 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Getter for a Sourceable instance + * Getter for a InputStreamable instance * - * @param $sourceInstance The Sourceable instance + * @param $inputStreamInstance The InputStreamable instance + */ + protected final function getInputStreamInstance () { + return $this->inputStreamInstance; + } + + /** + * Setter for a InputStreamable instance + * + * @param $inputStreamInstance The InputStreamable instance + * @return void + */ + protected final function setInputStreamInstance (InputStreamable $inputStreamInstance) { + $this->inputStreamInstance = $inputStreamInstance; + } + + /** + * Getter for a OutputStreamable instance + * + * @param $outputStreamInstance The OutputStreamable instance + */ + protected final function getOutputStreamInstance () { + return $this->outputStreamInstance; + } + + /** + * Setter for a OutputStreamable instance + * + * @param $outputStreamInstance The OutputStreamable instance + * @return void + */ + protected final function setOutputStreamInstance (OutputStreamable $outputStreamInstance) { + $this->outputStreamInstance = $outputStreamInstance; + } + + /** + * Setter for handler instance + * + * @param $handlerInstance A Networkable instance + * @return void */ - protected final function getSourceInstance () { - return $this->sourceInstance; + protected final function setHandlerInstance (Networkable $handlerInstance) { + $this->handlerInstance = $handlerInstance; + } + + /** + * Getter for handler instance + * + * @return $handlerInstance A Networkable instance + */ + protected final function getHandlerInstance () { + return $this->handlerInstance; } /** @@ -1532,6 +1660,191 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { public function getPackageData () { return $this->packageData; } + + /** + * Converts a hexadecimal string, even with negative sign as first string to + * a decimal number using BC functions. + * + * This work is based on comment #86673 on php.net documentation page at: + *