3 namespace Org\Mxchange\CoreFramework\Output;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
7 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
8 use Org\Mxchange\CoreFramework\Output\BaseOutput;
9 use Org\Mxchange\CoreFramework\Registry\Registerable;
10 use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
13 * This class simply puts HTML code / JavaScript code or CSS code out to the
16 * @author Roland Haeder <webmaster@shipsimu.org>
18 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
19 * @license GNU GPL 3.0 or any newer version
20 * @link http://www.shipsimu.org
22 * This program is free software: you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation, either version 3 of the License, or
25 * (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program. If not, see <http://www.gnu.org/licenses/>.
35 class WebOutput extends BaseOutput implements OutputStreamer, Registerable {
37 * The instance for the singleton design pattern
39 private static $webInstance = NULL;
42 * Protected constructor
46 private function __construct () {
47 // Call parent constructor
48 parent::__construct(__CLASS__);
52 * Create a new web output system and set the content type
54 * @return $webInstance An instance of an OutputStreamer class
56 public static final function createWebOutput () {
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 = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('web_content_type');
65 // Set the content type
66 if (!empty($contentType)) {
68 FrameworkBootstrap::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 (string $outStream = '', bool $stripTags = false) {
84 print(stripslashes($outStream));