Skip to content
Snippets Groups Projects
Commit 86391b6f authored by Chris Hallberg's avatar Chris Hallberg Committed by Demian Katz
Browse files

Breakup Recommendation/SideFacets into smaller templates (#892)

parent 2fe30aec
Branches
Tags
No related merge requests found
...@@ -7,238 +7,60 @@ ...@@ -7,238 +7,60 @@
<? if ($results->getResultTotal() > 0): ?> <? if ($results->getResultTotal() > 0): ?>
<h4><?=$this->transEsc(isset($this->overrideSideFacetCaption) ? $this->overrideSideFacetCaption : 'Narrow Search')?></h4> <h4><?=$this->transEsc(isset($this->overrideSideFacetCaption) ? $this->overrideSideFacetCaption : 'Narrow Search')?></h4>
<? endif; ?> <? endif; ?>
<? $checkboxFilters = $results->getParams()->getCheckboxFacets(); if (count($checkboxFilters) > 0): ?> <? $checkboxFilters = $results->getParams()->getCheckboxFacets(); ?>
<? <? $checkboxesShown = false; ?>
$html = ''; <? if (count($checkboxFilters) > 0):
$shown = 0; foreach ($checkboxFilters as $current) {
foreach ($checkboxFilters as $current) { if ($results->getResultTotal() > 0 || $current['selected'] || $current['alwaysVisible']) {
$html .= '<label class="checkbox'; $checkboxesShown = true;
if($results->getResultTotal() < 1 && !$current['selected'] && !$current['alwaysVisible']) { break;
$html .= ' hidden'; }
} else {
$shown ++;
} }
$html .= '"><input type="checkbox" name="filter[]" value="'.$this->escapeHtmlAttr($current['filter']).'" ?>
'. ($current['selected'] ? 'checked="checked"' : '') .' id="'.$this->escapeHtmlAttr(str_replace(' ', '', $current['desc'])).'" <?if ($checkboxesShown):?>
onclick="document.location.href=\''.($current['selected'] ? $results->getUrlQuery()->removeFilter($current['filter']) : $results->getUrlQuery()->addFilter($current['filter'])).'\';" />'.$this->transEsc($current['desc']).'</label>'; <div class="checkboxFilter">
} <?=$this->context($this)->renderInContext('Recommend/SideFacets/checkbox-filters.phtml', ['checkboxFilters' => $checkboxFilters, 'results' => $results]); ?>
?> </div>
<div class="checkboxFilter<?if($shown == 0):?> hidden<? endif; ?>"><?=$html ?></div> <? endif; ?>
<? endif; ?> <? endif; ?>
<? $extraFilters = isset($this->extraSideFacetFilters) ? $this->extraSideFacetFilters : []; ?> <? $extraFilters = isset($this->extraSideFacetFilters) ? $this->extraSideFacetFilters : []; ?>
<? $collapsedFacets = $this->recommend->getCollapsedFacets() ?> <? $collapsedFacets = $this->recommend->getCollapsedFacets() ?>
<? $hierarchicalFacetSortOptions = $this->recommend->getHierarchicalFacetSortOptions() ?> <? $filterList = array_merge($results->getParams()->getFilterList(true), $extraFilters); ?>
<? $hierarchicalFacets = $this->recommend->getHierarchicalFacets() ?> <? if (!empty($filterList)): ?>
<? $filterList = array_merge($results->getParams()->getFilterList(true), $extraFilters); if (!empty($filterList)): ?> <?=$this->context($this)->renderInContext('Recommend/SideFacets/filter-list.phtml', [
<div class="list-group filters"> 'collapsedFacets' => $collapsedFacets,
<div class="list-group-item title"><?=$this->transEsc('Remove Filters')?></div> 'extraFilters' => $extraFilters,
<? foreach ($filterList as $field => $filters): ?> 'filterList' => $filterList,
<? foreach ($filters as $i => $filter): ?> ]); ?>
<?
$index = isset($filter['field']) ? array_search($filter['field'], $collapsedFacets) : false;
if ($index !== false) {
unset($collapsedFacets[$index]); // Open if we have a match
}
if (isset($filter['specialType']) && $filter['specialType'] == 'keyword') {
$removeLink = $this->currentPath().$results->getUrlQuery()->replaceTerm($filter['value'], '');
} else {
$removeLink = $this->currentPath().$results->getUrlQuery()->removeFacet($filter['field'], $filter['value'], $filter['operator']);
}
if ($filter['displayText'] == '[* TO *]') {
$filter['displayText'] = $this->translate('filter_wildcard');
}
?>
<a class="list-group-item active" href="<?=$removeLink?>" title="<?=$this->transEsc('clear_tag_filter') ?>">
<span class="pull-right flip"><i class="fa fa-times" aria-hidden="true"></i></span>
<? if ($filter['operator'] == 'NOT') echo $this->transEsc('NOT') . ' '; if ($filter['operator'] == 'OR' && $i > 0) echo $this->transEsc('OR') . ' '; ?><?=$this->transEsc($field)?>: <?=$this->escapeHtml($filter['displayText'])?>
</a>
<? endforeach; ?>
<? endforeach; ?>
</div>
<? endif; ?> <? endif; ?>
<?= isset($this->sideFacetExtraControls) ? $this->sideFacetExtraControls : '' ?> <?= isset($this->sideFacetExtraControls) ? $this->sideFacetExtraControls : '' ?>
<? $sideFacetSet = $this->recommend->getFacetSet(); $rangeFacets = $this->recommend->getAllRangeFacets(); ?> <? $sideFacetSet = $this->recommend->getFacetSet(); $rangeFacets = $this->recommend->getAllRangeFacets(); ?>
<? $hierarchicalFacets = $this->recommend->getHierarchicalFacets() ?>
<? $hierarchicalFacetSortOptions = $this->recommend->getHierarchicalFacetSortOptions() ?>
<? if (!empty($sideFacetSet) && $results->getResultTotal() > 0): ?> <? if (!empty($sideFacetSet) && $results->getResultTotal() > 0): ?>
<? foreach ($sideFacetSet as $title => $cluster): ?> <? foreach ($sideFacetSet as $title => $cluster): ?>
<? $allowExclude = $this->recommend->excludeAllowed($title); ?>
<? $facets_before_more = $this->recommend->getShowMoreSetting($title); ?>
<? $showMoreInLightbox = $this->recommend->getShowInLightboxSetting($title); ?>
<div class="list-group facet" id="side-panel-<?=$this->escapeHtmlAttr($title) ?>"> <div class="list-group facet" id="side-panel-<?=$this->escapeHtmlAttr($title) ?>">
<div class="list-group-item title<? if(in_array($title, $collapsedFacets)): ?> collapsed<? endif ?>" data-toggle="collapse" href="#side-collapse-<?=$this->escapeHtmlAttr($title) ?>" > <div class="list-group-item title<? if(in_array($title, $collapsedFacets)): ?> collapsed<? endif ?>" data-toggle="collapse" href="#side-collapse-<?=$this->escapeHtmlAttr($title) ?>" >
<?=$this->transEsc($cluster['label'])?> <?=$this->transEsc($cluster['label'])?>
</div> </div>
<div id="side-collapse-<?=$this->escapeHtmlAttr($title) ?>" class="collapse<? if(!in_array($title, $collapsedFacets)): ?> in<? endif ?>"> <div id="side-collapse-<?=$this->escapeHtmlAttr($title) ?>" class="collapse<? if(!in_array($title, $collapsedFacets)): ?> in<? endif ?>">
<? if (isset($rangeFacets[$title])): ?> <? if (isset($rangeFacets[$title])): ?>
<div class="list-group-item"> <?=$this->context($this)->renderInContext('Recommend/SideFacets/range-slider.phtml', ['title' => $title, 'facet' => $rangeFacets[$title]]); ?>
<form name="<?=$this->escapeHtmlAttr($title)?>Filter" id="<?=$this->escapeHtmlAttr($title)?>Filter">
<?=$results->getUrlQuery()->asHiddenFields(['page' => "/./", 'filter' => "/^{$title}:.*/"])?>
<input type="hidden" name="<?=$this->escapeHtmlAttr($rangeFacets[$title]['type'])?>range[]" value="<?=$this->escapeHtmlAttr($title)?>"/>
<div class="row">
<? $extraInputAttribs = ($rangeFacets[$title]['type'] == 'date') ? 'maxlength="4" ' : ''; ?>
<div class="col-sm-6">
<label for="<?=$this->escapeHtmlAttr($title)?>from">
<?=$this->transEsc('date_from')?>:
</label>
<input type="text" class="form-control" name="<?=$this->escapeHtmlAttr($title)?>from" id="<?=$this->escapeHtmlAttr($title)?>from" value="<?=isset($rangeFacets[$title]['values'][0])?$this->escapeHtmlAttr($rangeFacets[$title]['values'][0]):''?>" <?=$extraInputAttribs?>/>
</div>
<div class="col-sm-6">
<label for="<?=$this->escapeHtmlAttr($title)?>to">
<?=$this->transEsc('date_to')?>:
</label>
<input type="text" class="form-control" name="<?=$this->escapeHtmlAttr($title)?>to" id="<?=$this->escapeHtmlAttr($title)?>to" value="<?=isset($rangeFacets[$title]['values'][1])?$this->escapeHtmlAttr($rangeFacets[$title]['values'][1]):''?>" <?=$extraInputAttribs?>/>
</div>
</div>
<? if ($rangeFacets[$title]['type'] == 'date'): ?>
<div class="slider-container"><input type="text" class="hidden" id="<?=$this->escapeHtmlAttr($title)?><?=$this->escapeHtml($rangeFacets[$title]['type'])?>Slider"/></div>
<? endif; ?>
<input class="btn btn-default" type="submit" value="<?=$this->transEsc('Set')?>"/>
</form>
</div>
<? if ($rangeFacets[$title]['type'] == 'date'): ?>
<? $this->headScript()->appendFile('vendor/bootstrap-slider.min.js'); ?>
<? $this->headLink()->appendStylesheet('vendor/bootstrap-slider.min.css'); ?>
<?
$min = !empty($rangeFacets[$title]['values'][0]) ? min($rangeFacets[$title]['values'][0], 1400) : 1400;
$future = date('Y', time()+31536000);
$max = !empty($rangeFacets[$title]['values'][1]) ? max($future, $rangeFacets[$title]['values'][1]) : $future;
$low = !empty($rangeFacets[$title]['values'][0]) ? $rangeFacets[$title]['values'][0] : $min;
$high = !empty($rangeFacets[$title]['values'][1]) ? $rangeFacets[$title]['values'][1] : $max;
$reversed = $this->layout()->rtl ? 'true' : 'false';
$script = <<<JS
$(document).ready(function() {
var fillTexts = function() {
var v = {$this->escapeHtmlAttr($title)}dateSlider.getValue();
$('#{$this->escapeHtmlAttr($title)}from').val(v[0]);
$('#{$this->escapeHtmlAttr($title)}to').val(v[1]);
};
var {$this->escapeHtmlAttr($title)}dateSlider = $('#{$this->escapeHtmlAttr($title)}dateSlider')
.slider({
'min':{$min},
'max':{$max},
'handle':"square",
'tooltip':"hide",
'value':[{$low},{$high}],
'reversed': {$reversed}
})
.on('change', fillTexts)
.data('slider');
});
$('#{$this->escapeHtmlAttr($title)}from, #{$this->escapeHtmlAttr($title)}to').change(function () {
var fromValue = Number($('#{$this->escapeHtmlAttr($title)}from').val());
var toValue = Number($('#{$this->escapeHtmlAttr($title)}to').val());
$('#{$this->escapeHtmlAttr($title)}dateSlider').slider(
'setValue',
[
isNaN(fromValue) || fromValue <= 0 ? {$min} : fromValue,
isNaN(toValue) || toValue <= 0 ? {$max} : toValue
],
true
);
});
JS;
?>
<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?>
<? endif; ?>
<? else: ?> <? else: ?>
<? if (in_array($title, $hierarchicalFacets)): ?> <? if (in_array($title, $hierarchicalFacets)): ?>
<? $this->headScript()->appendFile('vendor/jsTree/jstree.min.js'); ?> <?=$this->context($this)->renderInContext('Recommend/SideFacets/hierarchical-facet.phtml', ['title' => $title, 'sortOptions' => $hierarchicalFacetSortOptions[$title]]); ?>
<? $sort = isset($hierarchicalFacetSortOptions[$title]) ? $hierarchicalFacetSortOptions[$title] : ''; ?>
<? if (!in_array($title, $collapsedFacets)): ?>
<?
$script = <<<JS
$(document).ready(function() {
initFacetTree($('#facet_{$this->escapeHtml($title)}'), true);
});
JS;
?>
<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?>
<? else: ?>
<?
$script = <<<JS
$('#side-collapse-{$this->escapeHtmlAttr($title)}').on('show.bs.collapse', function() {
initFacetTree($('#facet_{$this->escapeHtml($title)}'), true);
});
JS;
?>
<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?>
<? endif; ?>
<li id="facet_<?=$this->escapeHtml($title)?>" class="jstree-facet"
data-facet="<?=$this->escapeHtmlAttr($title)?>"
data-path="<?=$this->currentPath()?>"
data-exclude="<?=$allowExclude?>"
data-operator="<?=$this->recommend->getFacetOperator($title)?>"
data-exclude-title="<?=$this->transEsc('exclude_facet')?>"
data-sort="<?=isset($hierarchicalFacetSortOptions[$title]) ? $hierarchicalFacetSortOptions[$title] : ''?>">
</li>
<noscript> <noscript>
<? endif; ?> <? endif; ?>
<? foreach ($cluster['list'] as $i=>$thisFacet): ?> <? $contextVars = [
<? 'options' => $options,
if(strlen($thisFacet['displayText']) == 0) { 'allowExclude' => $this->recommend->excludeAllowed($title),
$thisFacet['displayText'] = "-"; 'facets_before_more' => $this->recommend->getShowMoreSetting($title),
} 'showMoreInLightbox' => $this->recommend->getShowInLightboxSetting($title)
?> ]; ?>
<? $moreClass = 'narrowGroupHidden-'.$this->escapeHtmlAttr($title).' hidden'; ?> <?=$this->context($this)->renderInContext('Recommend/SideFacets/cluster-list.phtml', array_merge($contextVars, ['title' => $title, 'cluster' => $cluster])); ?>
<? if ($i == $facets_before_more): ?> <? if (in_array($title, $hierarchicalFacets)): ?>
<? $idAndClass = 'id="more-narrowGroupHidden-'.$this->escapeHtmlAttr($title).'" class="list-group-item narrow-toggle"'; ?> </noscript>
<? if ($facetLightbox = $options->getFacetListAction()): ?>
<? $moreUrl = $this->url($facetLightbox) . $results->getUrlQuery()->getParams().'&amp;facet='.$title.'&amp;facetop='.$thisFacet['operator'].'&amp;facetexclude='.($allowExclude ? 1 : 0); ?>
<? else: ?>
<? $moreUrl = '#'; ?>
<? endif; ?>
<? if (($showMoreInLightbox && $showMoreInLightbox !== 'more') && $facetLightbox): ?>
<a <?=$idAndClass ?> data-lightbox href="<?=$moreUrl ?>" rel="nofollow"><?=$this->transEsc('more')?> ...</a>
<? break; ?>
<? else: ?>
<a <?=$idAndClass ?> href="<?=$moreUrl ?>" onclick="return moreFacets('narrowGroupHidden-<?=$this->escapeHtmlAttr($title) ?>')" rel="nofollow"><?=$this->transEsc('more')?> ...</a>
<? endif; ?>
<? endif; ?>
<? if ($thisFacet['isApplied']): ?>
<a class="list-group-item active<? if ($i >= $facets_before_more): ?><?=$moreClass ?><?endif ?><? if ($thisFacet['operator'] == 'OR'): ?> facetOR applied<? endif ?>" href="<?=$this->currentPath().$results->getUrlQuery()->removeFacet($title, $thisFacet['value'], $thisFacet['operator']) ?>" title="<?=$this->transEsc('applied_filter') ?>">
<? if ($thisFacet['operator'] == 'OR'): ?>
<i class="fa fa-check-square-o" aria-hidden="true"></i>
<? else: ?>
<span class="pull-right flip"><i class="fa fa-check" aria-hidden="true"></i></span>
<? endif; ?>
<?=$this->escapeHtml($thisFacet['displayText'])?>
</a>
<? else: ?>
<? $addURL = $this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], $thisFacet['operator']); ?>
<? if ($allowExclude): ?>
<div class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i >= $facets_before_more): ?> <?=$moreClass ?><?endif ?>">
<? else: ?>
<a href="<?=$addURL ?>" class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i >= $facets_before_more): ?> <?=$moreClass ?><?endif ?>">
<? endif; ?>
<span class="badge">
<?=$this->localizedNumber($thisFacet['count'])?>
<? if ($allowExclude): ?>
<a href="<?=$this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], 'NOT') ?>" title="<?=$this->transEsc('exclude_facet') ?>"><i class="fa fa-times" aria-hidden="true"></i></a>
<? endif; ?>
</span>
<? if ($allowExclude): ?>
<a href="<?=$addURL ?>">
<? endif; ?>
<? if($thisFacet['operator'] == 'OR'): ?>
<i class="fa fa-square-o" aria-hidden="true"></i>
<? endif; ?>
<?=$this->escapeHtml($thisFacet['displayText'])?>
<? if ($allowExclude): ?>
</a>
</div>
<? else: ?>
</a>
<? endif; ?>
<? endif; ?>
<? endforeach; ?>
<? if ($showMoreInLightbox === 'more' && $facetLightbox = $options->getFacetListAction()): ?>
<? $moreUrl = $this->url($facetLightbox) . $results->getUrlQuery()->getParams().'&amp;facet='.$title.'&amp;facetop='.$thisFacet['operator'].'&amp;facetexclude='.($allowExclude ? 1 : 0); ?>
<a class="list-group-item narrow-toggle <?=$moreClass ?>" data-lightbox href="<?=$moreUrl ?>" rel="nofollow"><?=$this->transEsc('see all')?> ...</a>
<? endif; ?> <? endif; ?>
<? if ($i >= $facets_before_more): ?><a class="list-group-item narrow-toggle <?=$moreClass ?>" href="#" onclick="return lessFacets('narrowGroupHidden-<?=$this->escapeHtmlAttr($title) ?>')"><?=$this->transEsc('less')?> ...</a><? endif; ?>
<? endif; ?>
<? if (in_array($title, $hierarchicalFacets)): ?>
</noscript>
<? endif; ?> <? endif; ?>
</div> </div>
</div> </div>
......
<? foreach ($checkboxFilters as $current): ?>
<label class="checkbox<? if(!($results->getResultTotal() > 0 || $current['selected'] || $current['alwaysVisible'])): ?> hidden<? endif; ?>">
<input type="checkbox" name="filter[]"
value="<?=$this->escapeHtmlAttr($current['filter']) ?>"
<?=$current['selected'] ? ' checked="checked"' : '' ?>
id="<?=$this->escapeHtmlAttr(str_replace(' ', '', $current['desc'])) ?>"
onclick="document.location.href='<?=$current['selected'] ? $results->getUrlQuery()->removeFilter($current['filter']) : $results->getUrlQuery()->addFilter($current['filter']);?>'" />
<?=$this->transEsc($current['desc']) ?>
</label>
<?
endforeach;
?>
<? $idAndClass = 'id="more-narrowGroupHidden-'.$this->escapeHtmlAttr($this->title).'" class="list-group-item narrow-toggle"'; ?>
<? $moreClass = 'narrowGroupHidden-'.$this->escapeHtmlAttr($this->title).' hidden'; ?>
<? foreach ($this->cluster['list'] as $i => $thisFacet): ?>
<?
if(empty($thisFacet['displayText'])) {
$thisFacet['displayText'] = "-";
}
?>
<? if ($i == $this->facets_before_more): ?>
<? if ($facetLightbox = $this->options->getFacetListAction()): ?>
<? $moreUrl = $this->url($facetLightbox) . $results->getUrlQuery()->getParams() . '&amp;facet=' . $this->title . '&amp;facetop=' . $thisFacet['operator'] . '&amp;facetexclude=' . ($this->allowExclude ? 1 : 0); ?>
<? else: ?>
<? $moreUrl = '#'; ?>
<? endif; ?>
<? if (($this->showMoreInLightbox && $this->showMoreInLightbox !== 'more') && $facetLightbox): ?>
<a <?=$idAndClass ?> data-lightbox href="<?=$moreUrl ?>" rel="nofollow"><?=$this->transEsc('more')?> ...</a>
<? break; ?>
<? else: ?>
<a <?=$idAndClass ?> href="<?=$moreUrl ?>" onclick="return moreFacets('narrowGroupHidden-<?=$this->escapeHtmlAttr($this->title) ?>')" rel="nofollow"><?=$this->transEsc('more')?> ...</a>
<? endif; ?>
<? endif; ?>
<? if ($thisFacet['isApplied']): ?>
<a class="list-group-item active<? if ($i >= $this->facets_before_more): ?><?=$moreClass ?><?endif ?><? if ($thisFacet['operator'] == 'OR'): ?> facetOR applied<? endif ?>" href="<?=$this->currentPath().$results->getUrlQuery()->removeFacet($this->title, $thisFacet['value'], $thisFacet['operator']) ?>" title="<?=$this->transEsc('applied_filter') ?>">
<? if ($thisFacet['operator'] == 'OR'): ?>
<i class="fa fa-check-square-o" aria-hidden="true"></i>
<? else: ?>
<span class="pull-right flip"><i class="fa fa-check" aria-hidden="true"></i></span>
<? endif; ?>
<?=$this->escapeHtml($thisFacet['displayText'])?>
</a>
<? else: ?>
<? $addURL = $this->currentPath().$results->getUrlQuery()->addFacet($this->title, $thisFacet['value'], $thisFacet['operator']); ?>
<? if ($this->allowExclude): ?>
<div class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i >= $this->facets_before_more): ?> <?=$moreClass ?><?endif ?>">
<? else: ?>
<a href="<?=$addURL ?>" class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i >= $this->facets_before_more): ?> <?=$moreClass ?><?endif ?>">
<? endif; ?>
<span class="badge">
<?=$this->localizedNumber($thisFacet['count'])?>
<? if ($this->allowExclude): ?>
<a href="<?=$this->currentPath().$results->getUrlQuery()->addFacet($this->title, $thisFacet['value'], 'NOT') ?>" title="<?=$this->transEsc('exclude_facet') ?>"><i class="fa fa-times" aria-hidden="true"></i></a>
<? endif; ?>
</span>
<? if ($this->allowExclude): ?>
<a href="<?=$addURL ?>">
<? endif; ?>
<? if($thisFacet['operator'] == 'OR'): ?>
<i class="fa fa-square-o" aria-hidden="true"></i>
<? endif; ?>
<?=$this->escapeHtml($thisFacet['displayText'])?>
<? if ($this->allowExclude): ?>
</a>
</div>
<? else: ?>
</a>
<? endif; ?>
<? endif; ?>
<? endforeach; ?>
<? if ($this->showMoreInLightbox === 'more' && $facetLightbox = $options->getFacetListAction()): ?>
<? $moreUrl = $this->url($facetLightbox) . $results->getUrlQuery()->getParams().'&amp;facet='.$this->title.'&amp;facetop='.$thisFacet['operator'].'&amp;facetexclude='.($this->allowExclude ? 1 : 0); ?>
<a class="list-group-item narrow-toggle <?=$moreClass ?>" data-lightbox href="<?=$moreUrl ?>" rel="nofollow"><?=$this->transEsc('see all')?> ...</a>
<? endif; ?>
<? if ($i >= $this->facets_before_more): ?><a class="list-group-item narrow-toggle <?=$moreClass ?>" href="#" onclick="return lessFacets('narrowGroupHidden-<?=$this->escapeHtmlAttr($this->title) ?>')"><?=$this->transEsc('less')?> ...</a><? endif; ?>
<div class="list-group filters">
<div class="list-group-item title"><?=$this->transEsc('Remove Filters')?></div>
<? foreach ($filterList as $field => $filters): ?>
<? foreach ($filters as $i => $filter): ?>
<?
$index = isset($filter['field']) ? array_search($filter['field'], $collapsedFacets) : false;
if ($index !== false) {
unset($collapsedFacets[$index]); // Open if we have a match
}
if (isset($filter['specialType']) && $filter['specialType'] == 'keyword') {
$removeLink = $this->currentPath() . $results->getUrlQuery()->replaceTerm($filter['value'], '');
} else {
$removeLink = $this->currentPath() . $results->getUrlQuery()->removeFacet($filter['field'], $filter['value'], $filter['operator']);
}
if ($filter['displayText'] == '[* TO *]') {
$filter['displayText'] = $this->translate('filter_wildcard');
}
?>
<a class="list-group-item active" href="<?=$removeLink ?>" title="<?=$this->transEsc('clear_tag_filter') ?>">
<span class="pull-right flip"><i class="fa fa-times" aria-hidden="true"></i></span>
<? if ($filter['operator'] == 'NOT'): ?><?=$this->transEsc('NOT') ?><? endif; ?>
<? if ($filter['operator'] == 'OR' && $i > 0): ?><?=$this->transEsc('OR') ?><? endif; ?>
<?=$this->transEsc($field) ?>: <?=$this->escapeHtml($filter['displayText']) ?>
</a>
<? endforeach; ?>
<? endforeach; ?>
</div>
<? $this->headScript()->appendFile('vendor/jsTree/jstree.min.js'); ?>
<? if (!in_array($this->title, $collapsedFacets)): ?>
<?
$script = <<<JS
$(document).ready(function() {
initFacetTree($('#facet_{$this->escapeHtml($this->title)}'), true);
});
JS;
?>
<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?>
<? else: ?>
<?
$script = <<<JS
$('#side-collapse-{$this->escapeHtmlAttr($this->title)}').on('show.bs.collapse', function() {
initFacetTree($('#facet_{$this->escapeHtml($this->title)}'), true);
});
JS;
?>
<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?>
<? endif; ?>
<li id="facet_<?=$this->escapeHtml($this->title)?>" class="jstree-facet"
data-facet="<?=$this->escapeHtmlAttr($this->title)?>"
data-path="<?=$this->currentPath()?>"
data-exclude="<?=$allowExclude?>"
data-operator="<?=$this->recommend->getFacetOperator($this->title)?>"
data-exclude-title="<?=$this->transEsc('exclude_facet')?>"
data-sort="<?=isset($this->sortOptions) ? $this->sortOptions : ''?>">
</li>
<div class="list-group-item">
<form name="<?=$this->escapeHtmlAttr($this->title)?>Filter" id="<?=$this->escapeHtmlAttr($this->title)?>Filter">
<?=$results->getUrlQuery()->asHiddenFields(['page' => "/./", 'filter' => "/^{$this->title}:.*/"])?>
<input type="hidden" name="<?=$this->escapeHtmlAttr($this->facet['type'])?>range[]" value="<?=$this->escapeHtmlAttr($this->title)?>"/>
<div class="row">
<? $extraInputAttribs = ($this->facet['type'] == 'date') ? 'maxlength="4" ' : ''; ?>
<div class="col-sm-6">
<label for="<?=$this->escapeHtmlAttr($this->title)?>from">
<?=$this->transEsc('date_from')?>:
</label>
<input type="text" class="form-control" name="<?=$this->escapeHtmlAttr($this->title)?>from" id="<?=$this->escapeHtmlAttr($this->title)?>from" value="<?=isset($this->facet['values'][0])?$this->escapeHtmlAttr($this->facet['values'][0]):''?>" <?=$extraInputAttribs?>/>
</div>
<div class="col-sm-6">
<label for="<?=$this->escapeHtmlAttr($this->title)?>to">
<?=$this->transEsc('date_to')?>:
</label>
<input type="text" class="form-control" name="<?=$this->escapeHtmlAttr($this->title)?>to" id="<?=$this->escapeHtmlAttr($this->title)?>to" value="<?=isset($this->facet['values'][1])?$this->escapeHtmlAttr($this->facet['values'][1]):''?>" <?=$extraInputAttribs?>/>
</div>
</div>
<? if ($this->facet['type'] == 'date'): ?>
<div class="slider-container"><input type="text" class="hidden" id="<?=$this->escapeHtmlAttr($this->title)?><?=$this->escapeHtml($this->facet['type'])?>Slider"/></div>
<? endif; ?>
<input class="btn btn-default" type="submit" value="<?=$this->transEsc('Set')?>"/>
</form>
</div>
<? if ($this->facet['type'] == 'date'): ?>
<? $this->headScript()->appendFile('vendor/bootstrap-slider.min.js'); ?>
<? $this->headLink()->appendStylesheet('vendor/bootstrap-slider.min.css'); ?>
<?
$min = !empty($this->facet['values'][0]) ? min($this->facet['values'][0], 1400) : 1400;
$future = date('Y', time()+31536000); // next year
$max = !empty($this->facet['values'][1]) ? max($future, $this->facet['values'][1]) : $future;
$low = !empty($this->facet['values'][0]) ? $this->facet['values'][0] : $min;
$high = !empty($this->facet['values'][1]) ? $this->facet['values'][1] : $max;
$reversed = $this->layout()->rtl ? 'true' : 'false';
$script = <<<JS
$(document).ready(function() {
var fillTexts = function() {
var v = {$this->escapeHtmlAttr($this->title)}dateSlider.getValue();
$('#{$this->escapeHtmlAttr($this->title)}from').val(v[0]);
$('#{$this->escapeHtmlAttr($this->title)}to').val(v[1]);
};
var {$this->escapeHtmlAttr($this->title)}dateSlider = $('#{$this->escapeHtmlAttr($this->title)}dateSlider')
.slider({
'min':{$min},
'max':{$max},
'handle':"square",
'tooltip':"hide",
'value':[{$low},{$high}],
'reversed': {$reversed}
})
.on('change', fillTexts)
.data('slider');
});
$('#{$this->escapeHtmlAttr($this->title)}from, #{$this->escapeHtmlAttr($this->title)}to').change(function () {
var fromValue = Number($('#{$this->escapeHtmlAttr($this->title)}from').val());
var toValue = Number($('#{$this->escapeHtmlAttr($this->title)}to').val());
$('#{$this->escapeHtmlAttr($this->title)}dateSlider').slider(
'setValue',
[
isNaN(fromValue) || fromValue <= 0 ? {$min} : fromValue,
isNaN(toValue) || toValue <= 0 ? {$max} : toValue
],
true
);
});
JS;
?>
<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?>
<? endif; ?>
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