3 namespace CoreFramework\Output\Debug;
5 // Import framework stuff
6 use CoreFramework\Debug\Debugger;
7 use CoreFramework\Output\Debug\BaseDebugOutput;
8 use CoreFramework\Stream\Output\OutputStreamer;
11 * A debug output class for the web browser
13 * @author Roland Haeder <webmaster@shipsimu.org>
15 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
16 * @license GNU GPL 3.0 or any newer version
17 * @link http://www.shipsimu.org
19 * This program is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 class DebugWebOutput extends BaseDebugOutput implements Debugger, OutputStreamer {
34 * Protected constructor
38 protected function __construct () {
39 // Call parent constructor
40 parent::__construct(__CLASS__);
44 * Creates an instance of this class
46 * @return $debugInstance The prepared debug instance
48 public static final function createDebugWebOutput () {
50 $debugInstance = new DebugWebOutput();
53 return $debugInstance;
57 * Outputs the given data directly, ignores $stripTags
59 * @param $output The HTML output
60 * @param $stripTags Whether HTML tags shall be stripped out
63 public final function outputStream ($output, $stripTags = FALSE) {
65 $output = str_replace('<br />', '', $output);
66 print(stripslashes($output)."<br />\n");
72 * @param $outStream Stream to output
73 * @param $stripTags Whether HTML tags shall be stripped out
76 public final function output ($outStream = FALSE, $stripTags = FALSE) {
77 // Empty output will be silently ignored
78 if ($outStream !== FALSE) {
79 $this->outputStream($outStream, $stripTags);
84 * Streams the data and maybe does something to it
86 * @param $data The data (string mostly) to "stream"
87 * @return $data The data (string mostly) to "stream"
88 * @throws UnsupportedOperationException If this method is called
90 public function streamData ($data) {
91 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
92 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
96 * Determines seek position
98 * @return $seekPosition Current seek position
99 * @throws UnsupportedOperationException If this method is called
101 public function determineSeekPosition () {
102 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
106 * Seek to given offset (default) or other possibilities as fseek() gives.
108 * @param $offset Offset to seek to (or used as "base" for other seeks)
109 * @param $whence Added to offset (default: only use offset to seek to)
110 * @return $status Status of file seek: 0 = success, -1 = failed
111 * @throws UnsupportedOperationException If this method is called
113 public function seek ($offset, $whence = SEEK_SET) {
114 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
115 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
121 * @return $size Size (in bytes) of file
122 * @throws UnsupportedOperationException If this method is called
124 public function size () {
125 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);