1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
<?php
require_once("PHPReportsUtil.php");
/******************************************************************************
* *
* PHPReportMaker *
* This is the base class of the output plugins. They need to extends this *
* class. *
* *
******************************************************************************/
class PHPReportOutputObject {
var $_sInput;
var $_sOutput;
var $_bClean;
var $_bJump;
var $_bBody;
/***************************************************************************
* *
* Constructor, put default values *
* *
***************************************************************************/
function PHPReportOutputObject(){
$this->_sInput = null;
$this->_sOutput = null;
$this->_bClean = true;
$this->_bJump = true;
$this->_bBody = true;
}
/***************************************************************************
* *
* Sets the XML input file path *
* This is the XML layout file, not the data one. *
* @param String path *
* *
***************************************************************************/
function setInput($sInput_=null){
$this->_sInput=$sInput_;
}
/***************************************************************************
* *
* Returns the XML input file path *
* @return String path *
* *
***************************************************************************/
function getInput(){
return $this->_sInput;
}
/***************************************************************************
* *
* Sets the path of the plugin result file. *
* @param String path *
* *
***************************************************************************/
function setOutput($sOutput_=null){
$this->_sOutput=$sOutput_;
}
/***************************************************************************
* *
* Returns the path of the plugin result file. *
* @return String path *
* *
***************************************************************************/
function getOutput(){
return $this->_sOutput;
}
/***************************************************************************
* *
* Set the file erasing (after the report is rendered) flag *
* Erases (or not) the XML data file, not the plugin result. *
* @param boolean clean *
* *
***************************************************************************/
function setClean($bClean_=true){
$this->_bClean=$bClean_;
}
/***************************************************************************
* *
* Returns if this class will erase the file *
* after the report is rendered *
* @return boolean erase *
* *
***************************************************************************/
function isCleaning(){
return $this->_bClean;
}
/***************************************************************************
* *
* If true, makes the current URL "jumps" and show the plugin result. *
* *
***************************************************************************/
function setJump($bJump_=true){
$this->_bJump=$bJump_;
}
/***************************************************************************
* *
* Returns if it's "jumping". *
* *
***************************************************************************/
function isJumping(){
return $this->_bJump;
}
/***************************************************************************
* *
* This function needs to be defined on every plugin. *
* *
***************************************************************************/
function run(){
}
function setBody($b=true){
$this->_bBody=$b;
}
function getBody(){
return $this->_bBody;
}
/***************************************************************************
* *
* Load a saved report from a file. *
* @param file path *
* *
***************************************************************************/
function loadFrom($sPath_=null){
if(is_null($sPath_))
return;
if(!file_exists($sPath_)){
$oError = new PHPReportsErrorTr();
$oError->showMsg("NOLOAD",array($sPath_));
}
$sTemp = tempnam(getPHPReportsTmpPath(),"xml");
$fIn = fopen("compress.zlib://".$sPath_,"r");
$fOut = fopen($sTemp,"w");
// read the md5sum
$sMD5 = trim(fread($fIn,50));
while($sStr=fread($fIn,1024))
fwrite($fOut,$sStr);
fclose($fOut);
fclose($fIn);
$sMD5chk = md5_file($sTemp);
if(strcmp($sMD5,$sMD5chk)!=0){
unlink($sTemp);
print "<b>ERROR</b>: the report stored in $sPath_ is corrupted.";
return;
}
//$sTemp = substr(strrchr($sTemp,"/"),1);
$this->setInput($sTemp);
$this->run();
}
}
?>
|