Commit fd7c5b1243c3fd998de5c38c4f3e184b5d34d79c
1 parent
6f3966ab
Fixed wrong filename document after PDF conversion
Showing
1 changed file
with
9 additions
and
6 deletions
plugins/ktstandard/PDFGeneratorWorkflowTriggers.php
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | * Contributor( s): thePanz (thepanz@gmail.com) |
| 36 | 36 | * |
| 37 | 37 | */ |
| 38 | - | |
| 38 | + | |
| 39 | 39 | require_once(KT_LIB_DIR . '/workflow/workflowtrigger.inc.php'); |
| 40 | 40 | require_once(KT_DIR . '/plugins/pdfConverter/pdfConverter.php'); |
| 41 | 41 | |
| ... | ... | @@ -86,7 +86,7 @@ class PDFGeneratorWorkflowTriggerDuplicatePDF extends KTWorkflowTrigger { |
| 86 | 86 | return $pdfFile; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - $default->log->error("Duplicate_Copy the Document"); | |
| 89 | + $default->log->error("Duplicate-and-Copy the Document"); | |
| 90 | 90 | // Duplicate/Copy the Document |
| 91 | 91 | $oNewDocument = KTDocumentUtil::copy($oDocument, $oToFolder); |
| 92 | 92 | if (PEAR::isError($oNewDocument)) { |
| ... | ... | @@ -102,14 +102,18 @@ class PDFGeneratorWorkflowTriggerDuplicatePDF extends KTWorkflowTrigger { |
| 102 | 102 | |
| 103 | 103 | $res = KTDocumentUtil::storeContents($oNewDocument, $oContents = null, $aOptions); |
| 104 | 104 | if (PEAR::isError($res)) { |
| 105 | - $default->log->error("PDF WorkflowTrigger error: can't associate PDF file to document." . $res->message); | |
| 105 | + $default->log->error("PDF Error: can't associate PDF file to document. storeDocument error = " . $res->message); | |
| 106 | 106 | // Remove the created document (not-correct) |
| 107 | 107 | KTDocumentUtil::delete($oNewDocument, _kt("PDF WorkflowTrigger error: can't create associate PDF file to document.")); |
| 108 | 108 | return $res; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | + // Change filename reporeted by Document: renamed to .PDF | |
| 112 | + // TODO: maybe use the KTDocumentUtil::rename($oDocument, $sFilename, $oUser) for rename+MimeType? | |
| 113 | + $sFilename= pathinfo($oNewDocument->getFileName(), PATHINFO_FILENAME); | |
| 114 | + $oNewDocument->setFileName($sFilename . '.pdf'); | |
| 115 | + | |
| 111 | 116 | // Changing MIME-Filetype |
| 112 | - // TODO: maybe use the KTDocumentUtil::rename($oDocument, $sFilename, $oUser) ? | |
| 113 | 117 | $iMimeTypeId = KTMime::getMimeTypeID('application/pdf'); |
| 114 | 118 | $oNewDocument->setMimeTypeId($iMimeTypeId); |
| 115 | 119 | |
| ... | ... | @@ -132,17 +136,16 @@ class PDFGeneratorWorkflowTriggerDuplicatePDF extends KTWorkflowTrigger { |
| 132 | 136 | $dir = $default->pdfDirectory; |
| 133 | 137 | $iDocId = $oDocument->iId; |
| 134 | 138 | $file = $dir .'/'. $iDocId . '.pdf'; |
| 135 | - $default->log->error(__class__ . '::' . __function__ . '() PRE-CONV: '." file=$file'"); | |
| 136 | 139 | if (!file_exists($file)) { |
| 137 | 140 | // If not - create one |
| 138 | 141 | $converter = new pdfConverter(); |
| 139 | 142 | $converter->setDocument($oDocument); |
| 140 | 143 | $res = $converter->processDocument(); |
| 141 | 144 | if ($res !== true) { |
| 145 | + $default->log->error(__class__ . '::' . __function__ . '() PDF file could not be generated.'); | |
| 142 | 146 | return PEAR::raiseError(_kt('PDF file could not be generated; Please contact your System Administrator for assistance.')); |
| 143 | 147 | } |
| 144 | 148 | } |
| 145 | - $default->log->error(__class__ . '::' . __function__ . '() CONVERTED! : '." file=$file'"); | |
| 146 | 149 | return $file; |
| 147 | 150 | } |
| 148 | 151 | ... | ... |