From 2c4998ccb50a3c08264c758d1133c7aef4f81be8 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 9 Nov 2019 10:03:45 +1300 Subject: [PATCH] [NFC] Reformat Contact_Form_Search_Advanced Fix array style --- CRM/Contact/Form/Search/Advanced.php | 46 ++++++++++++---------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/CRM/Contact/Form/Search/Advanced.php b/CRM/Contact/Form/Search/Advanced.php index 6368ba8f9e..e2b3323b73 100644 --- a/CRM/Contact/Form/Search/Advanced.php +++ b/CRM/Contact/Form/Search/Advanced.php @@ -64,8 +64,8 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { CRM_Contact_Form_Search_Criteria::basic($this); } - $allPanes = array(); - $paneNames = array( + $allPanes = []; + $paneNames = [ ts('Address Fields') => 'location', ts('Custom Fields') => 'custom', ts('Activities') => 'activity', @@ -73,10 +73,10 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { ts('Demographics') => 'demographics', ts('Notes') => 'notes', ts('Change Log') => 'changeLog', - ); + ]; //check if there are any custom data searchable fields - $extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), + $extends = array_merge(['Contact', 'Individual', 'Household', 'Organization'], CRM_Contact_BAO_ContactType::subTypes() ); $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, @@ -95,7 +95,7 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { $components = CRM_Core_Component::getEnabledComponents(); - $componentPanes = array(); + $componentPanes = []; foreach ($components as $name => $component) { if (in_array($name, array_keys($this->_searchOptions)) && $this->_searchOptions[$name] && @@ -106,29 +106,29 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { } } - usort($componentPanes, array('CRM_Utils_Sort', 'cmpFunc')); + usort($componentPanes, ['CRM_Utils_Sort', 'cmpFunc']); foreach ($componentPanes as $name => $pane) { // FIXME: we should change the use of $name here to keyword $paneNames[$pane['title']] = $pane['name']; } - $hookPanes = array(); + $hookPanes = []; CRM_Contact_BAO_Query_Hook::singleton()->registerAdvancedSearchPane($hookPanes); $paneNames = array_merge($paneNames, $hookPanes); - $this->_paneTemplatePath = array(); + $this->_paneTemplatePath = []; foreach ($paneNames as $name => $type) { if (!array_key_exists($type, $this->_searchOptions) && !in_array($type, $hookPanes)) { continue; } - $allPanes[$name] = array( + $allPanes[$name] = [ 'url' => CRM_Utils_System::url('civicrm/contact/search/advanced', "snippet=1&searchPane=$type&qfKey={$this->controller->_key}" ), 'open' => 'false', 'id' => $type, - ); + ]; // see if we need to include this paneName in the current form if ($this->_searchPane == $type || !empty($_POST["hidden_{$type}"]) || @@ -236,10 +236,7 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { // FIXME: couldn't figure out a good place to do this, // FIXME: so leaving this as a dependency for now if (array_key_exists('contribution_amount_low', $this->_formValues)) { - foreach (array( - 'contribution_amount_low', - 'contribution_amount_high', - ) as $f) { + foreach (['contribution_amount_low', 'contribution_amount_high'] as $f) { $this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]); } } @@ -259,7 +256,7 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { } if (isset($this->_groupID) && empty($this->_formValues['group'])) { - $this->_formValues['group'] = array($this->_groupID => 1); + $this->_formValues['group'] = [$this->_groupID => 1]; } //search for civicase @@ -269,12 +266,7 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { !$this->_formValues['case_owner'] && !$this->_force ) { - foreach (array( - 'case_type_id', - 'case_status_id', - 'case_deleted', - 'case_tags', - ) as $caseCriteria) { + foreach (['case_type_id', 'case_status_id', 'case_deleted', 'case_tags'] as $caseCriteria) { if (!empty($this->_formValues[$caseCriteria])) { $allCases = TRUE; $this->_formValues['case_owner'] = 1; @@ -337,7 +329,7 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { } $config = CRM_Core_Config::singleton(); - $specialParams = array( + $specialParams = [ 'financial_type_id', 'contribution_soft_credit_type_id', 'contribution_status', @@ -355,11 +347,11 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { 'group', 'contact_tags', 'preferred_communication_method', - ); - $changeNames = array( + ]; + $changeNames = [ 'status_id' => 'activity_status_id', 'priority_id' => 'activity_priority_id', - ); + ]; CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, $specialParams, $changeNames); $taglist = CRM_Utils_Array::value('contact_taglist', $this->_formValues); @@ -407,7 +399,7 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { // This tag is a tagset unset($defaults['contact_tags'][$key]); if (!isset($defaults[$element])) { - $defaults[$element] = array(); + $defaults[$element] = []; } $defaults[$element][] = $tagId; } @@ -434,7 +426,7 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { $defaults['country'] = CRM_Core_DAO::singleValueQuery( "SELECT country_id FROM civicrm_state_province WHERE id = %1", - array(1 => array($defaults['state_province'][0], 'Integer')) + [1 => [$defaults['state_province'][0], 'Integer']] ); } } -- 2.25.1