Skip to content
Snippets Groups Projects
Commit db755110 authored by Chris Hallberg's avatar Chris Hallberg
Browse files

Per column cart support checking and logic compression.

Conflicts:
	module/VuFind/src/VuFind/Controller/CombinedController.php
	themes/bootstrap3/templates/combined/results-list.phtml
	themes/bootstrap3/templates/combined/results.phtml
	themes/bootstrap3/templates/combined/stack-distributed.phtml
	themes/bootstrap3/templates/combined/stack-left.phtml
	themes/bootstrap3/templates/combined/stack-right.phtml
	themes/bootstrap3/templates/search/list-list.phtml
	themes/bootstrap3/templates/search/results.phtml
parent 8ee52e20
No related merge requests found
...@@ -102,11 +102,21 @@ class CombinedController extends AbstractSearch ...@@ -102,11 +102,21 @@ class CombinedController extends AbstractSearch
) { ) {
$html = ''; $html = '';
} else { } 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( $html = $this->getViewRenderer()->render(
'combined/results-list.phtml', 'combined/results-list.phtml',
array( $viewParams
'searchClassId' => $searchClassId, 'currentSearch' => $settings
)
); );
} }
$response->setContent($html); $response->setContent($html);
...@@ -142,16 +152,18 @@ class CombinedController extends AbstractSearch ...@@ -142,16 +152,18 @@ class CombinedController extends AbstractSearch
->get('VuFind\SearchOptionsPluginManager'); ->get('VuFind\SearchOptionsPluginManager');
$config = $this->getServiceLocator()->get('VuFind\Config')->get('combined') $config = $this->getServiceLocator()->get('VuFind\Config')->get('combined')
->toArray(); ->toArray();
$supportsCart = false; $supportsCart = true;
$supportsCartOptions = array();
foreach ($config as $current => $settings) { foreach ($config as $current => $settings) {
// Special case -- ignore recommendation config: // Special case -- ignore recommendation config:
if ($current == 'RecommendationModules') { if ($current == 'Layout' || $current == 'RecommendationModules') {
continue; continue;
} }
$this->adjustQueryForSettings($settings); $this->adjustQueryForSettings($settings);
$currentOptions = $options->get($current); $currentOptions = $options->get($current);
$supportsCartOptions[] = $currentOptions->supportsCart();
if ($currentOptions->supportsCart()) { if ($currentOptions->supportsCart()) {
$supportsCart = true; $supportsCart = true;
} }
list($controller, $action) list($controller, $action)
= explode('-', $currentOptions->getSearchAction()); = explode('-', $currentOptions->getSearchAction());
...@@ -171,13 +183,33 @@ class CombinedController extends AbstractSearch ...@@ -171,13 +183,33 @@ class CombinedController extends AbstractSearch
// Run the search to obtain recommendations: // Run the search to obtain recommendations:
$results->performAndProcessSearch(); $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: // Build view model:
return $this->createViewModel( return $this->createViewModel(
array( array(
'results' => $results, 'columns' => $columns,
'params' => $params,
'combinedResults' => $combinedResults, 'combinedResults' => $combinedResults,
'config' => $config,
'params' => $params,
'placement' => $placement,
'results' => $results,
'supportsCart' => $supportsCart, 'supportsCart' => $supportsCart,
'supportsCartOptions' => $supportsCartOptions,
'showBulkOptions' => isset($settings->Site->showBulkOptions)
&& $settings->Site->showBulkOptions
) )
); );
} }
...@@ -233,3 +265,4 @@ class CombinedController extends AbstractSearch ...@@ -233,3 +265,4 @@ class CombinedController extends AbstractSearch
$query->noRecommend = 1; $query->noRecommend = 1;
} }
} }
...@@ -66,10 +66,12 @@ ...@@ -66,10 +66,12 @@
<? <?
$viewType = in_array('list', array_keys($params->getViewList())) $viewType = in_array('list', array_keys($params->getViewList()))
? 'list' : $params->getView(); ? 'list' : $params->getView();
$viewParams = array('results' => $results, 'params' => $params); $viewParams = array(
if (!$params->getOptions()->supportsCart()) { 'results' => $results,
$viewParams['hideCartControls'] = true; 'params' => $params,
} 'showCartControls' => $this->showCartControls,
'showBulkOptions' => $this->showBulkOptions
);
?> ?>
<?=$this->render('search/list-' . $viewType . '.phtml', $viewParams)?> <?=$this->render('search/list-' . $viewType . '.phtml', $viewParams)?>
<? if ($currentSearch['more_link']): ?> <? if ($currentSearch['more_link']): ?>
......
...@@ -34,6 +34,11 @@ ...@@ -34,6 +34,11 @@
$this->escapeHtml($lookfor) . '</li>'; $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: // Load Javascript dependencies into header:
$this->headScript()->appendFile("check_item_statuses.js"); $this->headScript()->appendFile("check_item_statuses.js");
$this->headScript()->appendFile("check_save_statuses.js"); $this->headScript()->appendFile("check_save_statuses.js");
...@@ -54,19 +59,16 @@ ...@@ -54,19 +59,16 @@
<?=$this->context($this)->renderInContext('search/bulk-action-buttons.phtml', array('idPrefix' => ''))?> <?=$this->context($this)->renderInContext('search/bulk-action-buttons.phtml', array('idPrefix' => ''))?>
</div> </div>
<? endif; ?> <? endif; ?>
<div class="row"> <?
<? $columns = count($this->combinedResults); ?> $viewParams = array(
<? foreach ($this->combinedResults as $searchClassId => $currentSearch): ?> 'searchClassId' => $searchClassId,
<? if ((!isset($currentSearch['ajax']) || !$currentSearch['ajax']) && isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty'] && $currentSearch['view']->results->getResultTotal() == 0) { continue; } ?> 'combinedResults' => $this->combinedResults,
<div class="col-sm-<?=floor(12/$columns)?> combined-list" id="combined_<?=$this->escapeHtml($searchClassId)?>"> 'supportsCartOptions' => $this->supportsCartOptions,
<? if (isset($currentSearch['ajax']) && $currentSearch['ajax']): ?> 'showCartControls' => $this->showCartControls,
<?=$this->render('combined/results-ajax.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?> 'showBulkOptions' => $this->showBulkOptions
<? else: ?> );
<?=$this->render('combined/results-list.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?> ?>
<? endif; ?> <?=$this->context($this)->renderInContext('combined/stack-'.$placement.'.phtml', $viewParams)?>
</div>
<? endforeach; ?>
</div>
<? $recs = $combinedResults->getRecommendations('bottom'); if (!empty($recs)): ?> <? $recs = $combinedResults->getRecommendations('bottom'); if (!empty($recs)): ?>
<div> <div>
<? foreach ($recs as $current): ?> <? foreach ($recs as $current): ?>
......
<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
<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
<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
<? if (!isset($this->indexStart)) $this->indexStart = 0; ?> <? 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): <? $i = $this->indexStart; foreach ($this->results->getResults() as $current):
$recordNumber = $this->results->getStartRecord()+$i-$this->indexStart; ?> $recordNumber = $this->results->getStartRecord()+$i-$this->indexStart; ?>
<div id="result<?=$i++ ?>" class="row result clearfix"> <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> <label>
<<<<<<< HEAD
<? if (!isset($this->hideCartControls) && $this->cart()->isActive()): ?> <? if (!isset($this->hideCartControls) && $this->cart()->isActive()): ?>
=======
<? if ($showCheckboxes): ?>
>>>>>>> b916700... Per column cart support checking and logic compression.
<?=$this->record($current)->getCheckbox()?> <?=$this->record($current)->getCheckbox()?>
<? endif; ?> <? endif; ?>
<?=$recordNumber?> <?=$recordNumber?>
......
...@@ -31,9 +31,15 @@ ...@@ -31,9 +31,15 @@
} }
// Disable cart if appropriate: // Disable cart if appropriate:
<<<<<<< HEAD
if (!$this->params->getOptions()->supportsCart()) { if (!$this->params->getOptions()->supportsCart()) {
$this->hideCartControls = true; $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: // Load Javascript dependencies into header:
$this->headScript()->appendFile("check_item_statuses.js"); $this->headScript()->appendFile("check_item_statuses.js");
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment