OXID eShop CE  4.9.10
 All Classes Files Functions Variables Pages
oxdiagnosticsoutput.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
17  protected $_sOutputKey = "diagnostic_tool_result";
18 
19 
25  protected $_sOutputFileName = "diagnostic_tool_result.html";
26 
32  protected $_oUtils = null;
33 
37  public function __construct()
38  {
39  $this->_oUtils = oxRegistry::getUtils();
40  }
41 
47  public function setOutputKey($sOutputKey)
48  {
49  if (!empty($sOutputKey)) {
50  $this->_sOutputKey = $sOutputKey;
51  }
52  }
53 
59  public function getOutputKey()
60  {
61  return $this->_sOutputKey;
62  }
63 
69  public function setOutputFileName($sOutputFileName)
70  {
71  if (!empty($sOutputFileName)) {
72  $this->_sOutputFileName = $sOutputFileName;
73  }
74  }
75 
81  public function getOutputFileName()
82  {
84  }
85 
91  public function storeResult($sResult)
92  {
93  $this->_oUtils->toFileCache($this->_sOutputKey, $sResult);
94  }
95 
103  public function readResultFile($sOutputKey = null)
104  {
105  $sCurrentKey = (empty($sOutputKey)) ? $this->_sOutputKey : $sOutputKey;
106 
107  return $this->_oUtils->fromFileCache($sCurrentKey);
108  }
109 
115  public function downloadResultFile($sOutputKey = null)
116  {
117  $sCurrentKey = (empty($sOutputKey)) ? $this->_sOutputKey : $sOutputKey;
118 
119  $this->_oUtils = oxRegistry::getUtils();
120  $iFileSize = filesize($this->_oUtils->getCacheFilePath($sCurrentKey));
121 
122  $this->_oUtils->setHeader("Pragma: public");
123  $this->_oUtils->setHeader("Expires: 0");
124  $this->_oUtils->setHeader("Cache-Control: must-revalidate, post-check=0, pre-check=0, private");
125  $this->_oUtils->setHeader('Content-Disposition: attachment;filename=' . $this->_sOutputFileName);
126  $this->_oUtils->setHeader("Content-Type: application/octet-stream");
127  if ($iFileSize) {
128  $this->_oUtils->setHeader("Content-Length: " . $iFileSize);
129  }
130  echo $this->_oUtils->fromFileCache($sCurrentKey);
131  }
132 }