mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 05:01:43 +00:00
- do not search for keywords in folders
- removed some old code
This commit is contained in:
parent
40568de7ad
commit
08e9f4da03
|
@ -478,24 +478,17 @@ class LetoDMS_Core_DMS {
|
||||||
/*--------- Do it all over again for folders -------------*/
|
/*--------- Do it all over again for folders -------------*/
|
||||||
if($mode & 0x2) {
|
if($mode & 0x2) {
|
||||||
$searchKey = "";
|
$searchKey = "";
|
||||||
// Assemble the arguments for the concatenation function. This allows the
|
|
||||||
// search to be carried across all the relevant fields.
|
|
||||||
$concatFunction = "";
|
|
||||||
if (in_array(2, $searchin)) {
|
if (in_array(2, $searchin)) {
|
||||||
$concatFunction = (strlen($concatFunction) == 0 ? "" : $concatFunction.", ")."`tblFolders`.`name`";
|
|
||||||
$searchFields[] = "`tblFolders`.`name`";
|
$searchFields[] = "`tblFolders`.`name`";
|
||||||
}
|
}
|
||||||
if (in_array(3, $searchin)) {
|
if (in_array(3, $searchin)) {
|
||||||
$concatFunction = (strlen($concatFunction) == 0 ? "" : $concatFunction.", ")."`tblFolders`.`comment`";
|
|
||||||
$searchFields[] = "`tblFolders`.`comment`";
|
$searchFields[] = "`tblFolders`.`comment`";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($concatFunction)>0 && count($tkeys)>0) {
|
if (count($searchFields)>0) {
|
||||||
$concatFunction = "CONCAT_WS(' ', ".$concatFunction.")";
|
|
||||||
foreach ($tkeys as $key) {
|
foreach ($tkeys as $key) {
|
||||||
$key = trim($key);
|
$key = trim($key);
|
||||||
if (strlen($key)>0) {
|
if (strlen($key)>0) {
|
||||||
//$searchKey = (strlen($searchKey)==0 ? "" : $searchKey." ".$logicalmode." ").$concatFunction." LIKE ".$this->db->qstr('%'.$key.'%');
|
|
||||||
$searchKey = (strlen($searchKey)==0 ? "" : $searchKey." ".$logicalmode." ")."(".implode(" like ".$this->db->qstr("%".$key."%")." OR ", $searchFields)." like ".$this->db->qstr("%".$key."%").")";
|
$searchKey = (strlen($searchKey)==0 ? "" : $searchKey." ".$logicalmode." ")."(".implode(" like ".$this->db->qstr("%".$key."%")." OR ", $searchFields)." like ".$this->db->qstr("%".$key."%").")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -547,41 +540,48 @@ class LetoDMS_Core_DMS {
|
||||||
$searchQuery .= " AND (".$searchCreateDate.")";
|
$searchQuery .= " AND (".$searchCreateDate.")";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count the number of rows that the search will produce.
|
/* Do not search for folders if not at least a search for a key,
|
||||||
$resArr = $this->db->getResultArray("SELECT COUNT(*) AS num ".$searchQuery);
|
* an owner, or creation date is requested.
|
||||||
$totalFolders = 0;
|
*/
|
||||||
if (is_numeric($resArr[0]["num"]) && $resArr[0]["num"]>0) {
|
if($searchKey || $searchOwner || $searchCreateDate) {
|
||||||
$totalFolders = (integer)$resArr[0]["num"];
|
// Count the number of rows that the search will produce.
|
||||||
}
|
$resArr = $this->db->getResultArray("SELECT COUNT(*) AS num ".$searchQuery." GROUP BY `tblFolders`.`id`");
|
||||||
|
$totalFolders = 0;
|
||||||
// If there are no results from the count query, then there is no real need
|
if (is_numeric($resArr[0]["num"]) && $resArr[0]["num"]>0) {
|
||||||
// to run the full query. TODO: re-structure code to by-pass additional
|
$totalFolders = (integer)$resArr[0]["num"];
|
||||||
// queries when no initial results are found.
|
|
||||||
|
|
||||||
// Only search if the offset is not beyond the number of folders
|
|
||||||
if($totalFolders > $offset) {
|
|
||||||
// Prepare the complete search query, including the LIMIT clause.
|
|
||||||
$searchQuery = "SELECT `tblFolders`.* ".$searchQuery;
|
|
||||||
|
|
||||||
if($limit) {
|
|
||||||
$searchQuery .= " LIMIT ".$offset.",".$limit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the complete search query to the database.
|
// If there are no results from the count query, then there is no real need
|
||||||
$resArr = $this->db->getResultArray($searchQuery);
|
// to run the full query. TODO: re-structure code to by-pass additional
|
||||||
} else {
|
// queries when no initial results are found.
|
||||||
$resArr = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------- Ausgabe der Ergebnisse ----------------------------
|
// Only search if the offset is not beyond the number of folders
|
||||||
$numResults = count($resArr);
|
if($totalFolders > $offset) {
|
||||||
if ($numResults == 0) {
|
// Prepare the complete search query, including the LIMIT clause.
|
||||||
$folderresult = array('totalFolders'=>$totalFolders, 'folders'=>array());
|
$searchQuery = "SELECT `tblFolders`.* ".$searchQuery;
|
||||||
} else {
|
|
||||||
foreach ($resArr as $folderArr) {
|
if($limit) {
|
||||||
$folders[] = $this->getFolder($folderArr['id']);
|
$searchQuery .= " LIMIT ".$offset.",".$limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the complete search query to the database.
|
||||||
|
$resArr = $this->db->getResultArray($searchQuery);
|
||||||
|
} else {
|
||||||
|
$resArr = array();
|
||||||
}
|
}
|
||||||
$folderresult = array('totalFolders'=>$totalFolders, 'folders'=>$folders);
|
|
||||||
|
// ------------------- Ausgabe der Ergebnisse ----------------------------
|
||||||
|
$numResults = count($resArr);
|
||||||
|
if ($numResults == 0) {
|
||||||
|
$folderresult = array('totalFolders'=>$totalFolders, 'folders'=>array());
|
||||||
|
} else {
|
||||||
|
foreach ($resArr as $folderArr) {
|
||||||
|
$folders[] = $this->getFolder($folderArr['id']);
|
||||||
|
}
|
||||||
|
$folderresult = array('totalFolders'=>$totalFolders, 'folders'=>$folders);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$folderresult = array('totalFolders'=>0, 'folders'=>array());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$folderresult = array('totalFolders'=>0, 'folders'=>array());
|
$folderresult = array('totalFolders'=>0, 'folders'=>array());
|
||||||
|
@ -591,29 +591,22 @@ class LetoDMS_Core_DMS {
|
||||||
|
|
||||||
if($mode & 0x1) {
|
if($mode & 0x1) {
|
||||||
$searchKey = "";
|
$searchKey = "";
|
||||||
// Assemble the arguments for the concatenation function. This allows the
|
|
||||||
// search to be carried across all the relevant fields.
|
|
||||||
$concatFunction = "";
|
|
||||||
$searchFields = array();
|
$searchFields = array();
|
||||||
if (in_array(1, $searchin)) {
|
if (in_array(1, $searchin)) {
|
||||||
$concatFunction = "`tblDocuments`.`keywords`";
|
|
||||||
$searchFields[] = "`tblDocuments`.`keywords`";
|
$searchFields[] = "`tblDocuments`.`keywords`";
|
||||||
}
|
}
|
||||||
if (in_array(2, $searchin)) {
|
if (in_array(2, $searchin)) {
|
||||||
$concatFunction = (strlen($concatFunction) == 0 ? "" : $concatFunction.", ")."`tblDocuments`.`name`";
|
|
||||||
$searchFields[] = "`tblDocuments`.`name`";
|
$searchFields[] = "`tblDocuments`.`name`";
|
||||||
}
|
}
|
||||||
if (in_array(3, $searchin)) {
|
if (in_array(3, $searchin)) {
|
||||||
$concatFunction = (strlen($concatFunction) == 0 ? "" : $concatFunction.", ")."`tblDocuments`.`comment`";
|
|
||||||
$searchFields[] = "`tblDocuments`.`comment`";
|
$searchFields[] = "`tblDocuments`.`comment`";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($concatFunction)>0 && count($tkeys)>0) {
|
|
||||||
$concatFunction = "CONCAT_WS(' ', ".$concatFunction.")";
|
if (count($searchFields)>0) {
|
||||||
foreach ($tkeys as $key) {
|
foreach ($tkeys as $key) {
|
||||||
$key = trim($key);
|
$key = trim($key);
|
||||||
if (strlen($key)>0) {
|
if (strlen($key)>0) {
|
||||||
//$searchKey = (strlen($searchKey)==0 ? "" : $searchKey." ".$logicalmode." ").$concatFunction." LIKE ".$this->db->qstr('%'.$key.'%');
|
|
||||||
$searchKey = (strlen($searchKey)==0 ? "" : $searchKey." ".$logicalmode." ")."(".implode(" like ".$this->db->qstr("%".$key."%")." OR ", $searchFields)." like ".$this->db->qstr("%".$key."%").")";
|
$searchKey = (strlen($searchKey)==0 ? "" : $searchKey." ".$logicalmode." ")."(".implode(" like ".$this->db->qstr("%".$key."%")." OR ", $searchFields)." like ".$this->db->qstr("%".$key."%").")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user