oxdiagnosticsoutput.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class oxDiagnosticsOutput {
00010 
00016     protected $_sOutputKey             = "diagnostic_tool_result";
00017 
00018 
00024     protected $_sOutputFileName        = "diagnostic_tool_result.html";
00025 
00031     protected $_oUtils = null;
00032 
00036     public function __construct()
00037     {
00038         $this->_oUtils = oxRegistry::getUtils();
00039     }
00040 
00046     public function setOutputKey( $sOutputKey )
00047     {
00048         if ( !empty( $sOutputKey ) ) {
00049             $this->_sOutputKey = $sOutputKey;
00050         }
00051     }
00052 
00058     public function getOutputKey()
00059     {
00060         return $this->_sOutputKey;
00061     }
00062 
00068     public function setOutputFileName( $sOutputFileName )
00069     {
00070         if ( !empty( $sOutputFileName ) ) {
00071             $this->_sOutputFileName = $sOutputFileName;
00072         }
00073     }
00074 
00080     public function getOutputFileName()
00081     {
00082         return $this->_sOutputFileName;
00083     }
00084 
00090     public function storeResult( $sResult )
00091     {
00092         $this->_oUtils->toFileCache( $this->_sOutputKey, $sBody . $sResult );
00093     }
00094 
00100     public function readResultFile( $sOutputKey = null )
00101     {
00102         $sCurrentKey = ( empty($sOutputKey) ) ?  $this->_sOutputKey : $sOutputKey;
00103 
00104         return $this->_oUtils->fromFileCache( $sCurrentKey );
00105     }
00106 
00112     public function downloadResultFile( $sOutputKey = null )
00113     {
00114         $sCurrentKey = ( empty($sOutputKey) ) ?  $this->_sOutputKey : $sOutputKey;
00115 
00116         $this->_oUtils = oxRegistry::getUtils();
00117         $iFileSize = filesize( $this->_oUtils->getCacheFilePath( $sCurrentKey ) );
00118 
00119         $this->_oUtils->setHeader( "Pragma: public" );
00120         $this->_oUtils->setHeader( "Expires: 0" );
00121         $this->_oUtils->setHeader( "Cache-Control: must-revalidate, post-check=0, pre-check=0, private" );
00122         $this->_oUtils->setHeader('Content-Disposition: attachment;filename=' . $this->_sOutputFileName );
00123         $this->_oUtils->setHeader( "Content-Type: application/octet-stream" );
00124         if ( $iFileSize) {
00125             $this->_oUtils->setHeader( "Content-Length: " . $iFileSize );
00126         }
00127         echo $this->_oUtils->fromFileCache( $sCurrentKey );
00128     }
00129 }