Continued with logger facility:
authorRoland Haeder <roland@mxchange.org>
Tue, 14 Jul 2015 21:20:40 +0000 (23:20 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 14 Jul 2015 21:20:40 +0000 (23:20 +0200)
- Introduced BaseOutput and BaseDebugOutput
- Moved debug/ classes to outut/debug/<type>/ as <type> can be console, error
  and web (later for HTML/HTTP output; careful, this may break sending HTTP
  headers!)
- Handled over the class' name the logger is being created for (for later
  configuration with XMLs)

Signed-off-by: Roland H├Ąder <roland@mxchange.org>
22 files changed:
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/debug/.htaccess [deleted file]
inc/classes/main/debug/class_DebugConsoleOutput.php [deleted file]
inc/classes/main/debug/class_DebugErrorLogOutput.php [deleted file]
inc/classes/main/debug/class_DebugWebOutput.php [deleted file]
inc/classes/main/output/class_ [new file with mode: 0644]
inc/classes/main/output/class_BaseOutput.php [new file with mode: 0644]
inc/classes/main/output/class_ConsoleOutput.php [deleted file]
inc/classes/main/output/class_WebOutput.php [deleted file]
inc/classes/main/output/console/.htaccess [new file with mode: 0644]
inc/classes/main/output/console/class_ConsoleOutput.php [new file with mode: 0644]
inc/classes/main/output/debug/.htaccess [new file with mode: 0644]
inc/classes/main/output/debug/console/.htaccess [new file with mode: 0644]
inc/classes/main/output/debug/console/class_DebugConsoleOutput.php [new file with mode: 0644]
inc/classes/main/output/debug/error/.htaccess [new file with mode: 0644]
inc/classes/main/output/debug/error/class_DebugErrorLogOutput.php [new file with mode: 0644]
inc/classes/main/output/debug/web/.htaccess [new file with mode: 0644]
inc/classes/main/output/debug/web/class_DebugWebOutput.php [new file with mode: 0644]
inc/classes/main/output/log_file/.htaccess [new file with mode: 0644]
inc/classes/main/output/web/.htaccess [new file with mode: 0644]
inc/classes/main/output/web/class_WebOutput.php [new file with mode: 0644]
inc/classes/middleware/debug/class_DebugMiddleware.php

index 6fa9f3a..2698606 100644 (file)
@@ -1857,7 +1857,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        // Try it
                        try {
                                // Get a debugger instance
-                               $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_class'));
+                               $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_class'), $className);
                        } catch (NullPointerException $e) {
                                // Didn't work, no instance there
                                exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
diff --git a/inc/classes/main/debug/.htaccess b/inc/classes/main/debug/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/inc/classes/main/debug/class_DebugConsoleOutput.php b/inc/classes/main/debug/class_DebugConsoleOutput.php
deleted file mode 100644 (file)
index 285c955..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php
-/**
- * A debug output class for the console (e.g. hub software)
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $debugInstance  The prepared debug instance
-        */
-       public static final function createDebugConsoleOutput () {
-               // Get a new instance
-               $debugInstance = new DebugConsoleOutput();
-
-               // Return it
-               return $debugInstance;
-       }
-
-       /**
-        * Outputs the given data without HTML tags
-        *
-        * @param       $output         The HTML'ed output
-        * @param       $stripTags      Whether HTML tags shall be stripped out
-        * @return      void
-        */
-       public final function outputStream ($output, $stripTags = FALSE) {
-               // Strip HTML tags out?
-               if ($stripTags === TRUE) {
-                       // Prepare the output without HTML tags
-                       $output = trim(html_entity_decode(strip_tags(stripslashes($output))));
-               } else {
-                       // Prepare the output with HTML tags
-                       $output = trim(stripslashes($output));
-               }
-
-               // Are debug times enabled?
-               if ($this->getConfigInstance()->getConfigEntry('debug_output_timings') == 'Y') {
-                       // Output it first
-                       $output = $this->getPrintableExecutionTime() . $output;
-               } // END - if
-
-               // And print it out...
-               printf('%s%s', $output, chr(10));
-       }
-
-       /**
-        * Output the code
-        *
-        * @param       $outStream      Stream to output
-        * @param       $stripTags      Whether HTML tags shall be stripped out
-        * @return      void
-        */
-       public final function output ($outStream = FALSE, $stripTags = FALSE) {
-               // Empty output will be silently ignored
-               if ($outStream !== FALSE) {
-                       $this->outputStream($outStream, $stripTags);
-               } // END - if
-       }
-
-       /**
-        * Streams the data and maybe does something to it
-        *
-        * @param       $data   The data (string mostly) to "stream"
-        * @return      $data   The data (string mostly) to "stream"
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function streamData ($data) {
-               self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Determines seek position
-        *
-        * @return      $seekPosition   Current seek position
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function determineSeekPosition () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Seek to given offset (default) or other possibilities as fseek() gives.
-        *
-        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
-        * @param       $whence         Added to offset (default: only use offset to seek to)
-        * @return      $status         Status of file seek: 0 = success, -1 = failed
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function seek ($offset, $whence = SEEK_SET) {
-               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Size of file stack
-        *
-        * @return      $size   Size (in bytes) of file
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function size () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/debug/class_DebugErrorLogOutput.php b/inc/classes/main/debug/class_DebugErrorLogOutput.php
deleted file mode 100644 (file)
index 7496383..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-/**
- * A debug output class for PHP's error_log() command
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $debugInstance  The prepared debug instance
-        */
-       public static final function createDebugErrorLogOutput () {
-               // Get a new instance
-               $debugInstance = new DebugErrorLogOutput();
-
-               // Return it
-               return $debugInstance;
-       }
-
-       /**
-        * Outputs the given data without HTML tags, ignores $stripTags
-        *
-        * @param       $output         The HTML'ed output
-        * @param       $stripTags      Whether HTML tags shall be stripped out
-        * @return      void
-        */
-       public final function outputStream ($output, $stripTags = FALSE) {
-               // Split multiple lines into and array to put them out line-by-line
-               $errorLines = explode(chr(10), $output);
-
-               // "Walk" through all lines
-               foreach ($errorLines as $err) {
-                       // Trim any spaces, \n, \r etc. out
-                       $err = trim($err);
-
-                       // Log only none-empty lines
-                       if (!empty($err)) {
-                               // Log this line
-                               error_log(html_entity_decode(strip_tags($err)), 0);
-                       } // END - if
-               } // END - foreach
-       }
-
-       /**
-        * Output the code
-        *
-        * @param       $outStream      Stream to output
-        * @param       $stripTags      Whether HTML tags shall be stripped out
-        * @return      void
-        */
-       public final function output ($outStream = FALSE, $stripTags = FALSE) {
-               // Empty output will be silently ignored
-               if ($outStream !== FALSE) {
-                       $this->outputStream($outStream);
-               }
-       }
-
-       /**
-        * Streams the data and maybe does something to it
-        *
-        * @param       $data   The data (string mostly) to "stream"
-        * @return      $data   The data (string mostly) to "stream"
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function streamData ($data) {
-               self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Determines for seek position
-        *
-        * @return      $seekPosition   Current seek position
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function determineSeekPosition () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Seek to given offset (default) or other possibilities as fseek() gives.
-        *
-        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
-        * @param       $whence         Added to offset (default: only use offset to seek to)
-        * @return      $status         Status of file seek: 0 = success, -1 = failed
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function seek ($offset, $whence = SEEK_SET) {
-               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Size of file stack
-        *
-        * @return      $size   Size (in bytes) of file
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function size () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/debug/class_DebugWebOutput.php b/inc/classes/main/debug/class_DebugWebOutput.php
deleted file mode 100644 (file)
index 0da9db7..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-/**
- * A debug output class for the web browser
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $debugInstance  The prepared debug instance
-        */
-       public static final function createDebugWebOutput () {
-               // Get a new instance
-               $debugInstance = new DebugWebOutput();
-
-               // Return it
-               return $debugInstance;
-       }
-
-       /**
-        * Outputs the given data directly, ignores $stripTags
-        *
-        * @param       $output         The HTML output
-        * @param       $stripTags      Whether HTML tags shall be stripped out
-        * @return      void
-        */
-       public final function outputStream ($output, $stripTags = FALSE) {
-               // Strip out <br />
-               $output = str_replace('<br />', '', $output);
-               print(stripslashes($output)."<br />\n");
-       }
-
-       /**
-        * Output the code
-        *
-        * @param       $outStream      Stream to output
-        * @param       $stripTags      Whether HTML tags shall be stripped out
-        * @return      void
-        */
-       public final function output ($outStream = FALSE, $stripTags = FALSE) {
-               // Empty output will be silently ignored
-               if ($outStream !== FALSE) {
-                       $this->outputStream($outStream, $stripTags);
-               } // END - if
-       }
-
-       /**
-        * Streams the data and maybe does something to it
-        *
-        * @param       $data   The data (string mostly) to "stream"
-        * @return      $data   The data (string mostly) to "stream"
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function streamData ($data) {
-               self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Determines seek position
-        *
-        * @return      $seekPosition   Current seek position
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function determineSeekPosition () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Seek to given offset (default) or other possibilities as fseek() gives.
-        *
-        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
-        * @param       $whence         Added to offset (default: only use offset to seek to)
-        * @return      $status         Status of file seek: 0 = success, -1 = failed
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function seek ($offset, $whence = SEEK_SET) {
-               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Size of file stack
-        *
-        * @return      $size   Size (in bytes) of file
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function size () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/output/class_ b/inc/classes/main/output/class_
new file mode 100644 (file)
index 0000000..01161ac
--- /dev/null
@@ -0,0 +1,113 @@
+<?php
+/**
+ * A ??? output class
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Output extends BaseOutput implements OutputStreamer, Registerable {
+       /**
+        * The instance for the singleton design pattern
+        */
+       private static $!!!Instance = NULL;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Create a new !!! output system and set the content type
+        *
+        * @param       $applicationInstance    An instance of a ManageableApplication class
+        * @return      $debugInstance                  An instance of this middleware class
+        */
+       public static final function createWebOutput (ManageableApplication $applicationInstance) {
+               // Is the self-instance already set?
+               if (is_null(self::$!!!Instance)) {
+                       // Get a new instance and set it
+                       self::$!!!Instance = new WebOutput();
+
+                       // Get the content type
+                       $contentType = self::$!!!Instance->getConfigInstance()->getConfigEntry('!!!_content_type');
+
+                       // Set the content type
+                       if (!empty($contentType)) {
+                               // Set the header
+                               $applicationInstance->getResponseInstance()->addHeader('Content-type', $contentType);
+                       } // END - if
+               } // END - if
+
+               // Return instance
+               return self::$!!!Instance;
+       }
+
+       /**
+        * Output the code
+        *
+        * @param       $outStream      Stream to output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
+        * @return      void
+        * @todo        0% done
+        */
+       public final function output ($outStream = FALSE, $stripTags = FALSE) {
+               $this->partialStub('Please implement this method. outStream()=' . strlen($outStream) . ',stripTags=' . intval($stripTags));
+       }
+
+       /**
+        * Determines seek position
+        *
+        * @return      $seekPosition   Current seek position
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function determineSeekPosition () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Seek to given offset (default) or other possibilities as fseek() gives.
+        *
+        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
+        * @param       $whence         Added to offset (default: only use offset to seek to)
+        * @return      $status         Status of file seek: 0 = success, -1 = failed
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function seek ($offset, $whence = SEEK_SET) {
+               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Size of file stack
+        *
+        * @return      $size   Size (in bytes) of file
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function size () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/output/class_BaseOutput.php b/inc/classes/main/output/class_BaseOutput.php
new file mode 100644 (file)
index 0000000..484db42
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Generic output class
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseOutput extends BaseFrameworkSystem {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/output/class_ConsoleOutput.php b/inc/classes/main/output/class_ConsoleOutput.php
deleted file mode 100644 (file)
index e920c6e..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-/**
- * This class simply puts text without any HTML code out. This class is suiable
- * for console output
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer {
-       /**
-        * The instance for the singleton design pattern
-        */
-       private static $consoleInstance = NULL;
-
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Create a new web output system and set the content type
-        *
-        * @param       $contentType    A valid content-type
-        * @return      $debugInstance  An instance of this middleware class
-        */
-       public static final function createConsoleOutput ($contentType) {
-               // Cast the content-type to string
-               $contentType = (string) $contentType;
-               $contentType = trim($contentType);
-
-               // Get instance
-               self::$consoleInstance = new ConsoleOutput();
-
-               // Set the content type
-               // @TODO Need to rewrite this to $requestInstance->addHeader()
-               if (!empty($contentType)) {
-                       @header(sprintf('Content-type: %s',
-                               $contentType
-                       ));
-               } // END - if
-
-               // Return instance
-               return self::$consoleInstance;
-       }
-
-       /**
-        * Getter for an instance of this class
-        *
-        * @return      $consoleInstance        An instance of this class
-        */
-       public static final function getInstance() {
-               // Is the self-instance already set?
-               if (is_null(self::$consoleInstance)) {
-                       $contentType = FrameworkConfiguration::getSelfInstance()->getConfigEntry('web_content_type');
-                       self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType);
-               } // END - if
-
-               // Return the instance
-               return self::$consoleInstance;
-       }
-
-       /**
-        * Output the code
-        *
-        * @param       $outStream      Something we shall sent to the console
-        * @param       $stripTags      Whether HTML tags shall be stripped out
-        * @return      void
-        */
-       public final function output ($outStream = FALSE, $stripTags = FALSE) {
-               print trim($outStream) . PHP_EOL;
-       }
-
-       /**
-        * Determines seek position
-        *
-        * @return      $seekPosition   Current seek position
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function determineSeekPosition () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Seek to given offset (default) or other possibilities as fseek() gives.
-        *
-        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
-        * @param       $whence         Added to offset (default: only use offset to seek to)
-        * @return      $status         Status of file seek: 0 = success, -1 = failed
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function seek ($offset, $whence = SEEK_SET) {
-               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Size of file stack
-        *
-        * @return      $size   Size (in bytes) of file
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function size () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/output/class_WebOutput.php b/inc/classes/main/output/class_WebOutput.php
deleted file mode 100644 (file)
index 58d2db0..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-<?php
-/**
- * This class simply puts HTML code / JavaScript code or CSS code out to the
- * browser
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class WebOutput extends BaseFrameworkSystem implements OutputStreamer, Registerable {
-       /**
-        * The instance for the singleton design pattern
-        */
-       private static $webInstance = NULL;
-
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Create a new web output system and set the content type
-        *
-        * @param       $applicationInstance    An instance of a ManageableApplication class
-        * @return      $debugInstance                  An instance of this middleware class
-        */
-       public static final function createWebOutput (ManageableApplication $applicationInstance) {
-               // Is the self-instance already set?
-               if (is_null(self::$webInstance)) {
-                       // Get a new instance and set it
-                       self::$webInstance = new WebOutput();
-
-                       // Get the content type
-                       $contentType = self::$webInstance->getConfigInstance()->getConfigEntry('web_content_type');
-
-                       // Set the content type
-                       if (!empty($contentType)) {
-                               // Set the header
-                               $applicationInstance->getResponseInstance()->addHeader('Content-type', $contentType);
-                       } // END - if
-               } // END - if
-
-               // Return instance
-               return self::$webInstance;
-       }
-
-       /**
-        * Output the code
-        *
-        * @param       $outStream      Stream to output
-        * @param       $stripTags      Whether HTML tags shall be stripped out
-        * @return      void
-        */
-       public final function output ($outStream = FALSE, $stripTags = FALSE) {
-               print(stripslashes($outStream));
-       }
-
-       /**
-        * Determines seek position
-        *
-        * @return      $seekPosition   Current seek position
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function determineSeekPosition () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Seek to given offset (default) or other possibilities as fseek() gives.
-        *
-        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
-        * @param       $whence         Added to offset (default: only use offset to seek to)
-        * @return      $status         Status of file seek: 0 = success, -1 = failed
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function seek ($offset, $whence = SEEK_SET) {
-               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Size of file stack
-        *
-        * @return      $size   Size (in bytes) of file
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function size () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-}
-
-// [EOF]
-?>
diff --git a/inc/classes/main/output/console/.htaccess b/inc/classes/main/output/console/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/output/console/class_ConsoleOutput.php b/inc/classes/main/output/console/class_ConsoleOutput.php
new file mode 100644 (file)
index 0000000..7d93422
--- /dev/null
@@ -0,0 +1,129 @@
+<?php
+/**
+ * This class simply puts text without any HTML code out. This class is suiable
+ * for console output
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ConsoleOutput extends BaseOutput implements OutputStreamer {
+       /**
+        * The instance for the singleton design pattern
+        */
+       private static $consoleInstance = NULL;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Create a new web output system and set the content type
+        *
+        * @param       $contentType    A valid content-type
+        * @return      $debugInstance  An instance of this middleware class
+        */
+       public static final function createConsoleOutput ($contentType) {
+               // Cast the content-type to string
+               $contentType = (string) $contentType;
+               $contentType = trim($contentType);
+
+               // Get instance
+               self::$consoleInstance = new ConsoleOutput();
+
+               // Set the content type
+               // @TODO Need to rewrite this to $requestInstance->addHeader()
+               if (!empty($contentType)) {
+                       @header(sprintf('Content-type: %s',
+                               $contentType
+                       ));
+               } // END - if
+
+               // Return instance
+               return self::$consoleInstance;
+       }
+
+       /**
+        * Getter for an instance of this class
+        *
+        * @return      $consoleInstance        An instance of this class
+        */
+       public static final function getInstance() {
+               // Is the self-instance already set?
+               if (is_null(self::$consoleInstance)) {
+                       $contentType = FrameworkConfiguration::getSelfInstance()->getConfigEntry('web_content_type');
+                       self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType);
+               } // END - if
+
+               // Return the instance
+               return self::$consoleInstance;
+       }
+
+       /**
+        * Output the code
+        *
+        * @param       $outStream      Something we shall sent to the console
+        * @param       $stripTags      Whether HTML tags shall be stripped out
+        * @return      void
+        */
+       public final function output ($outStream = FALSE, $stripTags = FALSE) {
+               print trim($outStream) . PHP_EOL;
+       }
+
+       /**
+        * Determines seek position
+        *
+        * @return      $seekPosition   Current seek position
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function determineSeekPosition () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Seek to given offset (default) or other possibilities as fseek() gives.
+        *
+        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
+        * @param       $whence         Added to offset (default: only use offset to seek to)
+        * @return      $status         Status of file seek: 0 = success, -1 = failed
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function seek ($offset, $whence = SEEK_SET) {
+               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Size of file stack
+        *
+        * @return      $size   Size (in bytes) of file
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function size () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/output/debug/.htaccess b/inc/classes/main/output/debug/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/output/debug/console/.htaccess b/inc/classes/main/output/debug/console/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/output/debug/console/class_DebugConsoleOutput.php b/inc/classes/main/output/debug/console/class_DebugConsoleOutput.php
new file mode 100644 (file)
index 0000000..d759159
--- /dev/null
@@ -0,0 +1,136 @@
+<?php
+/**
+ * A debug output class for the console (e.g. hub software)
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class DebugConsoleOutput extends BaseDebugOutput implements Debugger, OutputStreamer, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $debugInstance  The prepared debug instance
+        */
+       public static final function createDebugConsoleOutput () {
+               // Get a new instance
+               $debugInstance = new DebugConsoleOutput();
+
+               // Return it
+               return $debugInstance;
+       }
+
+       /**
+        * Outputs the given data without HTML tags
+        *
+        * @param       $output         The HTML'ed output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
+        * @return      void
+        */
+       public final function outputStream ($output, $stripTags = FALSE) {
+               // Strip HTML tags out?
+               if ($stripTags === TRUE) {
+                       // Prepare the output without HTML tags
+                       $output = trim(html_entity_decode(strip_tags(stripslashes($output))));
+               } else {
+                       // Prepare the output with HTML tags
+                       $output = trim(stripslashes($output));
+               }
+
+               // Are debug times enabled?
+               if ($this->getConfigInstance()->getConfigEntry('debug_output_timings') == 'Y') {
+                       // Output it first
+                       $output = $this->getPrintableExecutionTime() . $output;
+               } // END - if
+
+               // And print it out...
+               printf('%s%s', $output, chr(10));
+       }
+
+       /**
+        * Output the code
+        *
+        * @param       $outStream      Stream to output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
+        * @return      void
+        */
+       public final function output ($outStream = FALSE, $stripTags = FALSE) {
+               // Empty output will be silently ignored
+               if ($outStream !== FALSE) {
+                       $this->outputStream($outStream, $stripTags);
+               } // END - if
+       }
+
+       /**
+        * Streams the data and maybe does something to it
+        *
+        * @param       $data   The data (string mostly) to "stream"
+        * @return      $data   The data (string mostly) to "stream"
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function streamData ($data) {
+               self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Determines seek position
+        *
+        * @return      $seekPosition   Current seek position
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function determineSeekPosition () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Seek to given offset (default) or other possibilities as fseek() gives.
+        *
+        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
+        * @param       $whence         Added to offset (default: only use offset to seek to)
+        * @return      $status         Status of file seek: 0 = success, -1 = failed
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function seek ($offset, $whence = SEEK_SET) {
+               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Size of file stack
+        *
+        * @return      $size   Size (in bytes) of file
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function size () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/output/debug/error/.htaccess b/inc/classes/main/output/debug/error/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/output/debug/error/class_DebugErrorLogOutput.php b/inc/classes/main/output/debug/error/class_DebugErrorLogOutput.php
new file mode 100644 (file)
index 0000000..7124250
--- /dev/null
@@ -0,0 +1,133 @@
+<?php
+/**
+ * A debug output class for PHP's error_log() command
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class DebugErrorLogOutput extends BaseDebugOutput implements Debugger, OutputStreamer {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $debugInstance  The prepared debug instance
+        */
+       public static final function createDebugErrorLogOutput () {
+               // Get a new instance
+               $debugInstance = new DebugErrorLogOutput();
+
+               // Return it
+               return $debugInstance;
+       }
+
+       /**
+        * Outputs the given data without HTML tags, ignores $stripTags
+        *
+        * @param       $output         The HTML'ed output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
+        * @return      void
+        */
+       public final function outputStream ($output, $stripTags = FALSE) {
+               // Split multiple lines into and array to put them out line-by-line
+               $errorLines = explode(chr(10), $output);
+
+               // "Walk" through all lines
+               foreach ($errorLines as $err) {
+                       // Trim any spaces, \n, \r etc. out
+                       $err = trim($err);
+
+                       // Log only none-empty lines
+                       if (!empty($err)) {
+                               // Log this line
+                               error_log(html_entity_decode(strip_tags($err)), 0);
+                       } // END - if
+               } // END - foreach
+       }
+
+       /**
+        * Output the code
+        *
+        * @param       $outStream      Stream to output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
+        * @return      void
+        */
+       public final function output ($outStream = FALSE, $stripTags = FALSE) {
+               // Empty output will be silently ignored
+               if ($outStream !== FALSE) {
+                       $this->outputStream($outStream);
+               }
+       }
+
+       /**
+        * Streams the data and maybe does something to it
+        *
+        * @param       $data   The data (string mostly) to "stream"
+        * @return      $data   The data (string mostly) to "stream"
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function streamData ($data) {
+               self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Determines for seek position
+        *
+        * @return      $seekPosition   Current seek position
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function determineSeekPosition () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Seek to given offset (default) or other possibilities as fseek() gives.
+        *
+        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
+        * @param       $whence         Added to offset (default: only use offset to seek to)
+        * @return      $status         Status of file seek: 0 = success, -1 = failed
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function seek ($offset, $whence = SEEK_SET) {
+               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Size of file stack
+        *
+        * @return      $size   Size (in bytes) of file
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function size () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/output/debug/web/.htaccess b/inc/classes/main/output/debug/web/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/output/debug/web/class_DebugWebOutput.php b/inc/classes/main/output/debug/web/class_DebugWebOutput.php
new file mode 100644 (file)
index 0000000..b8c34cb
--- /dev/null
@@ -0,0 +1,122 @@
+<?php
+/**
+ * A debug output class for the web browser
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class DebugWebOutput extends BaseDebugOutput implements Debugger, OutputStreamer {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $debugInstance  The prepared debug instance
+        */
+       public static final function createDebugWebOutput () {
+               // Get a new instance
+               $debugInstance = new DebugWebOutput();
+
+               // Return it
+               return $debugInstance;
+       }
+
+       /**
+        * Outputs the given data directly, ignores $stripTags
+        *
+        * @param       $output         The HTML output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
+        * @return      void
+        */
+       public final function outputStream ($output, $stripTags = FALSE) {
+               // Strip out <br />
+               $output = str_replace('<br />', '', $output);
+               print(stripslashes($output)."<br />\n");
+       }
+
+       /**
+        * Output the code
+        *
+        * @param       $outStream      Stream to output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
+        * @return      void
+        */
+       public final function output ($outStream = FALSE, $stripTags = FALSE) {
+               // Empty output will be silently ignored
+               if ($outStream !== FALSE) {
+                       $this->outputStream($outStream, $stripTags);
+               } // END - if
+       }
+
+       /**
+        * Streams the data and maybe does something to it
+        *
+        * @param       $data   The data (string mostly) to "stream"
+        * @return      $data   The data (string mostly) to "stream"
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function streamData ($data) {
+               self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Determines seek position
+        *
+        * @return      $seekPosition   Current seek position
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function determineSeekPosition () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Seek to given offset (default) or other possibilities as fseek() gives.
+        *
+        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
+        * @param       $whence         Added to offset (default: only use offset to seek to)
+        * @return      $status         Status of file seek: 0 = success, -1 = failed
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function seek ($offset, $whence = SEEK_SET) {
+               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Size of file stack
+        *
+        * @return      $size   Size (in bytes) of file
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function size () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/output/log_file/.htaccess b/inc/classes/main/output/log_file/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/output/web/.htaccess b/inc/classes/main/output/web/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/output/web/class_WebOutput.php b/inc/classes/main/output/web/class_WebOutput.php
new file mode 100644 (file)
index 0000000..76f9be5
--- /dev/null
@@ -0,0 +1,113 @@
+<?php
+/**
+ * This class simply puts HTML code / JavaScript code or CSS code out to the
+ * browser
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class WebOutput extends BaseOutput implements OutputStreamer, Registerable {
+       /**
+        * The instance for the singleton design pattern
+        */
+       private static $webInstance = NULL;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Create a new web output system and set the content type
+        *
+        * @param       $applicationInstance    An instance of a ManageableApplication class
+        * @return      $debugInstance                  An instance of this middleware class
+        */
+       public static final function createWebOutput (ManageableApplication $applicationInstance) {
+               // Is the self-instance already set?
+               if (is_null(self::$webInstance)) {
+                       // Get a new instance and set it
+                       self::$webInstance = new WebOutput();
+
+                       // Get the content type
+                       $contentType = self::$webInstance->getConfigInstance()->getConfigEntry('web_content_type');
+
+                       // Set the content type
+                       if (!empty($contentType)) {
+                               // Set the header
+                               $applicationInstance->getResponseInstance()->addHeader('Content-type', $contentType);
+                       } // END - if
+               } // END - if
+
+               // Return instance
+               return self::$webInstance;
+       }
+
+       /**
+        * Output the code
+        *
+        * @param       $outStream      Stream to output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
+        * @return      void
+        */
+       public final function output ($outStream = FALSE, $stripTags = FALSE) {
+               print(stripslashes($outStream));
+       }
+
+       /**
+        * Determines seek position
+        *
+        * @return      $seekPosition   Current seek position
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function determineSeekPosition () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Seek to given offset (default) or other possibilities as fseek() gives.
+        *
+        * @param       $offset         Offset to seek to (or used as "base" for other seeks)
+        * @param       $whence         Added to offset (default: only use offset to seek to)
+        * @return      $status         Status of file seek: 0 = success, -1 = failed
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function seek ($offset, $whence = SEEK_SET) {
+               self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Size of file stack
+        *
+        * @return      $size   Size (in bytes) of file
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function size () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+}
+
+// [EOF]
+?>
index 328281b..1f6c6b3 100644 (file)
@@ -55,26 +55,44 @@ class DebugMiddleware extends BaseMiddleware implements Registerable {
         * If no output is given this class is currently being used for back-fall.
         * This fall-back mechanism will become deprecated very soon.
         *
-        * @param       $debuggerClass  The class name which we shall use for
+        * @param       $outputClass    The class name which we shall use for
         *                                                      registering the *real* debug output
+        * @param       $className              Class where a output should be created and
+        *                                                      configured for
         * @return      $debugInstance  An instance of this middleware class
         */
-       public static final function createDebugMiddleware ($debuggerClass) {
+       public static final function createDebugMiddleware ($outputClass, $className) {
+               die(__METHOD__.': outputClass=' . $outputClass . ',className=' . $className);
                // Create an instance if this middleware
                $debugInstance = new DebugMiddleware();
 
+               // Default is that $outputClass may be invalid
+               $isInitialized = FALSE;
+
                // Is there a valid output instance provided?
-               if ((!is_null($debuggerClass)) && (is_object($debuggerClass)) && ($debuggerClass instanceof OutputStreamer)) {
+               if ((!is_null($outputClass)) && (is_object($outputClass)) && ($outputClass instanceof OutputStreamer)) {
                        // Use the given output instance
-                       $debugInstance->setOutputInstance($debuggerClass);
-               } elseif ((!is_null($debuggerClass)) && (is_string($debuggerClass)) && (class_exists($debuggerClass))) {
+                       $debugInstance->setOutputInstance($outputClass);
+
+                       // All fine
+                       $isInitialized = TRUE;
+               } elseif ((!is_null($outputClass)) && (is_string($outputClass)) && (class_exists($outputClass))) {
                        // A name for a debug output class has been provided so we try to get it
-                       $debuggerInstance = ObjectFactory::createObjectByName($debuggerClass);
+                       $outputInstance = ObjectFactory::createObjectByName($outputClass);
 
                        // Set this as output class
-                       $debugInstance->setOutputInstance($debuggerInstance);
+                       $debugInstance->setOutputInstance($outputInstance);
+
+                       // All fine
+                       $isInitialized = TRUE;
                }
 
+               // Is the output class initialized?
+               if ($isInitialized === TRUE) {
+                       // Then set class name
+                       $debugInstance->getOutputInstance()->setLoggerClassName($className);
+               } // END - if
+
                // Return instance
                return $debugInstance;
        }