Merge pull request #4899 from colemanw/INFRA-132
[civicrm-core.git] / CRM / Financial / BAO / ExportFormat.php
index 00347247b3cf03f876ac67e982cfef3baa63da09..d664af865a3efec31d5c396c59d3ba307bb37d69 100644 (file)
@@ -38,7 +38,6 @@
  * Create a subclass for a specific format.
  * @see http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Specifications+-++Batches#CiviAccountsSpecifications-Batches-%C2%A0Overviewofimplementation
  */
-
 class CRM_Financial_BAO_ExportFormat {
 
   /*
@@ -54,8 +53,8 @@ class CRM_Financial_BAO_ExportFormat {
   /**
    * Class constructor
    */
-  function __construct() {
-    if ( !isset( self::$_template ) ) {
+  public function __construct() {
+    if (!isset(self::$_template)) {
       self::$_template = CRM_Core_Smarty::singleton();
     }
   }
@@ -66,7 +65,7 @@ class CRM_Financial_BAO_ExportFormat {
    *
    * @return mixed
    */
-  function export($exportParams) {
+  public function export($exportParams) {
     $this->_exportParams = $exportParams;
     return $exportParams;
   }
@@ -74,32 +73,32 @@ class CRM_Financial_BAO_ExportFormat {
   /**
    * @param null $fileName
    */
-  function output($fileName = NULL) {
+  public function output($fileName = NULL) {
     switch ($this->getFileExtension()) {
       case 'csv':
         self::createActivityExport($this->_batchIds, $fileName);
-      break;
+        break;
 
       case 'iif':
         $tplFile = $this->getHookedTemplateFileName();
         $out = self::getTemplate()->fetch($tplFile);
         $fileName = $this->putFile($out);
         self::createActivityExport($this->_batchIds, $fileName);
-      break;
+        break;
     }
   }
 
   /**
    * @return string
    */
-  function getMimeType() {
+  public function getMimeType() {
     return 'text/plain';
   }
 
   /**
    * @return string
    */
-  function getFileExtension() {
+  public function getFileExtension() {
     return 'txt';
   }
 
@@ -107,14 +106,14 @@ class CRM_Financial_BAO_ExportFormat {
   /**
    * @return null
    */
-  function getTemplateFileName() {
-    return null;
+  public function getTemplateFileName() {
+    return NULL;
   }
 
   /**
    * @return object
    */
-  static function &getTemplate() {
+  public static function &getTemplate() {
     return self::$_template;
   }
 
@@ -122,7 +121,7 @@ class CRM_Financial_BAO_ExportFormat {
    * @param $var
    * @param null $value
    */
-  function assign($var, $value = NULL) {
+  public function assign($var, $value = NULL) {
     self::$_template->assign($var, $value);
   }
 
@@ -138,7 +137,7 @@ class CRM_Financial_BAO_ExportFormat {
    *
    * @return null
    */
-  static function format($s, $type = 'string') {
+  public static function format($s, $type = 'string') {
     if (!empty($s)) {
       return $s;
     }
@@ -147,10 +146,10 @@ class CRM_Financial_BAO_ExportFormat {
     }
   }
 
-  function initiateDownload() {
+  public function initiateDownload() {
     $config = CRM_Core_Config::singleton();
     //zip files if more than one.
-    if (count($this->_downloadFile)>1) {
+    if (count($this->_downloadFile) > 1) {
       $zip = $config->customFileUploadDir . 'Financial_Transactions_' . date('YmdHis') . '.zip';
       $result = $this->createZip($this->_downloadFile, $zip, TRUE);
       if ($result) {
@@ -181,7 +180,7 @@ class CRM_Financial_BAO_ExportFormat {
    *
    * @throws CRM_Core_Exception
    */
-  static function createActivityExport($batchIds, $fileName) {
+  public static function createActivityExport($batchIds, $fileName) {
     $session = CRM_Core_Session::singleton();
     $values = array();
     $params = array('id' => $batchIds);
@@ -197,14 +196,14 @@ class CRM_Financial_BAO_ExportFormat {
     $details = '<p>' . ts('Record:') . ' ' . $values['title'] . '</p><p>' . ts('Description:') . '</p><p>' . ts('Created By:') . " $createdBy" . '</p><p>' . ts('Created Date:') . ' ' . $values['created_date'] . '</p><p>' . ts('Last Modified By:') . ' ' . $modifiedBy . '</p><p>' . ts('Payment Instrument:') . ' ' . $values['payment_instrument_id'] . '</p>';
     $subject = '';
     if (!empty($values['total'])) {
-      $subject .= ts('Total') . '['. CRM_Utils_Money::format($values['total']) .'],';
+      $subject .= ts('Total') . '[' . CRM_Utils_Money::format($values['total']) . '],';
     }
     if (!empty($values['item_count'])) {
-      $subject .= ' ' . ts('Count') . '['. $values['item_count'] .'],';
+      $subject .= ' ' . ts('Count') . '[' . $values['item_count'] . '],';
     }
 
     //create activity.
-    $subject .=  ' ' . ts('Batch') . '['. $values['title'] .']';
+    $subject .= ' ' . ts('Batch') . '[' . $values['title'] . ']';
     $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
     $activityParams = array(
       'activity_type_id' => array_search('Export Accounting Batch', $activityTypes),
@@ -215,7 +214,7 @@ class CRM_Financial_BAO_ExportFormat {
       'source_record_id' => $values['id'],
       'target_contact_id' => $session->get('userID'),
       'details' => $details,
-      'attachFile_1' => array (
+      'attachFile_1' => array(
         'uri' => $fileName,
         'type' => 'text/csv',
         'location' => $fileName,
@@ -233,7 +232,7 @@ class CRM_Financial_BAO_ExportFormat {
    *
    * @return bool
    */
-  function createZip($files = array(), $destination = NULL, $overwrite = FALSE) {
+  public function createZip($files = array(), $destination = NULL, $overwrite = FALSE) {
     //if the zip file already exists and overwrite is false, return false
     if (file_exists($destination) && !$overwrite) {
       return FALSE;
@@ -249,7 +248,7 @@ class CRM_Financial_BAO_ExportFormat {
     }
     if (count($validFiles)) {
       $zip = new ZipArchive();
-      if ($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== TRUE) {
+      if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== TRUE) {
         return FALSE;
       }
       foreach ($validFiles as $file) {
@@ -259,7 +258,7 @@ class CRM_Financial_BAO_ExportFormat {
       return file_exists($destination);
     }
     else {
-        return FALSE;
-      }
+      return FALSE;
+    }
   }
 }