OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
oxoutput.php
Go to the documentation of this file.
1 <?php
2 
7 class oxOutput extends oxSuperCfg
8 {
9  const OUTPUT_FORMAT_HTML = 'html';
10  const OUTPUT_FORMAT_JSON = 'json';
11 
17  protected $_blSearchEngine = false;
18 
24  protected $_sCharset = null;
25 
32 
38  protected $_aBuffer = array();
39 
45  public function __construct()
46  {
47  $this->setIsSearchEngine( oxRegistry::getUtils()->isSearchEngine() );
48  }
49 
57  public function setIsSearchEngine( $blOn )
58  {
59  $this->_blSearchEngine = $blOn;
60  }
61 
71  public function process( $sValue, $sClassName )
72  {
73  $myConfig = $this->getConfig();
74 
75  //fix for euro currency problem (it's invisible in some older browsers)
76  if ( !$myConfig->getConfigParam( 'blSkipEuroReplace' ) && !$myConfig->isUtf() ) {
77  $sValue = str_replace( '�', '&euro;', $sValue );
78  }
79 
80  return $sValue;
81  }
82 
90  final public function addVersionTags( $sOutput )
91  {
92  // DISPLAY IT
93  $sVersion = $this->getConfig()->getVersion();
94  $sEdition = $this->getConfig()->getFullEdition();
95  $sCurYear = date("Y");
96  $sShopMode = "";
97 
98  // SHOW ONLY MAJOR VERSION NUMBER
99  $aVersion = explode('.', $sVersion);
100  $sMajorVersion = reset($aVersion);
101 
102 
103  // Replacing only once per page
104  $sSearch = "</head>";
105  $sReplace = "</head>\n <!-- OXID eShop {$sEdition}, Version {$sMajorVersion}{$sShopMode}, Shopping Cart System (c) OXID eSales AG 2003 - {$sCurYear} - http://www.oxid-esales.com -->";
106 
107  $sOutput = ltrim($sOutput);
108  if ( ($pos = stripos( $sOutput, $sSearch )) !== false) {
109  $sOutput = substr_replace($sOutput, $sReplace, $pos, strlen($sSearch));
110  }
111 
112  return $sOutput;
113  }
114 
124  public function processViewArray($aViewData, $sClassName)
125  {
126  return $aViewData;
127  }
128 
136  public function processEmail( & $oEmail)
137  {
138  // #669 PHP5 claims that you cant pas full this but should instead pass reference what is anyway a much better idea
139  // dodger: removed "return" as by reference you dont need any return
140 
141  }
142 
143 
151  public function setCharset($sCharset)
152  {
153  $this->_sCharset = $sCharset;
154  }
155 
163  public function setOutputFormat($sFormat)
164  {
165  $this->_sOutputFormat = $sFormat;
166  }
167 
176  public function output($sName, $output)
177  {
178  switch ($this->_sOutputFormat) {
179  case self::OUTPUT_FORMAT_JSON:
180  $this->_aBuffer[$sName] = $output;
181  break;
182  case self::OUTPUT_FORMAT_HTML:
183  default:
184  echo $output;
185  break;
186  }
187  }
188 
194  public function flushOutput()
195  {
196  switch ($this->_sOutputFormat) {
197  case self::OUTPUT_FORMAT_JSON:
198  echo getStr()->jsonEncode($this->_aBuffer);
199  break;
200  case self::OUTPUT_FORMAT_HTML:
201  default:
202  break;
203  }
204  }
205 
211  public function sendHeaders()
212  {
213  switch ($this->_sOutputFormat) {
214  case self::OUTPUT_FORMAT_JSON:
215  oxRegistry::getUtils()->setHeader( "Content-Type: application/json; charset=".$this->_sCharset );
216  break;
217  case self::OUTPUT_FORMAT_HTML:
218  default:
219  oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".$this->_sCharset );
220  break;
221  }
222  }
223 }