]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/class_BaseFrameworkSystem.php
Factory renamed, emails can now be unique in game
[shipsimu.git] / inc / classes / main / class_BaseFrameworkSystem.php
index c1f216eee8f143fe14afa661d16bac5f7944b40d..1ccb1c2c765fdb5d588fad9b0a122e9cd0676dc2 100644 (file)
@@ -288,16 +288,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        // Initialize debug instance
                        if (is_null($this->getDebugInstance())) {
                                // Set the debug output system if it is not debug class ;)
-                               $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig("debug_engine")));
+                               $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig('debug_engine')));
                        }
 
                        // Initialize web instance
                        if (is_null($this->getWebOutputInstance())) {
                                // Generate the eval() command
                                $eval = sprintf("\$this->setWebOutputInstance(%s::create%s(\"%s\"));",
-                                       $this->getConfigInstance()->readConfig("web_engine"),
-                                       $this->getConfigInstance()->readConfig("web_engine"),
-                                       $this->getConfigInstance()->readConfig("web_content_type")
+                                       $this->getConfigInstance()->readConfig('web_engine'),
+                                       $this->getConfigInstance()->readConfig('web_engine'),
+                                       $this->getConfigInstance()->readConfig('web_content_type')
                                );
 
                                // Debug message
@@ -315,7 +315,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                                // Set the compressor channel
                                $this->setCompressorChannel(CompressorChannel::createCompressorChannel(sprintf("%s%s",
                                        PATH,
-                                       $this->getConfigInstance()->readConfig("compressor_base_path")
+                                       $this->getConfigInstance()->readConfig('compressor_base_path')
                                )));
                        }
 
@@ -839,9 +839,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Generate FQFN for all application templates
                $fqfn = sprintf("%s%s/%s/%s",
                        PATH,
-                       $this->getConfigInstance()->readConfig("application_path"),
+                       $this->getConfigInstance()->readConfig('application_path'),
                        strtolower($appInstance->getAppShortName()),
-                       $this->getConfigInstance()->readConfig("tpl_base_path")
+                       $this->getConfigInstance()->readConfig('tpl_base_path')
                );
 
                // Are both instances set?
@@ -860,8 +860,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        \$appInstance->getLanguageInstance(),
        \$appInstance->getFileIoInstance()
 );",
-                       $this->getConfigInstance()->readConfig("tpl_engine"),
-                       $this->getConfigInstance()->readConfig("tpl_engine"),
+                       $this->getConfigInstance()->readConfig('tpl_engine'),
+                       $this->getConfigInstance()->readConfig('tpl_engine'),
                        $fqfn
                );
 
@@ -896,10 +896,76 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        public final function debugInstance () {
                // Generate the output
-               $content = "<pre>".trim(print_r($this, true))."</pre>";
+               $content = sprintf("<pre>%s</pre>",
+                       trim(print_r($this, true))
+               );
 
                // Output it
-               ApplicationEntryPoint::app_die("<strong>Debug output:</strong>".$content);
+               ApplicationEntryPoint::app_die(sprintf("<strong>%s debug output:</strong>%s", $this->__toString(), $content));
+       }
+
+       /**
+        * Output a partial stub message for the caller method
+        *
+        * @param       $message        An optional message to display
+        * @return      void
+        */
+       protected function partialStub ($message = "") {
+               // Get the backtrace
+               $backtrace = debug_backtrace();
+
+               // Generate the class::method string
+               $methodName = "UnknownClass::unknownMethod";
+               if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) {
+                       $methodName = $backtrace[1]['class']."::".$backtrace[1]['function'];
+               }
+
+               // Construct the full message
+               $stubMessage = sprintf("[%s:] Partial stub!",
+                       $methodName
+               );
+
+               // Is the extra message given?
+               if (!empty($message)) {
+                       // Then add it as well
+                       $stubMessage .= sprintf(" Message: <u>%s</u>", $message);
+               }
+
+               // Debug instance is there?
+               if (!is_null($this->getDebugInstance())) {
+                       // Output stub message
+                       $this->getDebugInstance()->output($stubMessage);
+               } else {
+                       // Trigger an error
+                       trigger_error($stubMessage."<br />\n");
+               }
+       }
+
+       /**
+        * Converts e.g. a command from URL to a valid class by keeping out bad characters
+        *
+        * @param       $str            The string, what ever it is needs to be converted
+        * @return      $className      Generated class name
+        */
+       public function convertToClassName ($str) {
+               $className = "";
+               foreach (explode("_", $str) as $strPart) {
+                       $className .= ucfirst(strtolower($strPart));
+               }
+               return $className;
+       }
+
+       /**
+        * Outputs a debug backtrace and stops further script execution
+        *
+        * @return      void
+        */
+       public function debugBacktrace () {
+               // Sorry, there is no other way getting this nice backtrace
+               print "<pre>\n";
+               debug_print_backtrace();
+               print "</pre>";
+               exit;
        }
 }