3 * This class simply puts text without any HTML code out. This class is suiable
6 * @author Roland Haeder <webmaster@ship-simu.org>
8 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Core Developer Team
9 * @license GNU GPL 3.0 or any newer version
10 * @link http://www.ship-simu.org
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer {
27 * The instance for the singleton design pattern
29 private static $consoleInstance = null;
32 * Protected constructor
36 protected function __construct () {
37 // Call parent constructor
38 parent::__construct(__CLASS__);
42 * Create a new web output system and set the content type
44 * @param $contentType A valid content-type
45 * @return $debugInstance An instance of this middleware class
47 public static final function createConsoleOutput ($contentType) {
48 // Cast the content-type to string
49 $contentType = (string) $contentType;
50 $contentType = trim($contentType);
53 self::$consoleInstance = new ConsoleOutput();
55 // Set the content type
56 // @TODO Need to rewrite this to $requestInstance->addHeader()
57 if (!empty($contentType)) {
58 @header(sprintf("Content-type: %s",
64 return self::$consoleInstance;
68 * Getter for an instance of this class
70 * @return $consoleInstance An instance of this class
72 public static final function getInstance() {
73 // Is the self-instance already set?
74 if (is_null(self::$consoleInstance)) {
75 $contentType = FrameworkConfiguration::getInstance()->getConfigEntry('web_content_type');
76 self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType);
79 // Return the instance
80 return self::$consoleInstance;
86 * @param $outStream Something we shall sent to the console
89 public final function output ($outStream = false) {
90 print trim($outStream) . "\n";