3 namespace CoreFramework\Output;
5 // Import framework stuff
6 use CoreFramework\Manager\ManageableApplication;
7 use CoreFramework\Output\BaseOutput;
8 use CoreFramework\Registry\Registerable;
9 use CoreFramework\Stream\Output\OutputStreamer;
12 * This class simply puts HTML code / JavaScript code or CSS code out to the
15 * @author Roland Haeder <webmaster@shipsimu.org>
17 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
18 * @license GNU GPL 3.0 or any newer version
19 * @link http://www.shipsimu.org
21 * This program is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 class WebOutput extends BaseOutput implements OutputStreamer, Registerable {
36 * The instance for the singleton design pattern
38 private static $webInstance = NULL;
41 * Protected constructor
45 protected function __construct () {
46 // Call parent constructor
47 parent::__construct(__CLASS__);
51 * Create a new web output system and set the content type
53 * @param $applicationInstance An instance of a ManageableApplication class
54 * @return $debugInstance An instance of this middleware class
56 public static final function createWebOutput (ManageableApplication $applicationInstance) {
57 // Is the self-instance already set?
58 if (is_null(self::$webInstance)) {
59 // Get a new instance and set it
60 self::$webInstance = new WebOutput();
62 // Get the content type
63 $contentType = self::$webInstance->getConfigInstance()->getConfigEntry('web_content_type');
65 // Set the content type
66 if (!empty($contentType)) {
68 $applicationInstance->getResponseInstance()->addHeader('Content-type', $contentType);
73 return self::$webInstance;
79 * @param $outStream Stream to output
80 * @param $stripTags Whether HTML tags shall be stripped out
83 public final function output ($outStream = FALSE, $stripTags = FALSE) {
84 print(stripslashes($outStream));
88 * Determines seek position
90 * @return $seekPosition Current seek position
91 * @throws UnsupportedOperationException If this method is called
93 public function determineSeekPosition () {
94 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
98 * Seek to given offset (default) or other possibilities as fseek() gives.
100 * @param $offset Offset to seek to (or used as "base" for other seeks)
101 * @param $whence Added to offset (default: only use offset to seek to)
102 * @return $status Status of file seek: 0 = success, -1 = failed
103 * @throws UnsupportedOperationException If this method is called
105 public function seek ($offset, $whence = SEEK_SET) {
106 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
107 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
113 * @return $size Size (in bytes) of file
114 * @throws UnsupportedOperationException If this method is called
116 public function size () {
117 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);