// 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());
+++ /dev/null
-Deny from all
+++ /dev/null
-<?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]
-?>
+++ /dev/null
-<?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]
-?>
+++ /dev/null
-<?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]
-?>
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
+++ /dev/null
-<?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]
-?>
+++ /dev/null
-<?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]
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
* 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;
}