3 * This class simply puts HTML code / JavaScript code or CSS code out to the
6 class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer {
8 * The instance for the singleton design pattern
10 private static $consoleInstance = null;
15 private $vars = array();
22 private function __construct () {
23 // Call parent constructor
24 parent::constructor(__CLASS__);
27 $this->setPartDescr("Console-Ausgabe-Handler");
29 // Create an unique ID
30 $this->createUniqueID();
34 * Create a new web output system and set the content type
36 * @param $contentType A valid content-type
37 * @return $debugInstance An instance of this middleware class
39 public final static function createConsoleOutput ($contentType) {
40 // Cast the content-type to string
41 $contentType = (string) $contentType;
42 $contentType = trim($contentType);
45 self::$consoleInstance = new ConsoleOutput();
47 // Set the content type
48 if (!empty($contentType)) {
49 @header(sprintf("Content-type: %s",
55 return self::$consoleInstance;
59 * Getter for an instance of this class
61 * @return $consoleInstance An instance of this class
63 public final static function getInstance() {
64 if (is_null(self::$consoleInstance)) {
65 $contentType = FrameworkConfiguration::getInstance()->readConfig("web_content_type");
66 self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType);
68 return self::$consoleInstance;
74 * @param $outStream Something we shall sent to the console
77 public final function output ($outStream=false) {
78 if ($outStream === false) {
79 // Output something here...
80 foreach ($this->vars as $var=>$value) {
81 $this->output("var=".$var.", value=".$value."");
84 // Output it to the console
85 printf("%s\n", trim(html_entity_decode(strip_tags($outStream))));
90 * Assigns a variable for output
92 * @param $var The variable we shall assign
93 * @param $value The value to store in the variable
96 public function assignVariable ($var, $value) {
97 $this->vars[$var] = $value;