diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index caba24433..b4c66001f 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -1051,8 +1051,6 @@ $(document).ready(function() { $this->formField(getMLText("under_folder"), $this->getFolderChooserHtml("form3", M_READ, -1, $startfolder, 'folderfullsearchid')); $this->contentContainerEnd(); - $this->formSubmit(" ".getMLText('search')); - echo "

"; if($facets) { $menuitems = []; @@ -1064,10 +1062,22 @@ $(document).ready(function() { /* Create a link to remove the filter */ $allparams = $request->query->all(); if(isset($allparams['attributes'][$facetname])) { - $oldvalue = is_array($allparams['attributes'][$facetname]) ? implode(',', $allparams['attributes'][$facetname]) : $allparams['attributes'][$facetname]; - unset($allparams['attributes'][$facetname]); - $newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams); - $menuitems[] = array('label'=>$dispname.' = '.$oldvalue, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); + if(isset($allparams['attributes'][$facetname]['to']) && isset($allparams['attributes'][$facetname]['from'])) { + $oldvalue = $allparams['attributes'][$facetname]; + if(!empty($oldvalue['from']) || !empty($oldvalue['to'])) { + unset($allparams['attributes'][$facetname]); + $newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams); + $menuitems[] = array('label'=>' '.$dispname.' = '.$oldvalue['from'].' TO '.$oldvalue['to'], 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); + echo ''; + echo ''; + } + } else { + $oldvalue = is_array($allparams['attributes'][$facetname]) ? implode(',', $allparams['attributes'][$facetname]) : $allparams['attributes'][$facetname]; + unset($allparams['attributes'][$facetname]); + $newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams); + $menuitems[] = array('label'=>' '.$dispname.' = '.$oldvalue, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); + echo ''; + } } } } else { @@ -1077,46 +1087,76 @@ $(document).ready(function() { $oldvalue = is_array($allparams[$facetname]) ? implode(',', $allparams[$facetname]) : $allparams[$facetname]; unset($allparams[$facetname]); $newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams); - $menuitems[] = array('label'=>getMLText($facetname).' = '.$oldvalue, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); + $menuitems[] = array('label'=>' '.getMLText($facetname).' = '.$oldvalue, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x'); + echo ''; } } } if($menuitems) { - ob_start(); +// ob_start(); self::showNavigationListWithBadges($menuitems); - $content = ob_get_clean(); - $this->printAccordion(getMLText('current_filter'), $content, true); +// $content = ob_get_clean(); +// $this->printAccordion(getMLText('current_filter'), $content, true); } - + } + echo "

"; + $this->formSubmit(" ".getMLText('search')); + echo "

"; + if($facets) { + $allparams = $request->query->all(); + if(!isset($allparams['fullsearch'])) + $allparams['fullsearch'] = 1; + if(!isset($allparams['facetsearch'])) + $allparams['facetsearch'] = 1; + $newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams); foreach($facets as $facetname=>$values) { if(substr($facetname, 0, 5) == 'attr_') { $tmp = explode('_', $facetname); if($attrdef = $dms->getAttributeDefinition($tmp[1])) { $dispname = $attrdef->getName(); - /* See below on an explaination for the if statement */ - if($values && (count($values) > 1 || reset($values) < $total)) { - $menuitems = array(); - arsort($values); - foreach($values as $v=>$c) { - $menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$request->getRequestUri().'&attributes['.$facetname.'][]='.urlencode($v), 'badge'=>$c, 'attributes'=>array(array('data-href', $request->getRequestUri().'&'.$facetname.'='.$v), array('data-action', "printOpenTasksList"))); + switch($attrdef->getType()) { + case SeedDMS_Core_AttributeDefinition::type_int: + /* See below on an explaination for the if statement */ + if($values && (count($values) > 1 || reset($values) < $total)) { + if(empty($allparams['attributes'][$facetname]['from']) && empty($allparams['attributes'][$facetname]['to'])) { + $tt = array_keys($values); + $content = '
'; + $content .= ' from '; + $content .= ''; + $content .= ' to '; + $content .= ''; + $content .= ''; + $content .= '
'; + $this->printAccordion($dispname, $content); + } + } + break; + default: + /* See below on an explaination for the if statement */ + if($values && (count($values) > 1 || reset($values) < $total)) { + $menuitems = array(); + arsort($values); + foreach($values as $v=>$c) { + $menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.'][]='.urlencode($v), 'badge'=>$c); + } + ob_start(); + self::showNavigationListWithBadges($menuitems); + $content = ob_get_clean(); + $this->printAccordion($dispname, $content); } - ob_start(); - self::showNavigationListWithBadges($menuitems); - $content = ob_get_clean(); - $this->printAccordion($dispname, $content); } } } else { - /* Further filter makes onle sense if the facet has mor than 1 value - * or in case of 1 value that value has a count < $total. That second - * case will reduce the result set on those objects which the field + /* Further filter makes only sense if the facet has more than 1 value + * or in case of 1 value, if that value has a count < $total. That second + * case will reduce the result set on those objects which have the field * actually set. */ if($values && (count($values) > 1 || reset($values) < $total)) { $menuitems = array(); arsort($values); foreach($values as $v=>$c) { - $menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$request->getRequestUri().'&'.$facetname.'[]='.urlencode($v), 'badge'=>$c, 'attributes'=>array(array('data-href', "#initlist"), array('data-action', "printOpenTasksList"))); + $menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$newrequest->getRequestUri().'&'.$facetname.'[]='.urlencode($v), 'badge'=>$c); } ob_start(); self::showNavigationListWithBadges($menuitems);