- added new paramter $mode to search() to select if folders/documents shall

be search for
This commit is contained in:
steinm 2011-12-06 12:31:20 +00:00
parent 95c0a4deee
commit 61b2126aff

View File

@ -410,9 +410,14 @@ class LetoDMS_Core_DMS {
* @param status array list of status
* @param creationstartdate array search for documents created after this date
* @param creationenddate array search for documents created before this date
* @param categories array list of categories the documents must have assigned
* @param mode int decide whether to search for documents/folders
* 0x1 = documents only
* 0x2 = folders only
* 0x3 = both
* @return array containing the elements total and docs
*/
function search($query, $limit=0, $offset=0, $mode='AND', $searchin=array(), $startFolder=null, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $categories=array()) { /* {{{ */
function search($query, $limit=0, $offset=0, $mode='AND', $searchin=array(), $startFolder=null, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $categories=array(), $mode=0x3) { /* {{{ */
// Split the search string into constituent keywords.
$tkeys=array();
if (strlen($query)>0) {
@ -424,7 +429,7 @@ class LetoDMS_Core_DMS {
$searchin=array( 0, 1, 2, 3);
/*--------- Do it all over again for folders -------------*/
if(0 /* $searchfolders */) {
if($mode & 0x2) {
$searchKey = "";
// Assemble the arguments for the concatenation function. This allows the
// search to be carried across all the relevant fields.
@ -534,6 +539,7 @@ class LetoDMS_Core_DMS {
/*--------- Do it all over again for documents -------------*/
if($mode & 0x1) {
$searchKey = "";
// Assemble the arguments for the concatenation function. This allows the
// search to be carried across all the relevant fields.
@ -647,14 +653,6 @@ class LetoDMS_Core_DMS {
if (is_numeric($resArr[0]["num"]) && $resArr[0]["num"]>0) {
$totalDocs = (integer)$resArr[0]["num"];
}
if($limit) {
$totalPages = (integer)(($totalDocs+$totalFolders)/$limit);
if ((($totalDocs+$totalFolders)%$limit) > 0) {
$totalPages++;
}
} else {
$totalPages = 1;
}
// If there are no results from the count query, then there is no real need
// to run the full query. TODO: re-structure code to by-pass additional
@ -692,6 +690,18 @@ class LetoDMS_Core_DMS {
}
$docresult = array('totalDocs'=>$totalDocs, 'docs'=>$docs);
}
} else {
$docresult = array('totalDocs'=>0, 'docs'=>array());
}
if($limit) {
$totalPages = (integer)(($totalDocs+$totalFolders)/$limit);
if ((($totalDocs+$totalFolders)%$limit) > 0) {
$totalPages++;
}
} else {
$totalPages = 1;
}
return array_merge($docresult, $folderresult, array('totalPages'=>$totalPages));
} /* }}} */