From 742929002b9dcc3d3bdf41ab4c96b9e25b646576 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 6 Mar 2023 10:03:28 +0100 Subject: [PATCH] show number of occurances in subtitle of options --- views/bootstrap/class.Search.php | 37 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index d2da9d06d..5fd7ded68 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -854,9 +854,12 @@ function typeahead() { /* {{{ */ foreach($values as $v=>$c) { $uu = $dms->getUserByLogin($v); if($uu) { - $option = array($uu->getId(), $v.' ('.$c.')'); + $option = array($uu->getId(), $v/*.' ('.$c.')'*/); if(isset(${$facetname}) && in_array($uu->getId(), ${$facetname})) $option[] = true; + else + $option[] = false; + $option[] = array(array('data-subtitle', $c.' ×')); $options[] = $option; } } @@ -864,35 +867,48 @@ function typeahead() { /* {{{ */ foreach($values as $v=>$c) { $cat = $dms->getDocumentCategoryByName($v); if($cat) { - $option = array($cat->getId(), $v.' ('.$c.')'); + $option = array($cat->getId(), $v/*.' ('.$c.')'*/); if(isset(${$facetname}) && in_array($cat->getId(), ${$facetname})) $option[] = true; + else + $option[] = false; + $option[] = array(array('data-subtitle', $c.' ×')); $options[] = $option; } } } elseif($facetname == 'status') { foreach($values as $v=>$c) { - $option = array($v, getOverallStatusText($v).' ('.$c.')'); - if(isset(${$facetname}) && in_array($v, ${$facetname})) - $option[] = true; - $options[] = $option; + $option = array($v, getOverallStatusText($v)/*.' ('.$c.')'*/); + if(isset(${$facetname}) && in_array($v, ${$facetname})) + $option[] = true; + else + $option[] = false; + $option[] = array(array('data-subtitle', $c.' ×')); + $options[] = $option; } } elseif(substr($facetname, 0, 5) == 'attr_') { foreach($values as $v=>$c) { - $option = array($v, $v.' ('.$c.')'); - if(isset($attributes[$facetname]) && in_array($v, $attributes[$facetname])) - $option[] = true; - $options[] = $option; + $option = array($v, $v/*.' ('.$c.')'*/); + if(isset($attributes[$facetname]) && in_array($v, $attributes[$facetname])) + $option[] = true; + else + $option[] = false; + $option[] = array(array('data-subtitle', $c.' ×')); + $options[] = $option; } } else { foreach($values as $v=>$c) { $option = array($v, $v.' ('.$c.')'); if(isset(${$facetname}) && in_array($v, ${$facetname})) $option[] = true; + else + $option[] = false; + $option[] = array(array('data-subtitle', $c.' ×')); $options[] = $option; } } if(substr($facetname, 0, 5) == 'attr_') { + if($options) { $tmp = explode('_', $facetname); if($attrdef = $dms->getAttributeDefinition($tmp[1])) $dispname = $attrdef->getName(); @@ -910,6 +926,7 @@ function typeahead() { /* {{{ */ 'multiple'=>$multiple ) ); + } } else { $this->formField( getMLText($facetname),