From 461c8a93cbb7a1b3d6c2887bc8664ffe36c4248f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 10 Feb 2022 13:30:22 +1300 Subject: [PATCH] Some more notice fixes in smarty --- CRM/Contact/Form/Search.php | 4 ++-- CRM/Core/Form.php | 12 ++++++++++++ CRM/Core/Form/Search.php | 2 ++ CRM/Event/Form/Search.php | 4 ++-- templates/CRM/common/searchResultTasks.tpl | 2 +- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index a737667a8b..51b5fb670e 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -392,9 +392,9 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), 'search_custom_id' => $search_custom_id, ]; - $this->assign_by_ref('savedSearch', $savedSearchValues); - $this->assign('ssID', $this->_ssID); } + $this->assign('savedSearch', $savedSearchValues ?? NULL); + $this->assign('ssID', $this->_ssID); if ($this->_context === 'smog') { // CRM-11788, we might want to do this for all of search where force=1 diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index d3e8a94306..88ae11e9be 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1113,6 +1113,18 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $this->expectedSmartyVariables[] = $elementName; } + /** + * Add an expected smarty variable to the array. + * + * @param array $elementNames + */ + public function addExpectedSmartyVariables(array $elementNames): void { + foreach ($elementNames as $elementName) { + // Duplicates don't actually matter.... + $this->addExpectedSmartyVariable($elementName); + } + } + /** * Render form and return contents. * diff --git a/CRM/Core/Form/Search.php b/CRM/Core/Form/Search.php index 0a9969685f..480986ba66 100644 --- a/CRM/Core/Form/Search.php +++ b/CRM/Core/Form/Search.php @@ -120,6 +120,8 @@ class CRM_Core_Form_Search extends CRM_Core_Form { $this->handleForcedSearch(); } $this->_formValues = $this->getFormValues(); + // For searchResultsTasks.tpl. + $this->addExpectedSmartyVariables(['savedSearch', 'selectorLabel']); } /** diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index ac4404ca6d..0c2ce4dbf5 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -200,9 +200,9 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { 'id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), ]; - $this->assign_by_ref('savedSearch', $savedSearchValues); - $this->assign('ssID', $this->_ssID); } + $this->assign('savedSearch', $savedSearchValues ?? NULL); + $this->assign('ssID', $this->_ssID); $this->addTaskMenu($tasks); } diff --git a/templates/CRM/common/searchResultTasks.tpl b/templates/CRM/common/searchResultTasks.tpl index c126d858a1..14a873dca0 100644 --- a/templates/CRM/common/searchResultTasks.tpl +++ b/templates/CRM/common/searchResultTasks.tpl @@ -14,7 +14,7 @@ {if !empty($savedSearch.name)}{$savedSearch.name} ({ts}smart group{/ts}) - {/if} - {ts count=$pager->_totalItems plural='%count Results'}%count Result{/ts}{if !empty($selectorLabel)} - {$selectorLabel}{/if} + {ts count=$pager->_totalItems plural='%count Results'}%count Result{/ts}{if $selectorLabel} - {$selectorLabel}{/if} {if $context == 'Event' && $participantCount && ( $pager->_totalItems ne $participantCount ) }
{ts}Actual participant count{/ts} : {$participantCount} {help id="id-actual_participant_count" file="CRM/Event/Form/Search/Results.hlp"}   {/if} -- 2.25.1