diff --git a/module/VuFind/src/VuFind/Controller/CombinedController.php b/module/VuFind/src/VuFind/Controller/CombinedController.php index 4e9cc2188ee7bd2bc4a231fa4714af4d4c88f8a1..ef04476b8fcd9dcc2563e5f6c2ce97f897c06938 100644 --- a/module/VuFind/src/VuFind/Controller/CombinedController.php +++ b/module/VuFind/src/VuFind/Controller/CombinedController.php @@ -102,11 +102,21 @@ class CombinedController extends AbstractSearch ) { $html = ''; } else { + $cart = $this->getServiceLocator()->get('VuFind\Cart'); + $general = $this->getServiceLocator()->get('VuFind\Config') + ->get('config'); + $viewParams = array( + 'searchClassId' => $searchClassId, + 'currentSearch' => $settings, + 'showCartControls' => $currentOptions->supportsCart() + && $cart->isActive(), + 'showBulkOptions' => $currentOptions->supportsCart() + && isset($general->Site->showBulkOptions) + && $general->Site->showBulkOptions + ); $html = $this->getViewRenderer()->render( 'combined/results-list.phtml', - array( - 'searchClassId' => $searchClassId, 'currentSearch' => $settings - ) + $viewParams ); } $response->setContent($html); @@ -142,16 +152,18 @@ class CombinedController extends AbstractSearch ->get('VuFind\SearchOptionsPluginManager'); $config = $this->getServiceLocator()->get('VuFind\Config')->get('combined') ->toArray(); - $supportsCart = false; + $supportsCart = true; + $supportsCartOptions = array(); foreach ($config as $current => $settings) { // Special case -- ignore recommendation config: - if ($current == 'RecommendationModules') { + if ($current == 'Layout' || $current == 'RecommendationModules') { continue; } $this->adjustQueryForSettings($settings); $currentOptions = $options->get($current); + $supportsCartOptions[] = $currentOptions->supportsCart(); if ($currentOptions->supportsCart()) { - $supportsCart = true; + $supportsCart = true; } list($controller, $action) = explode('-', $currentOptions->getSearchAction()); @@ -171,13 +183,33 @@ class CombinedController extends AbstractSearch // Run the search to obtain recommendations: $results->performAndProcessSearch(); + $columns = isset($config['Layout']['columns']) + && intval($config['Layout']['columns']) <= count($combinedResults) + ? intval($config['Layout']['columns']) + : count($combinedResults); + $placement = isset($config['Layout']['stack_placement']) + ? $config['Layout']['stack_placement'] + : 'distributed'; + if (!in_array($placement, array('distributed', 'left', 'right'))) { + $placement = 'distributed'; + } + + // Get default config for showBulkOptions + $settings = $this->getServiceLocator()->get('VuFind\Config')->get('config'); + // Build view model: return $this->createViewModel( array( - 'results' => $results, - 'params' => $params, + 'columns' => $columns, 'combinedResults' => $combinedResults, + 'config' => $config, + 'params' => $params, + 'placement' => $placement, + 'results' => $results, 'supportsCart' => $supportsCart, + 'supportsCartOptions' => $supportsCartOptions, + 'showBulkOptions' => isset($settings->Site->showBulkOptions) + && $settings->Site->showBulkOptions ) ); } @@ -233,3 +265,4 @@ class CombinedController extends AbstractSearch $query->noRecommend = 1; } } + diff --git a/themes/bootstrap3/templates/combined/results-list.phtml b/themes/bootstrap3/templates/combined/results-list.phtml index 85712c53c6a9e9c91174eb563515c48971c78e6a..fa1f250eee05b509cd2d6d6c6bba8b4601a476bb 100644 --- a/themes/bootstrap3/templates/combined/results-list.phtml +++ b/themes/bootstrap3/templates/combined/results-list.phtml @@ -66,10 +66,12 @@ <? $viewType = in_array('list', array_keys($params->getViewList())) ? 'list' : $params->getView(); - $viewParams = array('results' => $results, 'params' => $params); - if (!$params->getOptions()->supportsCart()) { - $viewParams['hideCartControls'] = true; - } + $viewParams = array( + 'results' => $results, + 'params' => $params, + 'showCartControls' => $this->showCartControls, + 'showBulkOptions' => $this->showBulkOptions + ); ?> <?=$this->render('search/list-' . $viewType . '.phtml', $viewParams)?> <? if ($currentSearch['more_link']): ?> diff --git a/themes/bootstrap3/templates/combined/results.phtml b/themes/bootstrap3/templates/combined/results.phtml index 6d80bb93c19da62b70383d303ae10fd2c94c19e8..e2988b6daaccae735a91382b51ff77af93e50917 100644 --- a/themes/bootstrap3/templates/combined/results.phtml +++ b/themes/bootstrap3/templates/combined/results.phtml @@ -34,6 +34,11 @@ $this->escapeHtml($lookfor) . '</li>'; } + // Disable cart if appropriate: + $this->showCartControls = $this->supportsCart && $this->cart()->isActive(); + // Disable bulk options if appropriate: + $this->showBulkOptions = $this->supportsCart && $this->showBulkOptions; + // Load Javascript dependencies into header: $this->headScript()->appendFile("check_item_statuses.js"); $this->headScript()->appendFile("check_save_statuses.js"); @@ -54,19 +59,16 @@ <?=$this->context($this)->renderInContext('search/bulk-action-buttons.phtml', array('idPrefix' => ''))?> </div> <? endif; ?> - <div class="row"> - <? $columns = count($this->combinedResults); ?> - <? foreach ($this->combinedResults as $searchClassId => $currentSearch): ?> - <? if ((!isset($currentSearch['ajax']) || !$currentSearch['ajax']) && isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty'] && $currentSearch['view']->results->getResultTotal() == 0) { continue; } ?> - <div class="col-sm-<?=floor(12/$columns)?> combined-list" id="combined_<?=$this->escapeHtml($searchClassId)?>"> - <? if (isset($currentSearch['ajax']) && $currentSearch['ajax']): ?> - <?=$this->render('combined/results-ajax.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?> - <? else: ?> - <?=$this->render('combined/results-list.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?> - <? endif; ?> - </div> - <? endforeach; ?> - </div> + <? + $viewParams = array( + 'searchClassId' => $searchClassId, + 'combinedResults' => $this->combinedResults, + 'supportsCartOptions' => $this->supportsCartOptions, + 'showCartControls' => $this->showCartControls, + 'showBulkOptions' => $this->showBulkOptions + ); + ?> + <?=$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/bootstrap3/templates/combined/stack-distributed.phtml b/themes/bootstrap3/templates/combined/stack-distributed.phtml new file mode 100644 index 0000000000000000000000000000000000000000..6344f61f376bba061b1a105db7dac6a137c5de7d --- /dev/null +++ b/themes/bootstrap3/templates/combined/stack-distributed.phtml @@ -0,0 +1,32 @@ +<div class="row"> + <? $span = floor(12/$columns); ?> + <? $sectionCount = count($this->combinedResults); ?> + <? $keys = array(); ?> + <? $searches = array(); ?> + <? foreach ($this->combinedResults as $searchClassId => $currentSearch): ?> + <? $keys[] = $searchClassId; ?> + <? $searches[] = $currentSearch; ?> + <? endforeach; ?> + <? for ($column=0;$column<$columns;$column++): ?> + <? $columnIndex = $column; ?> + <div class="col-sm-<?=$span ?> combined-list"> + <? while ($columnIndex < $sectionCount): ?> + <? $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); + // Disable cart if appropriate: + $viewParams['showCartControls'] = $this->supportsCartOptions[$columnIndex] && $this->showCartControls; + // Disable bulk options if appropriate: + $viewParams['showBulkOptions'] = $this->supportsCartOptions[$columnIndex] && $this->showBulkOptions; + ?> + <div id="combined_<?=$this->escapeHtmlAttr($searchClassId)?>"> + <? $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?> + <?=$this->render('combined/results-' . $templateSuffix . '.phtml', $viewParams)?> + </div> + <? $columnIndex += $columns ?> + <? endwhile; ?> + </div> + <? endfor; ?> +</div> \ No newline at end of file diff --git a/themes/bootstrap3/templates/combined/stack-left.phtml b/themes/bootstrap3/templates/combined/stack-left.phtml new file mode 100644 index 0000000000000000000000000000000000000000..66666fd86f243fa2c1a628fd63f68e92542f4e99 --- /dev/null +++ b/themes/bootstrap3/templates/combined/stack-left.phtml @@ -0,0 +1,26 @@ +<div class="row"> + <? $columnIndex = 0; ?> + <? $span = floor(12/$columns); ?> + <? $sectionCount = count($this->combinedResults); ?> + <? foreach ($this->combinedResults as $searchClassId => $currentSearch): ?> + <? if ((!isset($currentSearch['ajax']) || !$currentSearch['ajax']) && isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty'] && $currentSearch['view']->results->getResultTotal() == 0) { continue; } ?> + <? if ($columnIndex < $columns): ?> + <div class="col-sm-<?=$span ?><? if($columnIndex == $columns-1): ?> col-sm-pull-<?=$span*($columns-1) ?><? else: ?> col-sm-push-<?=$span ?><? endif; ?> combined-list"> + <? endif; ?> + <? + $viewParams = array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch); + // Disable cart if appropriate: + $viewParams['showCartControls'] = $this->showCartControls; + // Disable bulk options if appropriate: + $viewParams['showBulkOptions'] = $this->showBulkOptions; + ?> + <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> + <? endif; ?> + <? endforeach; ?> +</div> \ No newline at end of file diff --git a/themes/bootstrap3/templates/combined/stack-right.phtml b/themes/bootstrap3/templates/combined/stack-right.phtml new file mode 100644 index 0000000000000000000000000000000000000000..c38a48f17b7f047e6abb2a9cd7dc2a79fe4c899c --- /dev/null +++ b/themes/bootstrap3/templates/combined/stack-right.phtml @@ -0,0 +1,26 @@ +<div class="row"> + <? $columnIndex = 0; ?> + <? $span = floor(12/$columns); ?> + <? $sectionCount = count($this->combinedResults); ?> + <? foreach ($this->combinedResults as $searchClassId => $currentSearch): ?> + <? if ((!isset($currentSearch['ajax']) || !$currentSearch['ajax']) && isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty'] && $currentSearch['view']->results->getResultTotal() == 0) { continue; } ?> + <? if ($columnIndex < $columns): ?> + <div class="col-sm-<?=$span ?> combined-list"> + <? endif; ?> + <? + $viewParams = array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch); + // Disable cart if appropriate: + $viewParams['showCartControls'] = $this->showCartControls; + // Disable bulk options if appropriate: + $viewParams['showBulkOptions'] = $this->showBulkOptions; + ?> + <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> + <? endif; ?> + <? endforeach; ?> +</div> \ No newline at end of file diff --git a/themes/bootstrap3/templates/search/list-list.phtml b/themes/bootstrap3/templates/search/list-list.phtml index 0986c37cdcfc22eb13fe8d22c444e0e00a1f5aac..624b9d9f0c6c03b99e34ed27c378b05e471b456a 100644 --- a/themes/bootstrap3/templates/search/list-list.phtml +++ b/themes/bootstrap3/templates/search/list-list.phtml @@ -1,10 +1,16 @@ <? if (!isset($this->indexStart)) $this->indexStart = 0; ?> +<? $showCheckboxes = (isset($this->showCartControls) && $this->showCartControls) + || (isset($this->showBulkOptions) && $this->showBulkOptions); ?> <? $i = $this->indexStart; foreach ($this->results->getResults() as $current): $recordNumber = $this->results->getStartRecord()+$i-$this->indexStart; ?> <div id="result<?=$i++ ?>" class="row result clearfix"> - <div class="col-xs-1 hidden-print checkbox"> + <div class="col-xs-1 hidden-print<? if ($showCheckboxes): ?> checkbox<? endif; ?>"> <label> +<<<<<<< HEAD <? if (!isset($this->hideCartControls) && $this->cart()->isActive()): ?> +======= + <? if ($showCheckboxes): ?> +>>>>>>> b916700... Per column cart support checking and logic compression. <?=$this->record($current)->getCheckbox()?> <? endif; ?> <?=$recordNumber?> diff --git a/themes/bootstrap3/templates/search/results.phtml b/themes/bootstrap3/templates/search/results.phtml index 85d2a9a62dbbbdfed817f104094826b996ae3694..dfa5837445eb1235cfd145f8f710d362df5ba01b 100644 --- a/themes/bootstrap3/templates/search/results.phtml +++ b/themes/bootstrap3/templates/search/results.phtml @@ -31,9 +31,15 @@ } // Disable cart if appropriate: +<<<<<<< HEAD if (!$this->params->getOptions()->supportsCart()) { $this->hideCartControls = true; } +======= + $this->showCartControls = $this->params->getOptions()->supportsCart() && $this->cart()->isActive(); + // Disable bulk options if appropriate: + $this->showBulkOptions = $this->params->getOptions()->supportsCart() && $this->showBulkOptions; +>>>>>>> b916700... Per column cart support checking and logic compression. // Load Javascript dependencies into header: $this->headScript()->appendFile("check_item_statuses.js");