Initial import of current development status
[shipsimu.git] / ship-simu / inc / classes / main / output / class_WebOutput.php
1 <?php
2 /**
3  * This class simply puts HTML code / JavaScript code or CSS code out to the
4  * browser
5  */
6 class WebOutput extends BaseFrameworkSystem implements OutputStreamer {
7         /**
8          * The instance for the singleton design pattern
9          */
10         private static $webInstance = null;
11
12         /**
13          * Private constructor
14          *
15          * @return      void
16          */
17         private function __construct () {
18                 // Call parent constructor
19                 parent::constructor(__CLASS__);
20
21                 // Set description
22                 $this->setPartDescr("Web-Ausgabe-Handler");
23
24                 // Create an unique ID
25                 $this->createUniqueID();
26         }
27
28         /**
29          * Create a new web output system and set the content type
30          *
31          * @param               $contentType            A valid content-type
32          * @return      $debugInstance          An instance of this middleware class
33          */
34         public final static function createWebOutput ($contentType) {
35                 // Is there no instance?
36                 if (is_null(self::$webInstance)) {
37                         // Cast the content-type to string and trim it
38                         $contentType = (string) $contentType;
39                         $contentType = trim($contentType);
40
41                         // Set the content type
42                         if (!empty($contentType)) {
43                                 @header(sprintf("Content-type: %s",
44                                         $contentType
45                                 ));
46                         }
47
48                         // Get a new instance and set it
49                         self::$webInstance = new WebOutput();
50                 }
51
52                 // Return instance
53                 return self::$webInstance;
54         }
55
56         /**
57          * Assigns a variable for output
58          *
59          * @param               $var            The variable we shall assign
60          * @param               $value  The value to store in the variable
61          * @return      void
62          */
63         public function assignVariable($var, $value) {
64                 // Stub message because we don't have it here
65                 trigger_error(__METHOD__.": Stub!");
66         }
67
68         /**
69          * Output the code
70          *
71          * @return      void
72          */
73         public final function output ($outStream=false) {
74                 print $outStream;
75         }
76 }
77
78 // [EOF]
79 ?>