Some more notice fixes in smarty
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 10 Feb 2022 00:30:22 +0000 (13:30 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 10 Feb 2022 00:30:22 +0000 (13:30 +1300)
CRM/Contact/Form/Search.php
CRM/Core/Form.php
CRM/Core/Form/Search.php
CRM/Event/Form/Search.php
templates/CRM/common/searchResultTasks.tpl

index a737667a8bfbc14c54f2e153b1c77ce1eab6a449..51b5fb670e59128fae14d837aa061222d33cd71a 100644 (file)
@@ -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
index d3e8a94306b98b9d2d4678de16219a6bf3df01a6..88ae11e9be1eaa4df791a561b45142eb0478814c 100644 (file)
@@ -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.
    *
index 0a9969685f7b4908ec3b0e8060c368849c008ee8..480986ba662a86d9c0918959515547cd24c49d07 100644 (file)
@@ -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']);
   }
 
   /**
index ac4404ca6de11e530b1b2f84dcebfa42bd935a0a..0c2ce4dbf53b0adaeb49ea72987d4f34d26a8dea 100644 (file)
@@ -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);
     }
index c126d858a1f47adde06fe1279a0f5f2eb3959bcb..14a873dca04316e79fedfce54ba97ef68d99bc39 100644 (file)
@@ -14,7 +14,7 @@
   <tr>
     <td style="width: 40%;">
     {if !empty($savedSearch.name)}{$savedSearch.name} ({ts}smart group{/ts}) - {/if}
-    {ts count=$pager->_totalItems plural='%count Results'}%count Result{/ts}{if !empty($selectorLabel)}&nbsp;-&nbsp;{$selectorLabel}{/if}
+    {ts count=$pager->_totalItems plural='%count Results'}%count Result{/ts}{if $selectorLabel}&nbsp;-&nbsp;{$selectorLabel}{/if}
     {if $context == 'Event' && $participantCount && ( $pager->_totalItems ne $participantCount ) }
         <br />{ts}Actual participant count{/ts} : {$participantCount} {help id="id-actual_participant_count" file="CRM/Event/Form/Search/Results.hlp"} &nbsp;
     {/if}