CRM-15883 - Suppressing Stationery path field from PDF Letter action since it is...
[civicrm-core.git] / CRM / Contact / Form / Task / PDFLetterCommon.php
index 68c721a65cdb1c55e983e573185c696b1692849c..740b689cb4b102a0565467dd4a0e1699a7f0887c 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -47,9 +47,9 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
    * @return void
    */
   public static function preProcess(&$form) {
-    $messageText    = array();
+    $messageText = array();
     $messageSubject = array();
-    $dao            = new CRM_Core_BAO_MessageTemplate();
+    $dao = new CRM_Core_BAO_MessageTemplate();
     $dao->is_active = 1;
     $dao->find();
     while ($dao->fetch()) {
@@ -156,15 +156,17 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
     );
 
     $config = CRM_Core_Config::singleton();
-    if ($config->wkhtmltopdfPath == false) {
-      $form->add(
-        'text',
-        'stationery',
-        ts('Stationery (relative path to PDF you wish to use as the background)'),
-        array('size' => 25, 'maxlength' => 900, 'onkeyup' => "showUpdateFormatChkBox();"),
-        FALSE
-      );
+    /** CRM-15883 Suppressing Stationery path field until we switch from DOMPDF to a library that supports it.
+    if ($config->wkhtmltopdfPath == FALSE) {
+    $form->add(
+    'text',
+    'stationery',
+    ts('Stationery (relative path to PDF you wish to use as the background)'),
+    array('size' => 25, 'maxlength' => 900, 'onkeyup' => "showUpdateFormatChkBox();"),
+    FALSE
+    );
     }
+     */
     $form->add('checkbox', 'bind_format', ts('Always use this Page Format with the selected Template'));
     $form->add('checkbox', 'update_format', ts('Update Page Format (this will affect all templates that use this format)'));
 
@@ -203,12 +205,14 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
   /**
    * Form rule
    *
-   * @param array $fields    the input form values
+   * @param array $fields
+   *   The input form values.
    * @param array $dontCare
-   * @param array $self      additional values form 'this'
-   *
-   * @return true if no errors, else array of errors
+   * @param array $self
+   *   Additional values form 'this'.
    *
+   * @return bool
+   *   TRUE if no errors, else array of errors.
    */
   public static function formRule($fields, $dontCare, $self) {
     $errors = array();
@@ -239,7 +243,8 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
    *
    * @param CRM_Core_Form $form
    *
-   * @return array( $categories, $html_message, $messageToken, $returnProperties )
+   * @return array
+   *   [$categories, $html_message, $messageToken, $returnProperties]
    */
   static protected function processMessageTemplate(&$form) {
     $formValues = $form->controller->exportValues($form->getName());
@@ -368,10 +373,10 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
    */
   public static function createActivities($form, $html_message, $contactIds) {
     //Added for CRM-12682: Add activity subject and campaign fields
-    $formValues     = $form->controller->exportValues($form->getName());
+    $formValues = $form->controller->exportValues($form->getName());
 
-    $session        = CRM_Core_Session::singleton();
-    $userID         = $session->get('userID');
+    $session = CRM_Core_Session::singleton();
+    $userID = $session->get('userID');
     $activityTypeID = CRM_Core_OptionGroup::getValue(
       'activity_type',
       'Print PDF Letter',
@@ -408,7 +413,7 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
       $activityTargetParams = array(
         'activity_id' => empty($activity->id) ? $activityIds[$contactId] : $activity->id,
         'contact_id' => $contactId,
-        'record_type_id' => $targetID
+        'record_type_id' => $targetID,
       );
       CRM_Activity_BAO_ActivityContact::create($activityTargetParams);
     }
@@ -437,8 +442,8 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
         $matches = array();
         if (preg_match('/^( )+/', $msg, $matches)) {
           $spaceLen = strlen($matches[0]) / 6;
-          $trimMsg  = ltrim($msg, '  ');
-          $charLen  = strlen($trimMsg);
+          $trimMsg = ltrim($msg, '  ');
+          $charLen = strlen($trimMsg);
           $totalLen = $charLen + $spaceLen;
           if ($totalLen > 100) {
             $spacesCount = 10;
@@ -456,4 +461,5 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
     }
     $message = implode($newLineOperators['p']['oper'], $htmlMsg);
   }
+
 }