From 5b05cb3d4391b5df31c24d832953ae5e9144e801 Mon Sep 17 00:00:00 2001 From: "kazzer@ub.uni-leipzig.de" <kazzer@ub.uni-leipzig.de> Date: Fri, 21 Aug 2020 16:40:09 +0200 Subject: [PATCH] refs #18209 [finc: BARF] adds missing labels in finc * adds missing labels in finc --- .../templates/search/advanced/layout.phtml | 2 +- .../templates/search/advanced/limit.phtml | 21 +++++ .../templates/search/advanced/ranges.phtml | 76 +++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 themes/finc/templates/search/advanced/limit.phtml create mode 100644 themes/finc/templates/search/advanced/ranges.phtml diff --git a/themes/finc/templates/search/advanced/layout.phtml b/themes/finc/templates/search/advanced/layout.phtml index a7f4c048d40..a2b6a6e2f41 100644 --- a/themes/finc/templates/search/advanced/layout.phtml +++ b/themes/finc/templates/search/advanced/layout.phtml @@ -128,7 +128,7 @@ if (isset($searchDetails) && is_object($searchDetails)) { <?php endfor; ?> </div> <div class="adv-group-match"> - <label class="search_bool"><?=$this->transEsc("search_match")?>: </label> + <label class="search_bool" for="search_bool<?=$group ?>"><?=$this->transEsc("search_match")?>: </label> <select name="bool<?=$group ?>[]" id="search_bool<?=$group ?>" class="form-control"> <option value="AND"<?php if(isset($setSearchGroups[$group]) && 'AND' == $setSearchGroups[$group]):?> selected<?php endif;?>><?=$this->transEsc("search_AND")?></option> <option value="OR"<?php if(isset($setSearchGroups[$group]) && 'OR' == $setSearchGroups[$group]):?> selected<?php endif;?>><?=$this->transEsc("search_OR")?></option> diff --git a/themes/finc/templates/search/advanced/limit.phtml b/themes/finc/templates/search/advanced/limit.phtml new file mode 100644 index 00000000000..3a48c286d3f --- /dev/null +++ b/themes/finc/templates/search/advanced/limit.phtml @@ -0,0 +1,21 @@ +<!-- finc: search - advanced - limit --> +<?php + // Set up convenience variables: + $limitList = $this->options->getLimitOptions(); + + // If a previous limit was used, make that the default; otherwise, use the "default default" + $lastLimit = $this->searchMemory()->getLastLimit($this->options->getSearchClassId()); + $defaultLimit = empty($lastLimit) ? $this->options->getDefaultLimit() : $lastLimit; +?> +<?php if (count($limitList) > 1): ?> + <fieldset class="limits"> + <legend><?=$this->transEsc('Results per page')?></legend> + <select id="limit" name="limit" class="form-control"> + <?php foreach ($limitList as $limitVal): ?> + <option value="<?=$this->escapeHtmlAttr($limitVal)?>" <?=($limitVal == $defaultLimit) ? 'selected="selected"' : ''?>><?=$this->escapeHtml($limitVal)?></option> + <?php endforeach; ?> + </select> + <label for="limit"><?=$this->transEsc('Limit To')?></label> + </fieldset> +<?php endif; ?> +<!-- finc: search - advanced - limit - END --> \ No newline at end of file diff --git a/themes/finc/templates/search/advanced/ranges.phtml b/themes/finc/templates/search/advanced/ranges.phtml new file mode 100644 index 00000000000..d0fc25eb2ed --- /dev/null +++ b/themes/finc/templates/search/advanced/ranges.phtml @@ -0,0 +1,76 @@ +<!-- finc: search - advanced - ranges --> +<?php if (isset($this->ranges) && !empty($this->ranges)): ?> + <?php $params = $this->searchParams($this->searchClassId); $params->activateAllFacets(); ?> + <?php foreach ($this->ranges as $current): $escField = $this->escapeHtmlAttr($current['field']); ?> + <?php $extraInputAttribs = ($current['type'] == 'date') ? 'maxlength="4" ' : ''; ?> + <fieldset class="range"> + <legend><?=$this->transEsc($params->getFacetLabel($current['field']))?></legend> + <input type="hidden" name="<?=$this->escapeHtmlAttr($current['type'])?>range[]" value="<?=$escField?>"/> + <div class="date-fields"> + <div class="date-from"> + <label for="<?=$escField?>from"><?=$this->transEsc('date_from')?>:</label> + <input type="text" name="<?=$escField?>from" id="<?=$escField?>from" value="<?=isset($current['values'][0])?$this->escapeHtmlAttr($current['values'][0]):''?>" class="form-control" <?=$extraInputAttribs?>/> + </div> + <div class="date-to"> + <label for="<?=$escField?>to"><?=$this->transEsc('date_to')?>:</label> + <input type="text" name="<?=$escField?>to" id="<?=$escField?>to" value="<?=isset($current['values'][1])?$this->escapeHtmlAttr($current['values'][1]):''?>" class="form-control" <?=$extraInputAttribs?>/> + </div> + </div> + <?php if ($current['type'] == 'date'): ?> + <div class="slider-container"> + <label for="<?=$escField?><?=$this->escapeHtmlAttr($current['type'])?>Slider"><?=$this->transEsc('Range-from-to')?>:</label> + <input type="text" id="<?=$escField?><?=$this->escapeHtmlAttr($current['type'])?>Slider"> + </div> + <?php + $this->headScript()->appendFile('vendor/bootstrap-slider.min.js'); + $this->headLink()->appendStylesheet('vendor/bootstrap-slider.min.css'); + $min = !empty($current['values'][0]) ? min($current['values'][0], 1400) : 1400; + $future = date('Y', time() + 31536000); + $max = !empty($current['values'][1]) ? max($future, $current['values'][1]) : $future; + $low = !empty($current['values'][0]) ? $current['values'][0] : $min; + $high = !empty($current['values'][1]) ? $current['values'][1] : $max; + $min = intval($min); + $max = intval($max); + $low = intval($low); + $high = intval($high); + $init = !empty($current['values'][0]) ? 'fillTexts()' : ''; + $script = <<<JS +$(document).ready(function() { + var fillTexts = function() { + var v = {$escField}dateSlider.getValue(); + $('#${escField}from').val(v[0]); + $('#${escField}to').val(v[1]); + }; + var {$escField}dateSlider = $('#{$escField}dateSlider') + .slider({ + 'min':{$min}, + 'max':{$max}, + 'handle':"square", + 'tooltip':"hide", + 'value':[{$low},{$high}] + }) + .on('change', fillTexts) + .data('slider'); + {$init} +}); + +$('#{$escField}from, #{$escField}to').change(function () { + var fromValue = Number($('#{$escField}from').val()); + var toValue = Number($('#{$escField}to').val()); + $('#{$escField}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'); ?> + <?php endif; ?> + </fieldset> + <?php endforeach; ?> +<?php endif; ?> +<!-- finc: search - advanced - ranges - END --> \ No newline at end of file -- GitLab