Code merged from ship-simu repository
[mailer.git] / inc / classes / main / class_BaseFrameworkSystem.php
index 31feceef559119b4ed21fa2743f5c8e21bf31848..d4eabd793f3564724250b78ec9e669c6f592b56e 100644 (file)
@@ -78,6 +78,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $userInstance = null;
 
+       /**
+        * A controller instance
+        */
+       private $controllerInstance = null;
+
        /**
         * The real class name
         */
@@ -192,8 +197,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
        }
@@ -748,14 +754,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)
@@ -818,7 +834,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                print("<pre>\n");
                debug_print_backtrace();
                print("</pre>");
-               exit;
+               exit();
        }
 
        /**
@@ -836,7 +852,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) {
@@ -971,7 +987,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
 
@@ -1036,6 +1052,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        public final function getUserInstance () {
                return $this->userInstance;
        }
+
+       /**
+        * Setter for controller instance (this surely breaks a bit the MVC patterm)
+        *
+        * @param       $controllerInstance             An instance of the controller
+        * @return      void
+        */
+       public final function setControllerInstance (Controller $controllerInstance) {
+               $this->controllerInstance = $controllerInstance;
+       }
+
+       /**
+        * Getter for controller instance (this surely breaks a bit the MVC patterm)
+        *
+        * @return      $controllerInstance             An instance of the controller
+        */
+       public final function getControllerInstance () {
+               return $this->controllerInstance;
+       }
 }
 
 // [EOF]