oxoutput.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxOutput extends oxSuperCfg
00008 {
00009 
00010     const OUTPUT_FORMAT_HTML = 'html';
00011     const OUTPUT_FORMAT_JSON = 'json';
00012 
00018     protected $_blSearchEngine = false;
00019 
00025     protected $_sCharset = null;
00026 
00032     protected $_sOutputFormat = self::OUTPUT_FORMAT_HTML;
00033 
00039     protected $_aBuffer = array();
00040 
00046     public function __construct()
00047     {
00048         $this->setIsSearchEngine(oxRegistry::getUtils()->isSearchEngine());
00049     }
00050 
00056     public function setIsSearchEngine($blOn)
00057     {
00058         $this->_blSearchEngine = $blOn;
00059     }
00060 
00070     public function process($sValue, $sClassName)
00071     {
00072         $myConfig = $this->getConfig();
00073 
00074         //fix for euro currency problem (it's invisible in some older browsers)
00075         if (!$myConfig->getConfigParam('blSkipEuroReplace') && !$myConfig->isUtf()) {
00076             $sValue = str_replace('�', '&euro;', $sValue);
00077         }
00078 
00079         return $sValue;
00080     }
00081 
00089     final public function addVersionTags($sOutput)
00090     {
00091         // DISPLAY IT
00092         $sVersion = $this->getConfig()->getVersion();
00093         $sEdition = $this->getConfig()->getFullEdition();
00094         $sCurYear = date("Y");
00095         $sShopMode = "";
00096 
00097         // SHOW ONLY MAJOR VERSION NUMBER
00098         $aVersion = explode('.', $sVersion);
00099         $sMajorVersion = reset($aVersion);
00100 
00101 
00102         // Replacing only once per page
00103         $sSearch = "</head>";
00104         $sReplace = "</head>\n  <!-- OXID eShop {$sEdition}, Version {$sMajorVersion}{$sShopMode}, Shopping Cart System (c) OXID eSales AG 2003 - {$sCurYear} - http://www.oxid-esales.com -->";
00105 
00106         $sOutput = ltrim($sOutput);
00107         if (($pos = stripos($sOutput, $sSearch)) !== false) {
00108             $sOutput = substr_replace($sOutput, $sReplace, $pos, strlen($sSearch));
00109         }
00110 
00111         return $sOutput;
00112     }
00113 
00123     public function processViewArray($aViewData, $sClassName)
00124     {
00125         return $aViewData;
00126     }
00127 
00133     public function processEmail(& $oEmail)
00134     {
00135         // #669 PHP5 claims that you cant pas full this but should instead pass reference what is anyway a much better idea
00136         // removed "return" as by reference you dont need any return
00137 
00138     }
00139 
00140 
00146     public function setCharset($sCharset)
00147     {
00148         $this->_sCharset = $sCharset;
00149     }
00150 
00156     public function setOutputFormat($sFormat)
00157     {
00158         $this->_sOutputFormat = $sFormat;
00159     }
00160 
00167     public function output($sName, $output)
00168     {
00169         switch ($this->_sOutputFormat) {
00170             case self::OUTPUT_FORMAT_JSON:
00171                 $this->_aBuffer[$sName] = $output;
00172                 break;
00173             case self::OUTPUT_FORMAT_HTML:
00174             default:
00175                 echo $output;
00176                 break;
00177         }
00178     }
00179 
00183     public function flushOutput()
00184     {
00185         switch ($this->_sOutputFormat) {
00186             case self::OUTPUT_FORMAT_JSON:
00187                 echo getStr()->jsonEncode($this->_aBuffer);
00188                 break;
00189             case self::OUTPUT_FORMAT_HTML:
00190             default:
00191                 break;
00192         }
00193     }
00194 
00198     public function sendHeaders()
00199     {
00200         switch ($this->_sOutputFormat) {
00201             case self::OUTPUT_FORMAT_JSON:
00202                 oxRegistry::getUtils()->setHeader("Content-Type: application/json; charset=" . $this->_sCharset);
00203                 break;
00204             case self::OUTPUT_FORMAT_HTML:
00205             default:
00206                 oxRegistry::getUtils()->setHeader("Content-Type: text/html; charset=" . $this->_sCharset);
00207                 break;
00208         }
00209     }
00210 }