From 9a24c6f4f6e8d3ea990b5b0f5427d40d1dc5c724 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Wed, 7 May 2014 15:52:07 -0400
Subject: [PATCH] Fixed bootstrap search box for consistency with blueprint.

---
 .../templates/search/searchbox.phtml          | 45 +++++--------------
 1 file changed, 11 insertions(+), 34 deletions(-)

diff --git a/themes/bootstrap/templates/search/searchbox.phtml b/themes/bootstrap/templates/search/searchbox.phtml
index e2bed076f31..7ced9c84e37 100644
--- a/themes/bootstrap/templates/search/searchbox.phtml
+++ b/themes/bootstrap/templates/search/searchbox.phtml
@@ -52,19 +52,6 @@
         <a href="<?=$this->url($advSearch)?>" class="btn btn-link"><?=$this->transEsc("Advanced")?></a>
       <? endif; ?>
 
-      <?
-      /* Do we have any checkbox filters? */
-      $hasCheckboxFilters = false;
-      if (isset($this->checkboxFilters) && count($this->checkboxFilters) > 0) {
-        foreach ($this->checkboxFilters as $current) {
-          if ($current['selected']) {
-            $hasCheckboxFilters = true;
-            break;
-          }
-        }
-      }
-      ?>
-
       <? $shards = $options->getShards(); if ($options->showShardCheckboxes() && !empty($shards)): ?>
         <?
         $selectedShards = isset($this->selectedShards)
@@ -76,33 +63,23 @@
           <input type="checkbox" <?=$isSelected ? 'checked="checked" ' : ''?>name="shard[]" value='<?=$this->escapeHtml($shard)?>' /> <?=$this->transEsc($shard)?>
         <? endforeach; ?>
       <? endif; ?>
-      <? if ((isset($this->filterList) && is_array($this->filterList) && count($this->filterList) > 0) || $hasCheckboxFilters): ?>
+      <?
+        $filterDetails = $this->searchbox()->getFilterDetails(
+            isset($this->filterList) && is_array($this->filterList) ? $this->filterList : array(),
+            isset($this->checkboxFilters) && is_array($this->checkboxFilters) ? $this->checkboxFilters : array()
+        );
+      ?>
+      <? if (!empty($filterDetails)): ?>
         <? $defaultFilterState = $options->getRetainFilterSetting() ? ' checked="checked"' : ''; ?>
         <label class="checkbox">
           <input onChange="$('.applied-filter').click()" type="checkbox"<?=$defaultFilterState?> id="searchFormKeepFilters"/>
           <?=$this->transEsc("basic_search_keep_filters")?>
         </label>
         <div class="hidden">
-          <? if (isset($this->filterList) && is_array($this->filterList)): ?>
-            <? $i = 0; foreach ($this->filterList as $field => $data): ?>
-              <? foreach ($data as $value): ?>                  
-                <label class="checkbox">
-                  <input class="applied-filter" id="applied_filter_<?=++$i?>" type="checkbox"<?=$defaultFilterState?> name="filter[]" value="<?=$this->escapeHtml($field)?>:&quot;<?=$this->escapeHtml($value)?>&quot;" />
-                  <?=$this->escapeHtml($field)?>:&quot;<?=$this->escapeHtml($value)?>&quot;
-                </label>
-              <? endforeach; ?>
-            <? endforeach; ?>
-          <? endif; ?>
-          <? if ($hasCheckboxFilters): ?>
-            <? $i = 0; foreach ($checkboxFilters as $current): ?>
-              <? if ($current['selected']): ?>
-                <label class="checkbox">
-                  <input class="applied-filter" id="applied_checkbox_filter_<?=++$i?>" type="checkbox"<?=$defaultFilterState?> name="filter[]" value="<?=$this->escapeHtml($current['filter'])?>" />
-                  <?=$this->escapeHtml($current['filter'])?>
-                </label>
-              <? endif; ?>
-            <? endforeach; ?>
-          <? endif; ?>
+          <? foreach ($filterDetails as $current): ?>
+            <input id="<?=$this->escapeHtml($current['id'])?>" type="checkbox"<?=$defaultFilterState?> name="filter[]" value="<?=$this->escapeHtml($current['value'])?>" />
+            <label for="<?=$this->escapeHtml($current['id'])?>"><?=$this->escapeHtml($current['value'])?></label>
+          <? endforeach; ?>
         </div>
       <? endif; ?>
       <?
-- 
GitLab