From c106cf12ec4b2168abaaf304fd60f46f350161af Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Wed, 15 Oct 2014 13:41:00 -0400
Subject: [PATCH] Per column cart settings in combined for blueprint and
 bootstrap.

---
 themes/blueprint/css/combined.css                 |  3 ++-
 .../templates/combined/results-list.phtml         | 14 ++++++++++++--
 themes/blueprint/templates/combined/results.phtml | 13 ++++++++++++-
 .../templates/combined/stack-distributed.phtml    | 13 ++++++++++---
 .../blueprint/templates/combined/stack-left.phtml | 13 ++++++++++---
 .../templates/combined/stack-right.phtml          | 13 ++++++++++---
 themes/bootstrap/css/combined.css                 |  8 ++++++--
 .../templates/combined/results-list.phtml         |  7 +++++--
 themes/bootstrap/templates/combined/results.phtml | 15 +++++++++++++--
 .../templates/combined/stack-distributed.phtml    |  7 ++++++-
 .../bootstrap/templates/combined/stack-left.phtml |  7 ++++++-
 .../templates/combined/stack-right.phtml          | 13 +++++++++----
 .../templates/combined/results-list.phtml         |  6 ++++--
 13 files changed, 105 insertions(+), 27 deletions(-)

diff --git a/themes/blueprint/css/combined.css b/themes/blueprint/css/combined.css
index 30b9f0b9ead..ca97db52e51 100644
--- a/themes/blueprint/css/combined.css
+++ b/themes/blueprint/css/combined.css
@@ -1,4 +1,5 @@
 .main {padding:0;}
 .main .combined-list {margin:0 2px;}
 .main .combined-list .result [class^=span-] {width:100%;}
-.main .combined-list .result .summcover {display:block;margin:0 auto;}
\ No newline at end of file
+.main .combined-list .result .summcover {display:block;margin:0 auto;}
+.main .combined-list .result .span-15 {margin-left:5px;width:80%}
\ No newline at end of file
diff --git a/themes/blueprint/templates/combined/results-list.phtml b/themes/blueprint/templates/combined/results-list.phtml
index 6726e21f57d..96011c43914 100644
--- a/themes/blueprint/templates/combined/results-list.phtml
+++ b/themes/blueprint/templates/combined/results-list.phtml
@@ -64,8 +64,18 @@
     <?=$this->recommend($current)?>
   <? endforeach; ?>
 <? else: ?>
-  <? $viewType = in_array('list', array_keys($params->getViewList())) ? 'list' : $params->getView(); ?>
-  <?=$this->render('search/list-' . $viewType . '.phtml', array('results' => $results, 'params' => $params))?>
+  <?
+    $viewType = in_array('list', array_keys($params->getViewList()))
+      ? 'list' : $params->getView();
+    $viewParams = array(
+      'results' => $results,
+      'params' => $params
+    );
+    if(isset($this->showCartControls) && !$this->showCartControls) {
+      $viewParams['hideCartControls'] = true;
+    }
+  ?>
+  <?=$this->render('search/list-' . $viewType . '.phtml', $viewParams)?>
   <? if ($currentSearch['more_link']): ?>
     <p class="more_link"><a href="<?=$moreUrl?>"><?=$this->transEsc($currentSearch['more_link'])?></a></p>
   <? endif; ?>
diff --git a/themes/blueprint/templates/combined/results.phtml b/themes/blueprint/templates/combined/results.phtml
index ca6f722f128..750911d0878 100644
--- a/themes/blueprint/templates/combined/results.phtml
+++ b/themes/blueprint/templates/combined/results.phtml
@@ -34,6 +34,9 @@
             $this->escapeHtml($lookfor) . '</em>';
     }
 
+    // Enable cart if appropriate:
+    $this->showCartControls = $this->supportsCart && $this->cart()->isActive();
+
     // Load Javascript dependencies into header:
     $this->headScript()->appendFile("check_item_statuses.js");
     $this->headScript()->appendFile("check_save_statuses.js");
@@ -49,7 +52,15 @@
     </div>
   <? endif; ?>
   <?=$this->flashmessages()?>
-  <?=$this->context($this)->renderInContext('combined/stack-'.$placement.'.phtml', array('searchClassId' => $searchClassId, 'combinedResults' => $this->combinedResults))?>
+  <?
+    $viewParams = array(
+      'searchClassId' => $searchClassId,
+      'combinedResults' => $this->combinedResults,
+      'supportsCartOptions' => $this->supportsCartOptions,
+      'showCartControls' => $this->showCartControls
+    );
+  ?>
+  <?=$this->context($this)->renderInContext('combined/stack-'.$placement.'.phtml', $viewParams)?>
 </div>
 <? /* End Main Listing */ ?>
 
diff --git a/themes/blueprint/templates/combined/stack-distributed.phtml b/themes/blueprint/templates/combined/stack-distributed.phtml
index 8d4172bc89a..840177f676c 100644
--- a/themes/blueprint/templates/combined/stack-distributed.phtml
+++ b/themes/blueprint/templates/combined/stack-distributed.phtml
@@ -14,10 +14,17 @@
       <? $currentSearch = $searches[$columnIndex]; ?>
       <? if ((!isset($currentSearch['ajax']) || !$currentSearch['ajax']) && isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty'] && $currentSearch['view']->results->getResultTotal() == 0) { $columnIndex += $columns; continue; } ?>
         <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>">
-          <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
-          <?=$this->render('combined/results-' . $templateSuffix . '.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?>
+          <?
+            $viewParams = array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch);
+            // Enable cart if appropriate:
+            $viewParams['showCartControls'] = $this->supportsCartOptions[$columnIndex] && $this->showCartControls;
+          ?>
+          <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>">
+            <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
+            <?=$this->render('combined/results-' . $templateSuffix . '.phtml', $viewParams)?>
+          </div>
         </div>
       <? $columnIndex += $columns ?>
     <? endwhile; ?>
   </div>
-<? endfor; ?>
\ No newline at end of file
+<? endfor; ?>
diff --git a/themes/blueprint/templates/combined/stack-left.phtml b/themes/blueprint/templates/combined/stack-left.phtml
index bd3d72e3356..012ed3507d0 100644
--- a/themes/blueprint/templates/combined/stack-left.phtml
+++ b/themes/blueprint/templates/combined/stack-left.phtml
@@ -21,8 +21,15 @@
   <? $currentSearch = $searches[$columnIndex]; ?>
   <div class="span-<?=$span ?> combined-list">
     <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>">
-      <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
-      <?=$this->render('combined/results-' . $templateSuffix . '.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?>
+      <?
+        $viewParams = array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch);
+        // Enable cart if appropriate:
+        $viewParams['showCartControls'] = $this->supportsCartOptions[$columnIndex] && $this->showCartControls;
+      ?>
+      <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>">
+        <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
+        <?=$this->render('combined/results-' . $templateSuffix . '.phtml', $viewParams)?>
+      </div>
     </div>
   </div>
-<? endfor; ?>
\ No newline at end of file
+<? endfor; ?>
diff --git a/themes/blueprint/templates/combined/stack-right.phtml b/themes/blueprint/templates/combined/stack-right.phtml
index 8f8031d0bba..90195563ffc 100644
--- a/themes/blueprint/templates/combined/stack-right.phtml
+++ b/themes/blueprint/templates/combined/stack-right.phtml
@@ -7,11 +7,18 @@
     <div class="span-<?=$span ?> combined-list">
   <? endif; ?>
     <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>">
-      <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
-      <?=$this->render('combined/results-' . $templateSuffix . '.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?>
+      <?
+        $viewParams = array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch);
+        // Enable cart if appropriate:
+        $viewParams['showCartControls'] = $this->supportsCartOptions[$columnIndex] && $this->showCartControls;
+      ?>
+      <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>">
+        <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
+        <?=$this->render('combined/results-' . $templateSuffix . '.phtml', $viewParams)?>
+      </div>
     </div>
   <? ++$columnIndex ?>
   <? if($columnIndex < $columns || $columnIndex == $sectionCount): ?>
     </div>
   <? endif; ?>
-<? endforeach; ?>
\ No newline at end of file
+<? endforeach; ?>
diff --git a/themes/bootstrap/css/combined.css b/themes/bootstrap/css/combined.css
index 03e6f28ce06..7c3bb4e6a04 100644
--- a/themes/bootstrap/css/combined.css
+++ b/themes/bootstrap/css/combined.css
@@ -1,3 +1,7 @@
-.combined-list .result .left   {width:23.0769%}
-.combined-list .result .middle {width:65.812%}
+.combined-list .result .left   {margin:0;width:25%}
+.combined-list .result .middle {margin:0;width:65%}
 .combined-list .result .right  {display:none}
+.result {padding-right:0}
+.result > .checkbox {padding-right:0;width:10%}
+.result > .span11 {margin:0;width:85%}
+.form-inline > .clearfix {margin-left:7px}
diff --git a/themes/bootstrap/templates/combined/results-list.phtml b/themes/bootstrap/templates/combined/results-list.phtml
index 0c796a2d755..fd9f8eb3218 100644
--- a/themes/bootstrap/templates/combined/results-list.phtml
+++ b/themes/bootstrap/templates/combined/results-list.phtml
@@ -66,8 +66,11 @@
   <?
     $viewType = in_array('list', array_keys($params->getViewList()))
       ? 'list' : $params->getView();
-    $viewParams = array('results' => $results, 'params' => $params);
-    if (!$params->getOptions()->supportsCart()) {
+    $viewParams = array(
+      'results' => $results,
+      'params' => $params
+    );
+    if(isset($this->showCartControls) && !$this->showCartControls) {
       $viewParams['hideCartControls'] = true;
     }
   ?>
diff --git a/themes/bootstrap/templates/combined/results.phtml b/themes/bootstrap/templates/combined/results.phtml
index 8e275c03c41..d20c3f85ec4 100644
--- a/themes/bootstrap/templates/combined/results.phtml
+++ b/themes/bootstrap/templates/combined/results.phtml
@@ -34,6 +34,9 @@
       $this->escapeHtml($lookfor) . '</li>';
   }
 
+  // Enable cart if appropriate:
+  $this->showCartControls = $this->supportsCart && $this->cart()->isActive();
+
   // Load Javascript dependencies into header:
   $this->headScript()->appendFile("check_item_statuses.js");
   $this->headScript()->appendFile("check_save_statuses.js");
@@ -49,12 +52,20 @@
       <? endforeach; ?>
     </div>
   <? endif; ?>
-  <? if ($this->supportsCart && $this->cart()->isActive()): ?>
+  <? if ($this->showCartControls): ?>
     <div class="clearfix">
       <?=$this->context($this)->renderInContext('search/bulk-action-buttons.phtml', array('idPrefix' => ''))?>
     </div>
   <? endif; ?>
-  <?=$this->context($this)->renderInContext('combined/stack-'.$placement.'.phtml', array('searchClassId' => $searchClassId, 'combinedResults' => $this->combinedResults))?>
+  <?
+    $viewParams = array(
+      'searchClassId' => $searchClassId,
+      'combinedResults' => $this->combinedResults,
+      'supportsCartOptions' => $this->supportsCartOptions,
+      'showCartControls' => $this->showCartControls
+    );
+  ?>
+  <?=$this->context($this)->renderInContext('combined/stack-'.$placement.'.phtml', $viewParams)?>
   <? $recs = $combinedResults->getRecommendations('bottom'); if (!empty($recs)): ?>
     <div>
       <? foreach ($recs as $current): ?>
diff --git a/themes/bootstrap/templates/combined/stack-distributed.phtml b/themes/bootstrap/templates/combined/stack-distributed.phtml
index f6edf5c9ab0..5b498a8c2a5 100644
--- a/themes/bootstrap/templates/combined/stack-distributed.phtml
+++ b/themes/bootstrap/templates/combined/stack-distributed.phtml
@@ -14,9 +14,14 @@
         <? $searchClassId = $keys[$columnIndex]; ?>
         <? $currentSearch = $searches[$columnIndex]; ?>
         <? if ((!isset($currentSearch['ajax']) || !$currentSearch['ajax']) && isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty'] && $currentSearch['view']->results->getResultTotal() == 0) { $columnIndex += $columns; continue; } ?>
+          <?
+            $viewParams = array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch);
+            // Enable cart if appropriate:
+            $viewParams['showCartControls'] = $this->supportsCartOptions[$columnIndex] && $this->showCartControls;
+          ?>
           <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>">
             <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
-            <?=$this->render('combined/results-' . $templateSuffix . '.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?>
+            <?=$this->render('combined/results-' . $templateSuffix . '.phtml', $viewParams)?>
           </div>
         <? $columnIndex += $columns ?>
       <? endwhile; ?>
diff --git a/themes/bootstrap/templates/combined/stack-left.phtml b/themes/bootstrap/templates/combined/stack-left.phtml
index 7e1bc8e6c8c..6aa2a320d60 100644
--- a/themes/bootstrap/templates/combined/stack-left.phtml
+++ b/themes/bootstrap/templates/combined/stack-left.phtml
@@ -11,9 +11,14 @@
     <? for ($columnIndex = $columns-1;$columnIndex < $sectionCount;$columnIndex++): ?>
       <? $searchClassId = $keys[$columnIndex]; ?>
       <? $currentSearch = $searches[$columnIndex]; ?>
+      <?
+        $viewParams = array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch);
+        // Enable cart if appropriate:
+        $viewParams['showCartControls'] = $this->supportsCartOptions[$columnIndex] && $this->showCartControls;
+      ?>
       <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>">
         <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
-        <?=$this->render('combined/results-' . $templateSuffix . '.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?>
+        <?=$this->render('combined/results-' . $templateSuffix . '.phtml', $viewParams)?>
       </div>
     <? endfor; ?>
   </div>
diff --git a/themes/bootstrap/templates/combined/stack-right.phtml b/themes/bootstrap/templates/combined/stack-right.phtml
index 8240eb5668d..d163a33f118 100644
--- a/themes/bootstrap/templates/combined/stack-right.phtml
+++ b/themes/bootstrap/templates/combined/stack-right.phtml
@@ -7,10 +7,15 @@
     <? if ($columnIndex < $columns): ?>
       <div class="span<?=$span ?> combined-list">
     <? endif; ?>
-      <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>">
-        <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
-        <?=$this->render('combined/results-' . $templateSuffix . '.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?>
-      </div>
+    <?
+      $viewParams = array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch);
+      // Enable cart if appropriate:
+      $viewParams['showCartControls'] = $this->supportsCartOptions[$columnIndex] && $this->showCartControls;
+    ?>
+    <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>">
+      <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
+      <?=$this->render('combined/results-' . $templateSuffix . '.phtml', $viewParams)?>
+    </div>
     <? ++$columnIndex ?>
     <? if($columnIndex < $columns || $columnIndex == $sectionCount): ?>
       </div>
diff --git a/themes/bootstrap3/templates/combined/results-list.phtml b/themes/bootstrap3/templates/combined/results-list.phtml
index 678ee6f7013..de2d54fa7c1 100644
--- a/themes/bootstrap3/templates/combined/results-list.phtml
+++ b/themes/bootstrap3/templates/combined/results-list.phtml
@@ -68,9 +68,11 @@
       ? 'list' : $params->getView();
     $viewParams = array(
       'results' => $results,
-      'params' => $params,
-      'showCartControls' => $this->showCartControls
+      'params' => $params
     );
+    if(isset($this->showCartControls) && !$this->showCartControls) {
+      $viewParams['hideCartControls'] = true;
+    }
   ?>
   <?=$this->render('search/list-' . $viewType . '.phtml', $viewParams)?>
   <? if ($currentSearch['more_link']): ?>
-- 
GitLab