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