mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-18 02:59:27 +00:00
parameters for search() can be an array, add support for sorting the output
This commit is contained in:
parent
e16a5dd46e
commit
3e4d90fe91
|
@ -1307,6 +1307,13 @@ class SeedDMS_Core_DMS {
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
function search($query, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=null, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x3, $expirationstartdate=array(), $expirationenddate=array()) { /* {{{ */
|
function search($query, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=null, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x3, $expirationstartdate=array(), $expirationenddate=array()) { /* {{{ */
|
||||||
|
if(is_array($query)) {
|
||||||
|
foreach(array('limit', 'offset', 'logicalmode', 'searchin', 'startFolder', 'owner', 'status', 'creationstartdate', 'creationenddate', 'modificationstartdate', 'modificationenddate', 'categories', 'attributes', 'mode', 'expirationstartdate', 'expirationenddate') as $paramname)
|
||||||
|
${$paramname} = isset($query[$paramname]) ? $query[$paramname] : ${$paramname};
|
||||||
|
foreach(array('orderby') as $paramname)
|
||||||
|
${$paramname} = isset($query[$paramname]) ? $query[$paramname] : '';
|
||||||
|
$query = isset($query['query']) ? $query['query'] : '';
|
||||||
|
}
|
||||||
// Split the search string into constituent keywords.
|
// Split the search string into constituent keywords.
|
||||||
$tkeys=array();
|
$tkeys=array();
|
||||||
if (strlen($query)>0) {
|
if (strlen($query)>0) {
|
||||||
|
@ -1436,7 +1443,22 @@ class SeedDMS_Core_DMS {
|
||||||
if($limit) {
|
if($limit) {
|
||||||
$searchQuery .= " LIMIT ".$limit." OFFSET ".$offset;
|
$searchQuery .= " LIMIT ".$limit." OFFSET ".$offset;
|
||||||
}
|
}
|
||||||
|
switch($orderby) {
|
||||||
|
case 'dd':
|
||||||
|
$searchQuery .= " ORDER BY `tblFolders`.`date` DESC";
|
||||||
|
break;
|
||||||
|
case 'da':
|
||||||
|
case 'd':
|
||||||
|
$searchQuery .= " ORDER BY `tblFolders`.`date`";
|
||||||
|
break;
|
||||||
|
case 'nd':
|
||||||
|
$searchQuery .= " ORDER BY `tblFolders`.`name` DESC";
|
||||||
|
break;
|
||||||
|
case 'na':
|
||||||
|
default:
|
||||||
$searchQuery .= " ORDER BY `tblFolders`.`name`";
|
$searchQuery .= " ORDER BY `tblFolders`.`name`";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Send the complete search query to the database.
|
// Send the complete search query to the database.
|
||||||
$resArr = $this->db->getResultArray($searchQuery);
|
$resArr = $this->db->getResultArray($searchQuery);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user