OXID eShop CE  4.10.4
 All Classes Namespaces Files Functions Variables Pages
oxoutput.php
Go to the documentation of this file.
1 <?php
2 
7 class oxOutput extends oxSuperCfg
8 {
9 
10  const OUTPUT_FORMAT_HTML = 'html';
11  const OUTPUT_FORMAT_JSON = 'json';
12 
18  protected $_blSearchEngine = false;
19 
25  protected $_sCharset = null;
26 
33 
39  protected $_aBuffer = array();
40 
46  public function __construct()
47  {
48  $this->setIsSearchEngine(oxRegistry::getUtils()->isSearchEngine());
49  }
50 
56  public function setIsSearchEngine($blOn)
57  {
58  $this->_blSearchEngine = $blOn;
59  }
60 
70  public function process($sValue, $sClassName)
71  {
72  $myConfig = $this->getConfig();
73 
74  //fix for euro currency problem (it's invisible in some older browsers)
75  if (!$myConfig->getConfigParam('blSkipEuroReplace') && !$myConfig->isUtf()) {
76  $sValue = str_replace('�', '&euro;', $sValue);
77  }
78 
79  return $sValue;
80  }
81 
89  final public function addVersionTags($sOutput)
90  {
91  // DISPLAY IT
92  $sVersion = $this->getConfig()->getVersion();
93  $sEdition = $this->getConfig()->getFullEdition();
94  $sCurYear = date("Y");
95  $sShopMode = "";
96 
97  // SHOW ONLY MAJOR VERSION NUMBER
98  $aVersion = explode('.', $sVersion);
99  $sMajorVersion = reset($aVersion);
100 
101 
102  // Replacing only once per page
103  $sSearch = "</head>";
104  $sReplace = "</head>\n <!-- OXID eShop {$sEdition}, Version {$sMajorVersion}{$sShopMode}, Shopping Cart System (c) OXID eSales AG 2003 - {$sCurYear} - http://www.oxid-esales.com -->";
105 
106  $sOutput = ltrim($sOutput);
107  if (($pos = stripos($sOutput, $sSearch)) !== false) {
108  $sOutput = substr_replace($sOutput, $sReplace, $pos, strlen($sSearch));
109  }
110 
111  return $sOutput;
112  }
113 
123  public function processViewArray($aViewData, $sClassName)
124  {
125  return $aViewData;
126  }
127 
133  public function processEmail(& $oEmail)
134  {
135  // #669 PHP5 claims that you cant pas full this but should instead pass reference what is anyway a much better idea
136  // removed "return" as by reference you dont need any return
137 
138  }
139 
140 
146  public function setCharset($sCharset)
147  {
148  $this->_sCharset = $sCharset;
149  }
150 
156  public function setOutputFormat($sFormat)
157  {
158  $this->_sOutputFormat = $sFormat;
159  }
160 
167  public function output($sName, $output)
168  {
169  switch ($this->_sOutputFormat) {
170  case self::OUTPUT_FORMAT_JSON:
171  $this->_aBuffer[$sName] = $output;
172  break;
173  case self::OUTPUT_FORMAT_HTML:
174  default:
175  echo $output;
176  break;
177  }
178  }
179 
183  public function flushOutput()
184  {
185  switch ($this->_sOutputFormat) {
186  case self::OUTPUT_FORMAT_JSON:
187  echo getStr()->jsonEncode($this->_aBuffer);
188  break;
189  case self::OUTPUT_FORMAT_HTML:
190  default:
191  break;
192  }
193  }
194 
198  public function sendHeaders()
199  {
200  switch ($this->_sOutputFormat) {
201  case self::OUTPUT_FORMAT_JSON:
202  oxRegistry::getUtils()->setHeader("Content-Type: application/json; charset=" . $this->_sCharset);
203  break;
204  case self::OUTPUT_FORMAT_HTML:
205  default:
206  oxRegistry::getUtils()->setHeader("Content-Type: text/html; charset=" . $this->_sCharset);
207  break;
208  }
209  }
210 }