]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/class_BaseFrameworkSystem.php
Style convention applied (incomplete), pre/post filters added for form handler
[shipsimu.git] / inc / classes / main / class_BaseFrameworkSystem.php
index 5e923ad937c1c442a27a225f8eb3c01d266a745d..75b851f85ef69b80fd3b5f8d88a652e65d8c1259 100644 (file)
@@ -903,22 +903,67 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        }
 
        /**
-        * Output a partial stub message for the given method name
+        * Output a partial stub message for the caller method
         *
-        * @param       $methodName             Name of the partially finished method
+        * @param       $message        An optional message to display
         * @return      void
         */
-       protected function partialStub ($methodName) {
+       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(sprintf("[%s:] Partial stub!<br />\n",
-                               $methodName
-                       ));
+                       $this->getDebugInstance()->output($stubMessage);
                } else {
                        // Trigger an error
-                       trigger_error(sprintf("[%s:] Partial stub!", $methodName));
+                       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;
        }
 }