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