oxdiagnosticsoutput.php

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