Merge pull request #9886 from JMAConsulting/CRM-20169
[civicrm-core.git] / CRM / Utils / PDF / Document.php
index e841d67ca09461f06fb36d0b0bf671dfffbbec9c..e2dac47b16e9f065ad163293b0082fb9c898d9c6 100644 (file)
@@ -57,7 +57,10 @@ class CRM_Utils_PDF_Document {
    * Convert html to a Doc file.
    *
    * @param array $pages
+   *   List of HTML snippets.
    * @param string $fileName
+   *   The logical filename to return to client.
+   *   Ex: "HelloWorld.odt".
    * @param array|int $format
    */
   public static function html2doc($pages, $fileName, $format = array()) {
@@ -100,7 +103,13 @@ class CRM_Utils_PDF_Document {
   /**
    * @param object|string $phpWord
    * @param string $ext
+   *   File extension/type.
+   *   Ex: docx, odt, html.
    * @param string $fileName
+   *   The logical filename to return to client.
+   *   Ex: "HelloWorld.odt".
+   *   Alternatively, a full path of a file to display. This seems sketchy.
+   *   Ex: "/var/lib/data/HelloWorld.odt".
    */
   public static function printDoc($phpWord, $ext, $fileName) {
     $formats = array(
@@ -173,10 +182,12 @@ class CRM_Utils_PDF_Document {
   /**
    * Modify contents of docx/odt file(s) and later merged into one final document
    *
-   * @param string $filePath
-   *   Document file path
    * @param array $contents
-   *   Content of formatted/token-replaced document
+   *   Content of formatted/token-replaced document.
+   *   List of HTML snippets.
+   * @param string $fileName
+   *   The logical filename to return to client.
+   *   Ex: "HelloWorld.odt".
    * @param string $docType
    *   Document type e.g. odt/docx
    * @param clsTbsZip $zip
@@ -186,7 +197,7 @@ class CRM_Utils_PDF_Document {
    *
    * @return string
    */
-  public static function printDocuments($filePath, $contents, $docType, $zip, $returnFinalContent = FALSE) {
+  public static function printDocuments($contents, $fileName, $docType, $zip, $returnFinalContent = FALSE) {
     $dataMap = self::$ooxmlMap[$docType];
 
     $finalContent = $zip->FileRead($dataMap['dataFile']);
@@ -215,7 +226,6 @@ class CRM_Utils_PDF_Document {
     // Replace the loaded document file content located at $filePath with $finaContent
     $zip->FileReplace($dataMap['dataFile'], $finalContent, TBSZIP_STRING);
 
-    $fileName = pathinfo($filePath, PATHINFO_FILENAME) . '.' . $docType;
     $zip->Flush(TBSZIP_DOWNLOAD, $fileName);
   }