Esempio n. 1
0
 function getBookmarkValue($oCol_ = null)
 {
     $sVal = "";
     $oError = new PHPReportsErrorTr();
     if ($this->_sType == "STATIC") {
         $sVal = $this->_sExpr;
     } else {
         if ($this->_sType == "DYNAMIC") {
             if (!isset($oCol_)) {
                 $oError->showMsg("DYNBOOK");
             }
             $sVal = $oCol_->getValue($this->_sExpr);
         } else {
             if ($this->_sType == "EXPRESSION") {
                 if (!isset($oCol_)) {
                     $oError->showMsg("EXPBOOK");
                 }
             }
         }
     }
     $sVal = $oCol_->availExpr($this->_sExpr);
     return $sVal;
 }
Esempio n. 2
0
 function run()
 {
     // get the files paths
     $sPath = getPHPReportsFilePath();
     $sXSLT = "{$sPath}/output/page/page.xsl";
     $sXML = $this->getInput();
     // get the DOCUMENT_ROOT path, for temporary copy
     $sRoot = $_SERVER["DOCUMENT_ROOT"];
     // copy the page.php file to the temporary dir
     if (!copy(realpath($sPath . "/output/page/page.php"), realpath($sRoot . "/tmp") . "/page.php")) {
         $oError = new PHPReportsErrorTr();
         $oError->showMsg("PAGEPARSER");
     }
     // get the HOST root URL
     $sHost = "http://" . $_SERVER["HTTP_HOST"];
     $aParm = array();
     $aParm["curpage"] = 1;
     $aParm["incr"] = $this->_iIncr;
     $aParm["l1"] = 1;
     $aParm["l2"] = $this->_iIncr;
     $aParm["first"] = $this->_sFirst;
     $aParm["last"] = $this->_sLast;
     $aParm["next"] = $this->_sNext;
     $aParm["prev"] = $this->_sPrev;
     $aParm["xmlfile"] = $this->getInput();
     $aParm["url"] = $sHost . "/tmp/page.php";
     $aParm["body"] = $this->getBody() ? "true" : "false";
     $oProcFactory = new XSLTProcessorFactory();
     $oProc = $oProcFactory->get();
     $oProc->setXML($sXML);
     $oProc->setXSLT($sXSLT);
     $oProc->setOutput($this->getOutput());
     $oProc->setParms($aParm);
     $sRst = $oProc->run();
     print $sRst;
 }
 function createFromTemplate($sTitle = "NO DEFINED TITLE", $sFile = null, $oParms = null, $oDocument = null, $oGroups = null)
 {
     $sPath = getPHPReportsFilePath();
     $oError = new PHPReportsErrorTr();
     $sIf = $this->getDatabaseInterface();
     $sFile = $sFile ? $sFile : realpath($sPath . "/template.xml");
     // if the file does not exist
     if (!file_exists($sFile)) {
         $oError->showMsg("NOTEMPLATE", $sFile);
     }
     // get the template contents
     $sFileContents = file_get_contents($sFile);
     // check if there are some parameters here ...
     if ($oParms) {
         $sParms = null;
         if (is_object($oParms)) {
             $sParms = $oParms->write();
         }
         if (is_string($oParms)) {
             $sParms = $oParms;
         }
         if ($sParms) {
             $sFileContents = str_replace("<REPLACE_WITH_PARAMETERS/>", $sParms, $sFileContents);
         }
     }
     // check if there is some document info
     if ($oDocument) {
         $sDocument = null;
         if (is_object($oDocument)) {
             $sDocument = $oDocument->write();
         }
         if (is_string($oDocument)) {
             $sDocument = $oDocument;
         }
         if ($sDocument) {
             $sFileContents = str_replace("<REPLACE_WITH_DOCUMENT_INFO/>", $sDocument, $sFileContents);
         }
     }
     // if no groups info was specified, follow the default behaviour: all the fields from the query,
     // with no group break
     if (!$oGroups) {
         // include the database interface and try to open the connection and execute the query
         $sIfFile = realpath($sPath . "/database/db_" . $sIf . ".php");
         if (!file_exists($sIfFile)) {
             $oError->showMsg("NOIF", $sIf);
         }
         include_once $sIfFile;
         // if the database connection is null, open it
         if (is_null($this->_oCon)) {
             $this->_oCon = @PHPReportsDBI::db_connect(array($this->sUser, $this->sPass, $this->sCon, $this->sDatabase)) or $oError->showMsg("REFUSEDCON");
         }
         // if there are some input filters ...
         if ($this->_oInput) {
             foreach ($this->_oInput as $oFilter) {
                 $oFilter->setConnection($this->_oCon);
                 $oFilter->setSQL(trim($this->sSQL));
                 $this->sSQL = trim($oFilter->run());
             }
             // there is no need to run the filters again
             $this->_oInput = null;
         }
         // run the query
         $this->_oQuery = @PHPReportsDBI::db_query($this->_oCon, trim($this->sSQL)) or $oError->showMsg("QUERYERROR");
         // insert the column names
         $sNames = "";
         $sReplacedNames = "";
         $iColNum = PHPREportsDBI::db_colnum($this->_oQuery);
         for ($i = 1; $i <= $iColNum; $i++) {
             $sName = PHPReportsDBI::db_columnName($this->_oQuery, $i);
             $sExtra = isNumericType(PHPReportsDBI::db_columnType($this->_oQuery, $i)) ? " ALIGN=\"RIGHT\"" : "";
             $sReplacedNames .= "<COL CELLCLASS=\"bold\"{$sExtra}>" . ucfirst(strtolower(str_replace("_", " ", $sName))) . "</COL>";
             $sNames .= "<COL TYPE=\"FIELD\"{$sExtra}>{$sName}</COL>";
         }
         // build the group info
         $sGroup = "<GROUP REPRINT_HEADER_ON_PAGEBREAK='TRUE'><HEADER><ROW><REPLACE_WITH_REPLACED_COLUMN_NAMES/></ROW></HEADER><FIELDS><ROW><REPLACE_WITH_COLUMN_NAMES/></ROW></FIELDS></GROUP>";
         $sGroup = str_replace("<REPLACE_WITH_REPLACED_COLUMN_NAMES/>", $sReplacedNames, $sGroup);
         $sGroup = str_replace("<REPLACE_WITH_COLUMN_NAMES/>", $sNames, $sGroup);
         $sFileContents = str_replace("<REPLACE_WITH_GROUP_INFO/>", $sGroup, $sFileContents);
     } else {
         $sGroups = null;
         if (is_object($oGroups)) {
             $sGroups = $oGroups->write();
         }
         if (is_string($oGroups)) {
             $sGroups = $oGroups;
         }
         if ($sGroups) {
             $sFileContents = str_replace("<REPLACE_WITH_GROUP_INFO/>", $sGroups, $sFileContents);
         }
     }
     // replace the report title
     $sFileContents = str_replace("<REPLACE_WITH_TITLE/>", $sTitle, $sFileContents);
     // print htmlspecialchars($sFileContents);
     // create the temporary XML file
     $sTemp = tempnam($this->_sTmp, "tempphprpt");
     // this is just for PHP4 compability
     $fHand = fopen($sTemp, "w");
     fwrite($fHand, $sFileContents);
     fclose($fHand);
     $this->_bDeleteXML = true;
     // flag to delete the temporary file
     $this->sXML = $sTemp;
     // the XML layout file is the temporary file now
 }
Esempio n. 4
0
 /**
 	Returns this link value based on it's expression and type
 */
 function getLinkValue($oCol_)
 {
     $sVal = "";
     $oError = new PHPReportsErrorTr();
     if ($this->_sType == "STATIC") {
         $sVal = $this->_sExpr;
     } else {
         if ($this->_sType == "DYNAMIC") {
             if (!isset($oCol_)) {
                 $oError->showMsg("DYNLINK");
             }
             $sVal = $oCol_->getValue($this->_sExpr);
         } else {
             if ($this->_sType == "EXPRESSION") {
                 if (!isset($oCol_)) {
                     $oError->showMsg("EXPLINK");
                 }
                 $sVal = htmlspecialchars($oCol_->availExpr($this->_sExpr));
             }
         }
     }
     return $sVal;
 }
Esempio n. 5
0
 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();
 }