From a73b5020b70fec11f31caedf0870b6324f04fcd4 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 6 May 2014 10:14:25 -0400 Subject: [PATCH] Smarter cart support in combined controller. --- .../src/VuFind/Controller/CombinedController.php | 7 ++++++- .../bootstrap/templates/combined/results-list.phtml | 11 +++++++++-- themes/bootstrap/templates/combined/results.phtml | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/CombinedController.php b/module/VuFind/src/VuFind/Controller/CombinedController.php index 77e2615c0aa..ab800fc9a64 100644 --- a/module/VuFind/src/VuFind/Controller/CombinedController.php +++ b/module/VuFind/src/VuFind/Controller/CombinedController.php @@ -131,9 +131,13 @@ class CombinedController extends AbstractSearch ->get('VuFind\SearchOptionsPluginManager'); $config = $this->getServiceLocator()->get('VuFind\Config')->get('combined') ->toArray(); + $supportsCart = false; foreach ($config as $current => $settings) { $this->adjustQueryForSettings($settings); $currentOptions = $options->get($current); + if ($currentOptions->supportsCart()) { + $supportsCart = true; + } list($controller, $action) = explode('-', $currentOptions->getSearchAction()); $combinedResults[$current] = $settings; @@ -154,7 +158,8 @@ class CombinedController extends AbstractSearch array( 'results' => $results, 'params' => $params, - 'combinedResults' => $combinedResults + 'combinedResults' => $combinedResults, + 'supportsCart' => $supportsCart, ) ); } diff --git a/themes/bootstrap/templates/combined/results-list.phtml b/themes/bootstrap/templates/combined/results-list.phtml index 0ffebf5b69f..38d780a394b 100644 --- a/themes/bootstrap/templates/combined/results-list.phtml +++ b/themes/bootstrap/templates/combined/results-list.phtml @@ -63,8 +63,15 @@ <?=$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 (!$params->getOptions()->supportsCart()) { + $viewParams['hideCartControls'] = true; + } + ?> + <?=$this->render('search/list-' . $viewType . '.phtml', $viewParams)?> <? if ($currentSearch['more_link']): ?> <p class="pad text-right"><a href="<?=$moreUrl?>"><?=$this->transEsc($currentSearch['more_link'])?> <i class="icon-long-arrow-right"></i></a></p> <? endif; ?> diff --git a/themes/bootstrap/templates/combined/results.phtml b/themes/bootstrap/templates/combined/results.phtml index 92f6cb49ef2..e380f189ade 100644 --- a/themes/bootstrap/templates/combined/results.phtml +++ b/themes/bootstrap/templates/combined/results.phtml @@ -38,7 +38,7 @@ ?> <?=$this->flashmessages()?> <form class="form-inline" method="post" name="bulkActionForm" action="<?=$this->url('cart-home')?>"> - <? if ($this->cart()->isActive()): ?> + <? if ($this->supportsCart && $this->cart()->isActive()): ?> <div class="clearfix"> <?=$this->context($this)->renderInContext('search/bulk-action-buttons.phtml', array('idPrefix' => ''))?> </div> -- GitLab