OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
oxdiagnosticsoutput.php
Go to the documentation of this file.
1 <?php
2 
10 
16  protected $_sOutputKey = "diagnostic_tool_result";
17 
18 
24  protected $_sOutputFileName = "diagnostic_tool_result.html";
25 
31  protected $_oUtils = null;
32 
36  public function __construct()
37  {
38  $this->_oUtils = oxRegistry::getUtils();
39  }
40 
46  public function setOutputKey( $sOutputKey )
47  {
48  if ( !empty( $sOutputKey ) ) {
49  $this->_sOutputKey = $sOutputKey;
50  }
51  }
52 
58  public function getOutputKey()
59  {
60  return $this->_sOutputKey;
61  }
62 
68  public function setOutputFileName( $sOutputFileName )
69  {
70  if ( !empty( $sOutputFileName ) ) {
71  $this->_sOutputFileName = $sOutputFileName;
72  }
73  }
74 
80  public function getOutputFileName()
81  {
83  }
84 
90  public function storeResult( $sResult )
91  {
92  $this->_oUtils->toFileCache( $this->_sOutputKey, $sBody . $sResult );
93  }
94 
100  public function readResultFile( $sOutputKey = null )
101  {
102  $sCurrentKey = ( empty($sOutputKey) ) ? $this->_sOutputKey : $sOutputKey;
103 
104  return $this->_oUtils->fromFileCache( $sCurrentKey );
105  }
106 
112  public function downloadResultFile( $sOutputKey = null )
113  {
114  $sCurrentKey = ( empty($sOutputKey) ) ? $this->_sOutputKey : $sOutputKey;
115 
116  $this->_oUtils = oxRegistry::getUtils();
117  $iFileSize = filesize( $this->_oUtils->getCacheFilePath( $sCurrentKey ) );
118 
119  $this->_oUtils->setHeader( "Pragma: public" );
120  $this->_oUtils->setHeader( "Expires: 0" );
121  $this->_oUtils->setHeader( "Cache-Control: must-revalidate, post-check=0, pre-check=0, private" );
122  $this->_oUtils->setHeader('Content-Disposition: attachment;filename=' . $this->_sOutputFileName );
123  $this->_oUtils->setHeader( "Content-Type: application/octet-stream" );
124  if ( $iFileSize) {
125  $this->_oUtils->setHeader( "Content-Length: " . $iFileSize );
126  }
127  echo $this->_oUtils->fromFileCache( $sCurrentKey );
128  }
129 }