From 29034a985ace87d2a48fac0cec63e0468433efce Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 25 Sep 2018 10:47:05 +1200 Subject: [PATCH] Rationalise 'getExportFilename' --- CRM/Export/BAO/Export.php | 47 +----------------------------- CRM/Export/BAO/ExportProcessor.php | 39 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 46 deletions(-) diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index deb2890c50..dede641e78 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -624,45 +624,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c } } - /** - * Name of the export file based on mode. - * - * @param string $output - * Type of output. - * @param int $mode - * Export mode. - * - * @return string - * name of the file - */ - public static function getExportFileName($output = 'csv', $mode = CRM_Export_Form_Select::CONTACT_EXPORT) { - switch ($mode) { - case CRM_Export_Form_Select::CONTACT_EXPORT: - return ts('CiviCRM Contact Search'); - - case CRM_Export_Form_Select::CONTRIBUTE_EXPORT: - return ts('CiviCRM Contribution Search'); - - case CRM_Export_Form_Select::MEMBER_EXPORT: - return ts('CiviCRM Member Search'); - - case CRM_Export_Form_Select::EVENT_EXPORT: - return ts('CiviCRM Participant Search'); - - case CRM_Export_Form_Select::PLEDGE_EXPORT: - return ts('CiviCRM Pledge Search'); - - case CRM_Export_Form_Select::CASE_EXPORT: - return ts('CiviCRM Case Search'); - - case CRM_Export_Form_Select::GRANT_EXPORT: - return ts('CiviCRM Grant Search'); - - case CRM_Export_Form_Select::ACTIVITY_EXPORT: - return ts('CiviCRM Activity Search'); - } - } - /** * Handle import error file creation. */ @@ -1249,13 +1210,7 @@ LIMIT $offset, $limit } $componentDetails[] = $row; } - if ($exportMode == 'financial') { - $getExportFileName = 'CiviCRM Contribution Search'; - } - else { - $getExportFileName = self::getExportFileName('csv', $exportMode); - } - CRM_Core_Report_Excel::writeCSVFile($getExportFileName, + CRM_Core_Report_Excel::writeCSVFile($processor->getExportFileName(), $headerRows, $componentDetails, NULL, diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php index b038424a4d..026befc133 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -301,6 +301,45 @@ class CRM_Export_BAO_ExportProcessor { $this->exportMode = $exportMode; } + /** + * Get the name for the export file. + * + * @return string + */ + public function getExportFileName() { + switch ($this->getExportMode()) { + case CRM_Export_Form_Select::CONTACT_EXPORT: + return ts('CiviCRM Contact Search'); + + case CRM_Export_Form_Select::CONTRIBUTE_EXPORT: + return ts('CiviCRM Contribution Search'); + + case CRM_Export_Form_Select::MEMBER_EXPORT: + return ts('CiviCRM Member Search'); + + case CRM_Export_Form_Select::EVENT_EXPORT: + return ts('CiviCRM Participant Search'); + + case CRM_Export_Form_Select::PLEDGE_EXPORT: + return ts('CiviCRM Pledge Search'); + + case CRM_Export_Form_Select::CASE_EXPORT: + return ts('CiviCRM Case Search'); + + case CRM_Export_Form_Select::GRANT_EXPORT: + return ts('CiviCRM Grant Search'); + + case CRM_Export_Form_Select::ACTIVITY_EXPORT: + return ts('CiviCRM Activity Search'); + + default: + // Legacy code suggests the value could be 'financial' - ie. something + // other than what should be accepted. However, I suspect that this line is + // never hit. + return ts('CiviCRM Search'); + } + } + /** * @param $params * @param $order -- 2.25.1