Skip to content

Commit

Permalink
Rationalise 'getExportFilename'
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Sep 24, 2018
1 parent 620eae1 commit edc6a48
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 46 deletions.
47 changes: 1 addition & 46 deletions CRM/Export/BAO/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -624,45 +624,6 @@ public static function exportComponents(
}
}

/**
* 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.
*/
Expand Down Expand Up @@ -1249,13 +1210,7 @@ public static function writeCSVFromTable($exportTempTable, $headerRows, $sqlColu
}
$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,
Expand Down
39 changes: 39 additions & 0 deletions CRM/Export/BAO/ExportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,45 @@ public function setExportMode($exportMode) {
$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
Expand Down

0 comments on commit edc6a48

Please sign in to comment.