3 namespace CoreFramework\Output\Debug;
6 * A debug output class for the web browser
8 * @author Roland Haeder <webmaster@shipsimu.org>
10 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
11 * @license GNU GPL 3.0 or any newer version
12 * @link http://www.shipsimu.org
14 * This program is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 class DebugWebOutput extends BaseDebugOutput implements Debugger, OutputStreamer {
29 * Protected constructor
33 protected function __construct () {
34 // Call parent constructor
35 parent::__construct(__CLASS__);
39 * Creates an instance of this class
41 * @return $debugInstance The prepared debug instance
43 public static final function createDebugWebOutput () {
45 $debugInstance = new DebugWebOutput();
48 return $debugInstance;
52 * Outputs the given data directly, ignores $stripTags
54 * @param $output The HTML output
55 * @param $stripTags Whether HTML tags shall be stripped out
58 public final function outputStream ($output, $stripTags = FALSE) {
60 $output = str_replace('<br />', '', $output);
61 print(stripslashes($output)."<br />\n");
67 * @param $outStream Stream to output
68 * @param $stripTags Whether HTML tags shall be stripped out
71 public final function output ($outStream = FALSE, $stripTags = FALSE) {
72 // Empty output will be silently ignored
73 if ($outStream !== FALSE) {
74 $this->outputStream($outStream, $stripTags);
79 * Streams the data and maybe does something to it
81 * @param $data The data (string mostly) to "stream"
82 * @return $data The data (string mostly) to "stream"
83 * @throws UnsupportedOperationException If this method is called
85 public function streamData ($data) {
86 self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
87 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
91 * Determines seek position
93 * @return $seekPosition Current seek position
94 * @throws UnsupportedOperationException If this method is called
96 public function determineSeekPosition () {
97 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
101 * Seek to given offset (default) or other possibilities as fseek() gives.
103 * @param $offset Offset to seek to (or used as "base" for other seeks)
104 * @param $whence Added to offset (default: only use offset to seek to)
105 * @return $status Status of file seek: 0 = success, -1 = failed
106 * @throws UnsupportedOperationException If this method is called
108 public function seek ($offset, $whence = SEEK_SET) {
109 self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
110 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
116 * @return $size Size (in bytes) of file
117 * @throws UnsupportedOperationException If this method is called
119 public function size () {
120 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);