X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fclass_BaseFrameworkSystem.php;h=7a43629c0abf8dc23034e7b64f7bee5dab8d63d4;hp=70ab046529da504a28c0a40d9e4d74e996bf4021;hb=76d80add86d84cb1933df9be7c4332693b4940b3;hpb=36a96a3b68cb6da4e1b431fbc5983821de918618
diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php
index 70ab0465..7a43629c 100644
--- a/inc/classes/main/class_BaseFrameworkSystem.php
+++ b/inc/classes/main/class_BaseFrameworkSystem.php
@@ -78,6 +78,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
*/
private $rngInstance = null;
+ /**
+ * Instance of a crypto helper
+ */
+ private $cryptoInstance = null;
+
/**
* Instance of an Iterator class
*/
@@ -123,11 +128,36 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
*/
private $databaseInstance = null;
+ /**
+ * A helper instance for the form
+ */
+ private $helperInstance = null;
+
+ /**
+ * 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;
+
/**
* The real class name
*/
private $realClass = 'BaseFrameworkSystem';
+ /**
+ * An instance of a database wrapper class
+ */
+ private $wrapperInstance = null;
+
/**
* Thousands seperator
*/
@@ -151,6 +181,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;
@@ -197,6 +228,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;
@@ -209,6 +241,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
*
@@ -219,9 +291,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
// Set real class
$this->setRealClass($className);
- // Set configuration instance if no registry
+ // Set configuration instance if no registry ...
if (!$this instanceof Register) {
- // Because registries doesn't need to be configured
+ // ... because registries doesn't need to be configured
$this->setConfigInstance(FrameworkConfiguration::getInstance());
} // END - if
}
@@ -230,7 +302,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* Destructor reached...
*
* @return void
- * @todo This is old code. Do we still need this old lost code?
*/
public function __destruct() {
// Flush any updated entries to the database
@@ -250,8 +321,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
}
/**
- * The call method where all non-implemented methods end up
+ * The __call() method where all non-implemented methods end up
*
+ * @param $methodName Name of the missing method
+ * @args $args Arguments passed to the method
* @return void
*/
public final function __call ($methodName, $args) {
@@ -267,7 +340,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
$argsString .= $this->replaceControlCharacters($arg) . ' (' . gettype($arg);
// Add length if type is string
- if (gettype($arg) == 'string') $argsString .= ', '.strlen($arg);
+ if (is_string($arg)) {
+ $argsString .= ', '.strlen($arg);
+ } // END - if
// Closing bracket
$argsString .= '), ';
@@ -293,6 +368,54 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
return null;
}
+ /**
+ * Getter for $realClass
+ *
+ * @return $realClass The name of the real class (not BaseFrameworkSystem)
+ */
+ public function __toString () {
+ return $this->realClass;
+ }
+
+ /**
+ * Magic function to catch setting of missing but set class fields/attributes
+ *
+ * @param $name Name of the field/attribute
+ * @param $value Value to store
+ * @return void
+ */
+ public final function __set ($name, $value) {
+ $this->debugBackTrace(sprintf("Tried to set a missing field. name=%s, value[%s]=%s",
+ $name,
+ gettype($value),
+ $value
+ ));
+ }
+
+ /**
+ * Magic function to catch getting of missing fields/attributes
+ *
+ * @param $name Name of the field/attribute
+ * @return void
+ */
+ public final function __get ($name) {
+ $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
+ ));
+ }
+
/**
* Setter for database result instance
*
@@ -554,15 +677,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
return $this->responseInstance;
}
- /**
- * Getter for $realClass
- *
- * @return $realClass The name of the real class (not BaseFrameworkSystem)
- */
- public function __toString () {
- return $this->realClass;
- }
-
/**
* Setter for the real class name
*
@@ -699,10 +813,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @param $applicationInstance An application helper instance or
* null if we shall use the default
* @return $templateInstance The template engine instance
- * @throws NullPointerException If the template engine could not
- * be initialized
- * @throws UnsupportedTemplateEngineException If $templateInstance is an
- * unsupported template engine
* @throws NullPointerException If the discovered application
* instance is still null
*/
@@ -794,7 +904,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
// Generate the class::method string
$methodName = 'UnknownClass->unknownMethod';
if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) {
- $methodName = $backtrace[1]['class']."->".$backtrace[1]['function'];
+ $methodName = $backtrace[1]['class'] . '->' . $backtrace[1]['function'];
} // END - if
// Construct the full message
@@ -814,17 +924,23 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
$this->debugOutput($stubMessage);
} else {
// Trigger an error
- trigger_error($stubMessage."
\n");
+ trigger_error($stubMessage . "
\n");
}
}
/**
* 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(""); @@ -846,7 +962,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (is_object($debugInstance)) { // Use debug output handler $debugInstance->output($message); - if ($doPrint === false) die(); // Die here if not printed + + if ($doPrint === false) { + // Die here if not printed + die(); + } // END - if } else { // Put directly out if ($doPrint === true) { @@ -1141,7 +1261,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->debugOutput($message); } else { // Trigger an error - trigger_error($message."