class_ConsoleOutput.php
Go to the documentation of this file.00001 <?php
00025 class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer {
00029 private static $consoleInstance = null;
00030
00034 private $vars = array();
00035
00041 protected function __construct () {
00042
00043 parent::__construct(__CLASS__);
00044 }
00045
00052 public final static function createConsoleOutput ($contentType) {
00053
00054 $contentType = (string) $contentType;
00055 $contentType = trim($contentType);
00056
00057
00058 self::$consoleInstance = new ConsoleOutput();
00059
00060
00061 if (!empty($contentType)) {
00062 @header(sprintf("Content-type: %s",
00063 $contentType
00064 ));
00065 }
00066
00067
00068 return self::$consoleInstance;
00069 }
00070
00076 public final static function getInstance() {
00077 if (is_null(self::$consoleInstance)) {
00078 $contentType = FrameworkConfiguration::getInstance()->readConfig('web_content_type');
00079 self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType);
00080 }
00081 return self::$consoleInstance;
00082 }
00083
00090 public final function output ($outStream=false) {
00091 if ($outStream === false) {
00092
00093 foreach ($this->vars as $var => $value) {
00094 $this->output("var=".$var.", value=".$value."");
00095 }
00096 } else {
00097
00098 printf("%s\n", trim(html_entity_decode(strip_tags(stripslashes($outStream)))));
00099 }
00100 }
00101
00109 public function assignVariable ($var, $value) {
00110 $this->vars[$var] = $value;
00111 }
00112 }
00113
00114
00115 ?>