$this->_selectAll = FALSE;
$this->_exportMode = self::CONTACT_EXPORT;
- $this->_componentIds = array();
+ $this->_componentIds = [];
$this->_componentClause = NULL;
// we need to determine component export
- $components = array('Contact', 'Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity');
+ $components = ['Contact', 'Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity'];
// FIXME: This should use a modified version of CRM_Contact_Form_Search::getModeValue but it doesn't have all the contexts
// FIXME: Or better still, use CRM_Core_DAO_AllCoreTables::getBriefName($daoName) to get the $entityShortName
$formName = CRM_Utils_System::getClassName($this->controller->getStateMachine());
$componentName = explode('_', $formName);
if ($formName == 'CRM_Export_StateMachine_Standalone') {
- $componentName = array('CRM', $this->controller->get('entity'));
+ $componentName = ['CRM', $this->controller->get('entity')];
}
- $entityShortname = $componentName[1]; // Contact
+ // Contact
+ $entityShortname = $componentName[1];
$entityDAOName = $entityShortname;
break;
}
*/
public function buildQuickForm() {
//export option
- $exportOptions = $mergeOptions = $postalMailing = array();
+ $exportOptions = $mergeOptions = $postalMailing = [];
$exportOptions[] = $this->createElement('radio',
NULL, NULL,
ts('Export PRIMARY fields'),
self::EXPORT_ALL,
- array('onClick' => 'showMappingOption( );')
+ ['onClick' => 'showMappingOption( );']
);
$exportOptions[] = $this->createElement('radio',
NULL, NULL,
ts('Select fields for export'),
self::EXPORT_SELECTED,
- array('onClick' => 'showMappingOption( );')
+ ['onClick' => 'showMappingOption( );']
);
$mergeOptions[] = $this->createElement('radio',
NULL, NULL,
ts('Do not merge'),
self::EXPORT_MERGE_DO_NOT_MERGE,
- array('onclick' => 'showGreetingOptions( );')
+ ['onclick' => 'showGreetingOptions( );']
);
$mergeOptions[] = $this->createElement('radio',
NULL, NULL,
ts('Merge All Contacts with the Same Address'),
self::EXPORT_MERGE_SAME_ADDRESS,
- array('onclick' => 'showGreetingOptions( );')
+ ['onclick' => 'showGreetingOptions( );']
);
$mergeOptions[] = $this->createElement('radio',
NULL, NULL,
ts('Merge Household Members into their Households'),
self::EXPORT_MERGE_HOUSEHOLD,
- array('onclick' => 'showGreetingOptions( );')
+ ['onclick' => 'showGreetingOptions( );']
);
$postalMailing[] = $this->createElement('advcheckbox',
$this->_greetingOptions = self::getGreetingOptions();
foreach ($this->_greetingOptions as $key => $value) {
- $fieldLabel = ts('%1 (merging > 2 contacts)', array(1 => ucwords(str_replace('_', ' ', $key))));
+ $fieldLabel = ts('%1 (merging > 2 contacts)', [1 => ucwords(str_replace('_', ' ', $key))]);
$this->addElement('select', $key, $fieldLabel,
- $value, array('onchange' => "showOther(this);")
+ $value, ['onchange' => "showOther(this);"]
);
$this->addElement('text', "{$key}_other", '');
}
$this->addGroup($postalMailing, 'postal_mailing_export', ts('Postal Mailing Export'), '<br/>');
$this->addElement('select', 'additional_group', ts('Additional Group for Export'),
- array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(),
- array('class' => 'crm-select2 huge')
+ ['' => ts('- select group -')] + CRM_Core_PseudoConstant::nestedGroup(),
+ ['class' => 'crm-select2 huge']
);
}
$this->buildMapping();
- $this->setDefaults(array(
+ $this->setDefaults([
'exportOption' => self::EXPORT_ALL,
'mergeOption' => self::EXPORT_MERGE_DO_NOT_MERGE,
- ));
-
- $this->addButtons(array(
- array(
- 'type' => 'next',
- 'name' => ts('Continue'),
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- )
- );
-
- $this->addFormRule(array('CRM_Export_Form_Select', 'formRule'), $this);
+ ]);
+
+ $this->addButtons([
+ [
+ 'type' => 'next',
+ 'name' => ts('Continue'),
+ 'spacing' => ' ',
+ 'isDefault' => TRUE,
+ ],
+ [
+ 'type' => 'cancel',
+ 'name' => ts('Cancel'),
+ ],
+ ]);
+
+ $this->addFormRule(['CRM_Export_Form_Select', 'formRule'], $this);
}
/**
* mixed true or array of errors
*/
public static function formRule($params, $files, $self) {
- $errors = array();
+ $errors = [];
if (CRM_Utils_Array::value('mergeOption', $params) == self::EXPORT_MERGE_SAME_ADDRESS &&
$self->_matchingContacts
) {
- $greetings = array(
+ $greetings = [
'postal_greeting' => 'postal_greeting_other',
'addressee' => 'addressee_other',
- );
+ ];
foreach ($greetings as $key => $value) {
$otherOption = CRM_Utils_Array::value($key, $params);
if ((CRM_Utils_Array::value($otherOption, $self->_greetingOptions[$key]) == ts('Other')) && empty($params[$value])) {
$label = ucwords(str_replace('_', ' ', $key));
- $errors[$value] = ts('Please enter a value for %1 (merging > 2 contacts), or select a pre-configured option from the list.', array(1 => $label));
+ $errors[$value] = ts('Please enter a value for %1 (merging > 2 contacts), or select a pre-configured option from the list.', [1 => $label]);
}
}
}
// all submitted options or any other argument
$exportParams = $params;
- if (!empty($this->_greetingOptions)) {
- foreach ($this->_greetingOptions as $key => $value) {
- if ($option = CRM_Utils_Array::value($key, $exportParams)) {
- if ($this->_greetingOptions[$key][$option] == ts('Other')) {
- $exportParams[$key] = $exportParams["{$key}_other"];
- }
- elseif ($this->_greetingOptions[$key][$option] == ts('List of names')) {
- $exportParams[$key] = '';
- }
- else {
- $exportParams[$key] = $this->_greetingOptions[$key][$option];
- }
- }
- }
- }
-
$mappingId = CRM_Utils_Array::value('mapping', $params);
if ($mappingId) {
$this->set('mappingId', $mappingId);
$mappings = CRM_Core_BAO_Mapping::getMappings($exportType);
if (!empty($mappings)) {
- $this->add('select', 'mapping', ts('Use Saved Field Mapping'), array('' => '-select-') + $mappings);
+ $this->add('select', 'mapping', ts('Use Saved Field Mapping'), ['' => '-select-'] + $mappings);
}
}
* @return array
*/
public static function getGreetingOptions() {
- $options = array();
- $greetings = array(
+ $options = [];
+ $greetings = [
'postal_greeting' => 'postal_greeting_other',
'addressee' => 'addressee_other',
- );
+ ];
foreach ($greetings as $key => $value) {
- $params = array();
+ $params = [];
$optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $key, 'id', 'name');
CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_OptionValue', 'option_group_id', $optionGroupId,
- $params, array('label', 'filter')
+ $params, ['label', 'filter']
);
$greetingCount = 1;
- $options[$key] = array("$greetingCount" => ts('List of names'));
+ $options[$key] = ["$greetingCount" => ts('List of names')];
foreach ($params as $id => $field) {
if (CRM_Utils_Array::value('filter', $field) == 4) {