From bc70af210d56e41a38c5b39f3d07f5ecd1e80ac9 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 10 Oct 2023 10:33:26 +0200 Subject: [PATCH] add fulltext search for attribute=__any__ --- views/bootstrap/class.Search.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index 45fb21d48..f512f55a0 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -1017,7 +1017,7 @@ $(document).ready(function() { default: $option = array($v, $v); } - if(isset($attributes[$facetname]) && in_array($v, $attributes[$facetname])) + if(isset($attributes[$facetname]) && is_array($attributes[$facetname]) && in_array($v, $attributes[$facetname])) $option[] = true; else $option[] = false; @@ -1125,11 +1125,13 @@ $(document).ready(function() { } else { $oldvalue = [$allparams['attributes'][$facetname]]; } - unset($allparams['attributes'][$facetname]); - $newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams); - $menuitems[] = array('label'=>' '.$dispname.' = '.implode(', ', $oldvalue), 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); - foreach($oldvalue as $ov) - echo ''; + if($oldvalue) { + unset($allparams['attributes'][$facetname]); + $newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams); + $menuitems[] = array('label'=>' '.$dispname.' = '.implode(', ', $oldvalue), 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); + foreach($oldvalue as $ov) + echo ''; + } } } } @@ -1201,14 +1203,14 @@ $(document).ready(function() { $allparams = $request->query->all(); if(isset($allparams['attributes'])) { foreach($allparams['attributes'] as $an=>$av) { - if(is_string($av) && $av == '__notset__') { + if(is_string($av) && ($av == '__notset__')) { $tmp = explode('_', $an); if($attrdef = $dms->getAttributeDefinition($tmp[1])) { $dispname = $attrdef->getName(); unset($allparams['attributes'][$an]); $newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams); $menuitems[] = array('label'=>' '.$dispname.' is not set', 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); - echo ''; + echo ''; } } } @@ -1275,6 +1277,7 @@ $(document).ready(function() { if($values && (count($values) > 1 || reset($values) < $total)) { $menuitems = array(); $menuitems[] = array('label'=>getMLText('no_value_set'), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.']=__notset__'); + $menuitems[] = array('label'=>getMLText('any_value_set'), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.']=__any__'); arsort($values); foreach($values as $v=>$c) { switch($attrdef->getType()) {