From facd9f7a657a4a497cdd8ed69ca2b4129665c89e Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 15 Dec 2023 17:13:28 +0100 Subject: [PATCH] use a stats array from fulltext search for min/max of facet value --- out/out.Search.php | 5 +++++ views/bootstrap/class.Search.php | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/out/out.Search.php b/out/out.Search.php index c56138c05..5b868bee2 100644 --- a/out/out.Search.php +++ b/out/out.Search.php @@ -356,10 +356,12 @@ if($fullsearch) { $totalPages = 0; $entries = array(); $facets = array(); + $stats = array(); $searchTime = 0; } else { $entries = array(); $facets = $searchresult['facets']; + $stats = $searchresult['stats'] ?? null; $dcount = 0; $fcount = 0; if($searchresult['hits']) { @@ -406,6 +408,7 @@ if($fullsearch) { $totalPages = 0; $entries = array(); $facets = array(); + $stats = array(); $searchTime = 0; } } @@ -680,6 +683,7 @@ if($fullsearch) { } else $totalPages = 1; $facets = array(); + $stats = array(); // }}} } @@ -700,6 +704,7 @@ if($settings->_showSingleSearchHit && count($entries) == 1) { $accessop = new SeedDMS_AccessOperation($dms, null, $user, $settings); if($view) { $view->setParam('facets', $facets); + $view->setParam('stats', $stats); $view->setParam('accessobject', $accessop); $view->setParam('query', $query); $view->setParam('includecontent', $includecontent); diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index 4713a907a..4cd15fa24 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -393,6 +393,7 @@ $(document).ready(function() { $orderby = $this->params['orderby']; $entries = $this->params['searchhits']; $facets = $this->params['facets']; + $stats = $this->params['stats']; $totalpages = $this->params['totalpages']; $pageNumber = $this->params['pagenumber']; $searchTime = $this->params['searchtime']; @@ -1221,14 +1222,14 @@ $(document).ready(function() { case SeedDMS_Core_AttributeDefinition::type_date: if($values && (count($values) > 1 || reset($values) < $total)) { if(empty($allparams['attributes'][$facetname]['from']) && empty($allparams['attributes'][$facetname]['to'])) { - $tt = array_keys($values); + $tt = isset($stats[$facetname]) ? $stats[$facetname] : [];//array_keys($values); $content = ''; $content .= '

'.getMLText('objects_without_attribute').'

'; $content .= '
'; $content .= ' from '; - $content .= $this->getDateChooser('', "attributes[".$facetname."][from]", $this->params['session']->getLanguage(), '', getReadableDate(min($tt)), getReadableDate(max($tt)), null, '', true); + $content .= $this->getDateChooser('', "attributes[".$facetname."][from]", $this->params['session']->getLanguage(), '', $tt ? getReadableDate($tt['min']) : null, $tt ? getReadableDate($tt['max']) : null, null, '', true); $content .= ' to '; - $content .= $this->getDateChooser('', "attributes[".$facetname."][to]", $this->params['session']->getLanguage(), '', getReadableDate(min($tt)), getReadableDate(max($tt)), null, '', true); + $content .= $this->getDateChooser('', "attributes[".$facetname."][to]", $this->params['session']->getLanguage(), '', $tt ? getReadableDate($tt['min']) : null, $tt ? getReadableDate($tt['max']) : null, null, '', true); $content .= ''; $content .= '
'; $this->printAccordion($dispname, $content);