Commit f54daecd4c775010894a02eec60a511323a3bbac

Authored by kevin_fourie
1 parent e5ce0a52

KTS-1794

"0 bytes files using PDF Convert function and openoffice service crashing"
Still working on this issue. Commited some error handling code and fixed some typos.

Reviewed By: Conrad



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@6533 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktstandard/PDFGeneratorAction.php
@@ -167,10 +167,10 @@ class PDFGeneratorAction extends KTDocumentAction { @@ -167,10 +167,10 @@ class PDFGeneratorAction extends KTDocumentAction {
167 167
168 if (file_exists($sPath)) { 168 if (file_exists($sPath)) {
169 169
170 -# Get a tmp file 170 + // Get a tmp file
171 $sTempFilename = tempnam('/tmp', 'ktpdf'); 171 $sTempFilename = tempnam('/tmp', 'ktpdf');
172 172
173 -# We need to handle Windows differently - as usual ;) 173 + // We need to handle Windows differently - as usual ;)
174 if (substr( PHP_OS, 0, 3) == 'WIN') { 174 if (substr( PHP_OS, 0, 3) == 'WIN') {
175 175
176 $cmd = "\"" . KT_DIR . "/../openoffice/openoffice/program/python.bat\" \"". KT_DIR . "/bin/openoffice/pdfgen.py\" \"" . $sPath . "\" \"" . $sTempFilename . "\""; 176 $cmd = "\"" . KT_DIR . "/../openoffice/openoffice/program/python.bat\" \"". KT_DIR . "/bin/openoffice/pdfgen.py\" \"" . $sPath . "\" \"" . $sTempFilename . "\"";
@@ -197,7 +197,7 @@ class PDFGeneratorAction extends KTDocumentAction { @@ -197,7 +197,7 @@ class PDFGeneratorAction extends KTDocumentAction {
197 197
198 } 198 }
199 199
200 -# Check the tempfile exists and the python script did not return anything (which would indicate an error) 200 + // Check the tempfile exists and the python script did not return anything (which would indicate an error)
201 if (file_exists($sTempFilename) && $res == '') { 201 if (file_exists($sTempFilename) && $res == '') {
202 202
203 $sUrlEncodedFileName = substr($oDocument->getFileName(), 0, strrpos($oDocument->getFileName(), '.') ); 203 $sUrlEncodedFileName = substr($oDocument->getFileName(), 0, strrpos($oDocument->getFileName(), '.') );
@@ -213,28 +213,28 @@ class PDFGeneratorAction extends KTDocumentAction { @@ -213,28 +213,28 @@ class PDFGeneratorAction extends KTDocumentAction {
213 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 213 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
214 header("Cache-Control: must-revalidate"); 214 header("Cache-Control: must-revalidate");
215 215
216 -# Get a filelike object and send it to the browser 216 + // Get a filelike object and send it to the browser
217 $oFile = new KTFSFileLike($sTempFilename); 217 $oFile = new KTFSFileLike($sTempFilename);
218 KTFileLikeUtil::send_contents($oFile); 218 KTFileLikeUtil::send_contents($oFile);
219 -# Remove the tempfile 219 + // Remove the tempfile
220 unlink($sTempFilename); 220 unlink($sTempFilename);
221 221
222 -# Create the document transaction 222 + // Create the document transaction
223 $oDocumentTransaction = & new DocumentTransaction($oDocument, 'Document downloaded as PDF', 'ktcore.transactions.download', $aOptions); 223 $oDocumentTransaction = & new DocumentTransaction($oDocument, 'Document downloaded as PDF', 'ktcore.transactions.download', $aOptions);
224 $oDocumentTransaction->create(); 224 $oDocumentTransaction->create();
225 -# Just stop here - the content has already been sent. 225 + // Just stop here - the content has already been sent.
226 exit(0); 226 exit(0);
227 227
228 } else { 228 } else {
229 -# Set the error messsage and redirect to view document  
230 - $this->addErrorMessage(_kt('An error occured generating the PDF - please contact the system administrator.')); 229 + // Set the error messsage and redirect to view document
  230 + $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator.<br>' . $res));
231 redirect(generateControllerLink('viewDocument',sprintf(_kt('fDocumentId=%d'),$oDocument->getId()))); 231 redirect(generateControllerLink('viewDocument',sprintf(_kt('fDocumentId=%d'),$oDocument->getId())));
232 exit(0); 232 exit(0);
233 } 233 }
234 234
235 } else { 235 } else {
236 -# Set the error messsage and redirect to view document  
237 - $this->addErrorMessage(_kt('An error occured generating the PDF - please contact the system administrator.')); 236 + // Set the error messsage and redirect to view document
  237 + $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator.<br>The path to the document did not exist.'));
238 redirect(generateControllerLink('viewDocument',sprintf(_kt('fDocumentId=%d'),$oDocument->getId()))); 238 redirect(generateControllerLink('viewDocument',sprintf(_kt('fDocumentId=%d'),$oDocument->getId())));
239 exit(0); 239 exit(0);
240 } 240 }