oxoutput.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxOutput extends oxSuperCfg
00008 {
00009     const OUTPUT_FORMAT_HTML = 'html';
00010     const OUTPUT_FORMAT_JSON = 'json';
00011 
00017     protected $_blSearchEngine = false;
00018 
00024     protected $_sCharset = null;
00025 
00031     protected $_sOutputFormat = self::OUTPUT_FORMAT_HTML;
00032 
00038     protected $_aBuffer = array();
00039 
00045     public function __construct()
00046     {
00047         $this->setIsSearchEngine( oxUtils::getInstance()->isSearchEngine() );
00048     }
00049 
00057     public function setIsSearchEngine( $blOn )
00058     {
00059         $this->_blSearchEngine = $blOn;
00060     }
00061 
00071     public function process( $sValue, $sClassName )
00072     {
00073         $myConfig = $this->getConfig();
00074 
00075         //fix for euro currency problem (it's invisible in some older browsers)
00076         if ( !$myConfig->getConfigParam( 'blSkipEuroReplace' ) && !$myConfig->isUtf() ) {
00077             $sValue = str_replace( '�', '&euro;', $sValue );
00078         }
00079 
00080         return $sValue;
00081     }
00082 
00090     final public function addVersionTags( $sOutput )
00091     {
00092         // DISPLAY IT
00093         $sVersion  = $this->getConfig()->getVersion();
00094         $sEdition  = $this->getConfig()->getFullEdition();
00095         $sCurYear  = date("Y");
00096         $sShopMode = "";
00097 
00098         // SHOW ONLY MAJOR VERSION NUMBER
00099         $aVersion = explode('.', $sVersion);
00100         $sMajorVersion = reset($aVersion);
00101 
00102 
00103         // Replacing only once per page
00104         $sOutput = str_ireplace("</head>", "</head>\n  <!-- OXID eShop {$sEdition}, Version {$sMajorVersion}{$sShopMode}, Shopping Cart System (c) OXID eSales AG 2003 - {$sCurYear} - http://www.oxid-esales.com -->", ltrim($sOutput));
00105 
00106         return $sOutput;
00107     }
00108 
00118     public function processViewArray($aViewData, $sClassName)
00119     {
00120         return $aViewData;
00121     }
00122 
00130     public function processEmail( & $oEmail)
00131     {
00132         // #669 PHP5 claims that you cant pas full this but should instead pass reference what is anyway a much better idea
00133         // dodger: removed "return" as by reference you dont need any return
00134 
00135     }
00136 
00137 
00145     public function setCharset($sCharset)
00146     {
00147         $this->_sCharset = $sCharset;
00148     }
00149 
00157     public function setOutputFormat($sFormat)
00158     {
00159         $this->_sOutputFormat = $sFormat;
00160     }
00161 
00170     public function output($sName, $output)
00171     {
00172         switch ($this->_sOutputFormat) {
00173             case self::OUTPUT_FORMAT_JSON:
00174                 $this->_aBuffer[$sName] = $output;
00175                 break;
00176             case self::OUTPUT_FORMAT_HTML:
00177             default:
00178                 echo $output;
00179                 break;
00180         }
00181     }
00182 
00188     public function flushOutput()
00189     {
00190         switch ($this->_sOutputFormat) {
00191             case self::OUTPUT_FORMAT_JSON:
00192                 echo getStr()->jsonEncode($this->_aBuffer);
00193                 break;
00194             case self::OUTPUT_FORMAT_HTML:
00195             default:
00196                 break;
00197         }
00198     }
00199 
00205     public function sendHeaders()
00206     {
00207         switch ($this->_sOutputFormat) {
00208             case self::OUTPUT_FORMAT_JSON:
00209                 oxUtils::getInstance()->setHeader( "Content-Type: application/json; charset=".$this->_sCharset );
00210                 break;
00211             case self::OUTPUT_FORMAT_HTML:
00212             default:
00213                 oxUtils::getInstance()->setHeader( "Content-Type: text/html; charset=".$this->_sCharset );
00214                 break;
00215         }
00216     }
00217 }