]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/class_BaseFrameworkSystem.php
Typos fixed and special command resolver are now possible
[shipsimu.git] / inc / classes / main / class_BaseFrameworkSystem.php
index 198280bd430a4044918eb05421f3f00b0e0e571a..0c490f1ee7d1d7362552cd75eb3a2548df527264 100644 (file)
@@ -192,8 +192,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Set real class
                $this->setRealClass($className);
 
-               // Initialize the class if the registry is there
+               // Initialize the class if class Registry is there
                if ((class_exists('Registry')) && (Registry::isInitialized() === false)) {
+                       // Initialize the registry automatically
                        $this->initInstance();
                } // END - if
        }
@@ -211,7 +212,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        $this->setRealClass('DestructedObject');
                } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
                        // Already destructed object
-                       $this->debugOutput(sprintf("[%s:] The object <strong>%s</strong> is already destroyed.",
+                       $this->debugOutput(sprintf("[%s:] The object <span class=\"object_name\">%s</span> is already destroyed.",
                                __CLASS__, $this->__toString()
                        ));
                }
@@ -232,7 +233,13 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        // Some arguments are there
                        foreach ($args as $arg) {
                                // Add the type
-                               $argsString .= $arg." (".gettype($arg)."), ";
+                               $argsString .= $arg." (".gettype($arg);
+
+                               // Add length if type is string
+                               if (gettype($arg) == 'string') $argsString .= ", ".strlen($arg);
+
+                               // Closing bracket
+                               $argsString .= "), ";
                        } // END - foreach
 
                        // Remove last comma
@@ -263,6 +270,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        private final function initInstance () {
                // Is this a system class?
                if (!in_array($this->__toString(), $this->systemClasses)) {
+                       // Set configuration instance
+                       $this->setConfigInstance(FrameworkConfiguration::getInstance());
+
                        // Add application helper to our class
                        $this->systemclasses[] = $this->getConfigInstance()->readConfig('app_helper_class');
 
@@ -275,7 +285,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 
                        // Set the compressor channel
                        $this->setCompressorChannel(CompressorChannel::createCompressorChannel(sprintf("%s%s",
-                               PATH,
+                               $this->getConfigInstance()->readConfig('base_path'),
                                $this->getConfigInstance()->readConfig('compressor_base_path')
                        )));
 
@@ -283,7 +293,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        Registry::isInitialized('OK');
                } elseif ($this->__toString() == 'DebugMiddleware') {
                        // Set configuration instance
-                       $this->setConfigInstance(FrameworkConfiguration::createFrameworkConfiguration());
+                       $this->setConfigInstance(FrameworkConfiguration::getInstance());
                }
        }
 
@@ -551,25 +561,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                $this->realClass = $realClass;
        }
 
-       /**
-        * Compare if both simulation part description and class name matches
-        * (shall be enough)
-        *
-        * @param       $itemInstance   An object instance to an other class
-        * @return      boolean                 The result of comparing class name simulation part description
-        * @deprecated
-        */
-       public function itemMatches ($itemInstance) {
-               $this->partialStub("Deprecated!");
-               return (
-                       (
-                               $this->__toString()   == $itemInstance->__toString()
-                       ) && (
-                               $this->getObjectDescription() == $itemInstance->getObjectDescription()
-                       )
-               );
-       }
-
        /**
         * Compare class name of this and given class name
         *
@@ -584,6 +575,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * Stub method (only real cabins shall override it)
         *
         * @return      boolean false = is no cabin, true = is a cabin
+        * @deprecated
         */
        public function isCabin () {
                return false;
@@ -594,6 +586,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         *
         * @return      boolean false = is not tradeable by the Merchant class,
         *                                      true  = is a tradeable object
+        * @deprecated
         */
        public function isTradeable () {
                return false;
@@ -731,8 +724,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                } // END - if
 
                // Generate FQFN for all application templates
-               $fqfn = sprintf("%s%s/%s/%s",
-                       PATH,
+               $fqfn = sprintf("%s%s/%s",
                        $this->getConfigInstance()->readConfig('application_path'),
                        strtolower($appInstance->getAppShortName()),
                        $this->getConfigInstance()->readConfig('tpl_base_path')
@@ -757,14 +749,24 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        /**
         * Debugs this instance by putting out it's full content
         *
+        * @param       $message        Optional message to show in debug output
         * @return      void
         */
-       public final function debugInstance () {
+       public final function debugInstance ($message = "") {
                // Restore the error handler to avoid trouble with missing array elements or undeclared variables
                restore_error_handler();
 
+               // Init content
+               $content = "";
+
+               // Is a message set?
+               if (!empty($message)) {
+                       // Construct message
+                       $content = sprintf("<div class=\"debug_message\">Message: %s</div>\n", $message);
+               } // END - if
+
                // Generate the output
-               $content = sprintf("<pre>%s</pre>",
+               $content .= sprintf("<pre>%s</pre>",
                        trim(
                                htmlentities(
                                        print_r($this, true)
@@ -773,7 +775,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                );
 
                // Output it
-               ApplicationEntryPoint::app_die(sprintf("<strong>%s debug output:</strong><div id=\"debug_content\">%s</div>\nLoaded includes: <div id=\"debug_include_list\">%s</div>",
+               ApplicationEntryPoint::app_die(sprintf("<div class=\"debug_header\">%s debug output:</div><div class=\"debug_content\">%s</div>\nLoaded includes: <div class=\"debug_include_list\">%s</div>",
                        $this->__toString(),
                        $content,
                        ClassLoader::getInstance()->getPrintableIncludeList()
@@ -824,9 +826,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        public function debugBackTrace () {
                // Sorry, there is no other way getting this nice backtrace
-               print "<pre>\n";
+               print("<pre>\n");
                debug_print_backtrace();
-               print "</pre>";
+               print("</pre>");
                exit;
        }
 
@@ -845,7 +847,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                if (is_object($debugInstance)) {
                        // Use debug output handler
                        $debugInstance->output($message);
-                       if (!$doPrint) die(); // Die here if not printed
+                       if ($doPrint === false) die(); // Die here if not printed
                } else {
                        // Put directly out
                        if ($doPrint) {
@@ -905,7 +907,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                } // END - if
 
                // Add line number to the code
-               foreach (explode("\n", $phpCode) as $lineNo=>$code) {
+               foreach (explode("\n", $phpCode) as $lineNo => $code) {
                        // Add line numbers
                        $markedCode .= sprintf("<span id=\"code_line\">%s</span>: %s\n",
                                ($lineNo + 1),
@@ -980,7 +982,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                $this->getResultInstance()->rewind();
 
                // Do we have an entry?
-               if (!$this->getResultInstance()->valid()) {
+               if ($this->getResultInstance()->valid() === false) {
                        throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
                } // END - if