diff --git a/out/out.Search.php b/out/out.Search.php index 99cdb822d..73af0259c 100644 --- a/out/out.Search.php +++ b/out/out.Search.php @@ -161,6 +161,11 @@ if($fullsearch) { else $record_type = array(); + if (isset($_GET["attributes"])) + $attributes = $_GET["attributes"]; + else + $attributes = array(); + // Check to see if the search has been restricted to a particular sub-tree in // the folder hierarchy. $startFolder = null; @@ -193,7 +198,7 @@ if($fullsearch) { if($index) { // $terms = $index->terms($_GET['query']); $lucenesearch = $fulltextservice->Search(); - $searchresult = $lucenesearch->search($query, array('record_type'=>$record_type, 'owner'=>$ownernames, 'status'=>$status, 'category'=>$categorynames, 'user'=>$user->isAdmin() ? [] : [$user->getLogin()], 'mimetype'=>$mimetype, 'startFolder'=>$startFolder, 'rootFolder'=>$rootFolder), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1)))); + $searchresult = $lucenesearch->search($query, array('record_type'=>$record_type, 'owner'=>$ownernames, 'status'=>$status, 'category'=>$categorynames, 'user'=>$user->isAdmin() ? [] : [$user->getLogin()], 'mimetype'=>$mimetype, 'startFolder'=>$startFolder, 'rootFolder'=>$rootFolder, 'attributes'=>$attributes), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1)))); if($searchresult === false) { $session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm'))); $dcount = 0; diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index 72e70b053..d2da9d06d 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -877,6 +877,13 @@ function typeahead() { /* {{{ */ $option[] = true; $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; + } } else { foreach($values as $v=>$c) { $option = array($v, $v.' ('.$c.')'); @@ -885,18 +892,38 @@ function typeahead() { /* {{{ */ $options[] = $option; } } - $this->formField( - getMLText($facetname), - array( - 'element'=>'select', - 'id'=>$facetname, - 'name'=>$facetname."[]", - 'class'=>'chzn-select', - 'attributes'=>array(array('data-placeholder', getMLText('select_'.$facetname)), array('data-allow-clear', 'true')), - 'options'=>$options, - 'multiple'=>$multiple - ) - ); + if(substr($facetname, 0, 5) == 'attr_') { + $tmp = explode('_', $facetname); + if($attrdef = $dms->getAttributeDefinition($tmp[1])) + $dispname = $attrdef->getName(); + else + $dispname = getMLText($facetname); + $this->formField( + $dispname, + array( + 'element'=>'select', + 'id'=>$facetname, + 'name'=>'attributes['.$facetname.'][]', + 'class'=>'chzn-select', + 'attributes'=>array(array('data-placeholder', $dispname), array('data-allow-clear', 'true')), + 'options'=>$options, + 'multiple'=>$multiple + ) + ); + } else { + $this->formField( + getMLText($facetname), + array( + 'element'=>'select', + 'id'=>$facetname, + 'name'=>$facetname."[]", + 'class'=>'chzn-select', + 'attributes'=>array(array('data-placeholder', getMLText('select_'.$facetname)), array('data-allow-clear', 'true')), + 'options'=>$options, + 'multiple'=>$multiple + ) + ); + } } } $this->contentContainerEnd();