mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-11 16:35:38 +00:00
allow sorting of fulltext search
This commit is contained in:
parent
244066d34d
commit
c8d6eafc71
|
@ -169,6 +169,13 @@ if(!empty($_GET["owner"])) {
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
if (isset($_GET["orderby"]) && is_string($_GET["orderby"])) {
|
||||
$orderby = $_GET["orderby"];
|
||||
}
|
||||
else {
|
||||
$orderby = "";
|
||||
}
|
||||
|
||||
$terms = [];
|
||||
$limit = (isset($_GET["limit"]) && is_numeric($_GET["limit"])) ? (int) $_GET['limit'] : 20;
|
||||
$fullsearch = ((!isset($_GET["fullsearch"]) && $settings->_defaultSearchMethod == 'fulltext') || !empty($_GET["fullsearch"])) && $settings->_enableFullSearch;
|
||||
|
@ -279,6 +286,31 @@ if($fullsearch) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Create $order array for fulltext search */
|
||||
$order = ['by'=>'', 'dir'=>''];
|
||||
switch($orderby) {
|
||||
case 'dd':
|
||||
$order = ['by'=>'created', 'dir'=>'desc'];
|
||||
break;
|
||||
case 'd':
|
||||
$order = ['by'=>'created', 'dir'=>'asc'];
|
||||
break;
|
||||
case 'nd':
|
||||
$order = ['by'=>'title', 'dir'=>'desc'];
|
||||
break;
|
||||
case 'n':
|
||||
$order = ['by'=>'title', 'dir'=>'asc'];
|
||||
break;
|
||||
case 'id':
|
||||
$order = ['by'=>'id', 'dir'=>'desc'];
|
||||
break;
|
||||
case 'i':
|
||||
$order = ['by'=>'id', 'dir'=>'asc'];
|
||||
break;
|
||||
default:
|
||||
$order = ['by'=>'', 'dir'=>''];
|
||||
}
|
||||
|
||||
//print_r($attributes);exit;
|
||||
// Check to see if the search has been restricted to a particular sub-tree in
|
||||
// the folder hierarchy.
|
||||
|
@ -316,7 +348,7 @@ if($fullsearch) {
|
|||
$terms = $index->terms($lastterm, $settings->_suggestTerms);
|
||||
}
|
||||
$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, 'created_start'=>$createstartts, 'created_end'=>$createendts, 'modified_start'=>$modifystartts, 'modified_end'=>$modifyendts, 'attributes'=>$attributes), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1))), ['by'=>'', 'dir'=>'desc']);
|
||||
$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, 'created_start'=>$createstartts, 'created_end'=>$createendts, 'modified_start'=>$modifystartts, 'modified_end'=>$modifyendts, 'attributes'=>$attributes), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1))), $order);
|
||||
if($searchresult === false) {
|
||||
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
|
||||
$dcount = 0;
|
||||
|
@ -387,13 +419,6 @@ if($fullsearch) {
|
|||
$query = "";
|
||||
}
|
||||
|
||||
if (isset($_GET["orderby"]) && is_string($_GET["orderby"])) {
|
||||
$orderby = $_GET["orderby"];
|
||||
}
|
||||
else {
|
||||
$orderby = "";
|
||||
}
|
||||
|
||||
/* Select if only documents (0x01), only folders (0x02) or both (0x03)
|
||||
* are found
|
||||
*/
|
||||
|
|
|
@ -780,10 +780,28 @@ $(document).ready(function() {
|
|||
'element'=>'input',
|
||||
'type'=>'search',
|
||||
'name'=>'query',
|
||||
'placeholder'=>getMLText('search_query_placeholder'),
|
||||
'value'=>htmlspecialchars($this->query)
|
||||
)
|
||||
);
|
||||
$this->formField(getMLText("under_folder"), $this->getFolderChooserHtml("form2", M_READ, -1, $startfolder, 'folderfullsearchid'));
|
||||
$options = array();
|
||||
$options[] = array('', getMLText('orderby_relevance'));
|
||||
$options[] = array('dd', getMLText('orderby_date_desc'), 'dd'==$orderby);
|
||||
$options[] = array('d', getMLText('orderby_date_asc'), 'd'==$orderby);
|
||||
$options[] = array('nd', getMLText('orderby_name_desc'), 'nd'==$orderby);
|
||||
$options[] = array('n', getMLText('orderby_name_asc'), 'n'==$orderby);
|
||||
$this->formField(
|
||||
getMLText("orderby"),
|
||||
array(
|
||||
'element'=>'select',
|
||||
'name'=>'orderby',
|
||||
'class'=>'chzn-select',
|
||||
'multiple'=>false,
|
||||
'options'=>$options
|
||||
)
|
||||
);
|
||||
|
||||
$this->formField(
|
||||
getMLText("creation_date")." (".getMLText('from').")",
|
||||
$this->getDateChooser(!empty($created['from']) ? getReadableDate($created['from']) : null, "created[from]", $this->params['session']->getLanguage())
|
||||
|
@ -1039,6 +1057,23 @@ $(document).ready(function() {
|
|||
);
|
||||
$this->formField(getMLText("under_folder"), $this->getFolderChooserHtml("form3", M_READ, -1, $startfolder, 'folderfullsearchid'));
|
||||
|
||||
$options = array();
|
||||
$options[] = array('', getMLText('orderby_relevance'));
|
||||
$options[] = array('dd', getMLText('orderby_date_desc'), 'dd'==$orderby);
|
||||
$options[] = array('d', getMLText('orderby_date_asc'), 'd'==$orderby);
|
||||
$options[] = array('nd', getMLText('orderby_name_desc'), 'nd'==$orderby);
|
||||
$options[] = array('n', getMLText('orderby_name_asc'), 'n'==$orderby);
|
||||
$this->formField(
|
||||
getMLText("orderby"),
|
||||
array(
|
||||
'element'=>'select',
|
||||
'name'=>'orderby',
|
||||
'class'=>'chzn-select',
|
||||
'multiple'=>false,
|
||||
'options'=>$options
|
||||
)
|
||||
);
|
||||
|
||||
$this->contentContainerEnd();
|
||||
|
||||
$menuitems = [];
|
||||
|
|
Loading…
Reference in New Issue
Block a user