Commit 47fe386b6d434b81326247631b9442210dc1120d

Authored by Michael Joseph
1 parent cab7e39d

(#2785) tidied formatting and only restrict search by folderID when one is present


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2434 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc
@@ -14,11 +14,12 @@ function getHeading() { @@ -14,11 +14,12 @@ function getHeading() {
14 } 14 }
15 15
16 function getMessage() { 16 function getMessage() {
17 - $sRefreshMessage = "<table><tr><td align=\"center\">If your browser displays a 'Warning: Page has Expired' message when you attempt to return to these search results, please click your browser's 'Refresh' button</td></tr></table>"; 17 + $sRefreshMessage = "<table><tr><td align=\"center\">If your browser displays a 'Warning: Page has Expired' message when you attempt to return to these search results, please click your browser's 'Refresh' button</td></tr></table>";
18 } 18 }
19 19
20 function getSearchResultsByCategory($iFolderID, $sKeywords, $iStartIndex, $sCategory) { 20 function getSearchResultsByCategory($iFolderID, $sKeywords, $iStartIndex, $sCategory) {
21 global $default; 21 global $default;
  22 + $default->log->info("getSearchResultsByCategory($iFolderID, $sKeywords, $iStartIndex, $sCategory)");
22 $sQuery = "SELECT DISTINCT '" . "$default->graphicsUrl/widgets/dfolder.gif" . "' AS folder_image_url, F.id AS folder_id, D.id AS document_id, D.name AS document_name, ROUND(MATCH(DT.document_text) AGAINST ('" . $sKeywords . "'),3) AS score " . 23 $sQuery = "SELECT DISTINCT '" . "$default->graphicsUrl/widgets/dfolder.gif" . "' AS folder_image_url, F.id AS folder_id, D.id AS document_id, D.name AS document_name, ROUND(MATCH(DT.document_text) AGAINST ('" . $sKeywords . "'),3) AS score " .
23 "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_document_text_table AS DT ON D.id = DT.document_id " . 24 "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_document_text_table AS DT ON D.id = DT.document_id " .
24 "INNER JOIN $default->owl_document_fields_table AS DFL ON DT.document_id=DFL.document_id " . 25 "INNER JOIN $default->owl_document_fields_table AS DFL ON DT.document_id=DFL.document_id " .
@@ -29,20 +30,17 @@ function getSearchResultsByCategory($iFolderID, $sKeywords, $iStartIndex, $sCate @@ -29,20 +30,17 @@ function getSearchResultsByCategory($iFolderID, $sKeywords, $iStartIndex, $sCate
29 "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " . 30 "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " .
30 "AND SDUL.user_id = " . $_SESSION["userID"] . " " . 31 "AND SDUL.user_id = " . $_SESSION["userID"] . " " .
31 "AND SL.name='Live' "; 32 "AND SL.name='Live' ";
32 - //only check in the parent_folder_ids if we're not searching from the  
33 - //root folder down  
34 - if ($iFolderID != 1) {  
35 - $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) ";  
36 - }  
37 - $sQuery .= "AND DF.name LIKE 'Category' ";  
38 - if (isset($sCategory)) {  
39 - $sQuery .= "AND DFL.value LIKE '$sCategory' ";  
40 - }  
41 - $sQuery .= "ORDER BY score DESC"; 33 + //only check in the parent_folder_ids if we're not searching from the
  34 + //root folder down
  35 + if (isset($iFolderID) && ($iFolderID != 1)) {
  36 + $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) ";
  37 + }
  38 + $sQuery .= "AND DF.name LIKE 'Category' ";
  39 + if (isset($sCategory)) {
  40 + $sQuery .= "AND DFL.value LIKE '$sCategory' ";
  41 + }
  42 + $sQuery .= "ORDER BY score DESC";
42 43
43 -  
44 - //var_dump($sQuery);  
45 -  
46 $aColumns = array("folder_image_url", "document_name","score"); 44 $aColumns = array("folder_image_url", "document_name","score");
47 $aColumnTypes = array(4,3,1); 45 $aColumnTypes = array(4,3,1);
48 $aColumnHeaders = array("<font color=\"ffffff\">Folder</font>","<font color=\"ffffff\">Document</font>","<font color=\"ffffff\">Score</font>"); 46 $aColumnHeaders = array("<font color=\"ffffff\">Folder</font>","<font color=\"ffffff\">Document</font>","<font color=\"ffffff\">Score</font>");
@@ -64,18 +62,16 @@ function getSearchResultsByDocumentType($iFolderID, $sKeywords, $iStartIndex, $i @@ -64,18 +62,16 @@ function getSearchResultsByDocumentType($iFolderID, $sKeywords, $iStartIndex, $i
64 "INNER JOIN $default->search_permissions_table AS SDUL ON SDUL.document_id = D.id " . 62 "INNER JOIN $default->search_permissions_table AS SDUL ON SDUL.document_id = D.id " .
65 "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " . 63 "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " .
66 "AND SDUL.user_id = " . $_SESSION["userID"] . " "; 64 "AND SDUL.user_id = " . $_SESSION["userID"] . " ";
67 - if (isset($iDocTypeID)) {  
68 - $sQuery .= "AND D.document_type_id = $iDocTypeID ";  
69 - }  
70 - $sQuery .= "AND SL.name='Live' ";  
71 - //only check in the parent_folder_ids if we're not searching from the  
72 - //root folder down  
73 - if ($iFolderID != 1) {  
74 - $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) ";  
75 - }  
76 - $sQuery .= "ORDER BY score DESC";  
77 -  
78 - //var_dump($sQuery); 65 + if (isset($iDocTypeID)) {
  66 + $sQuery .= "AND D.document_type_id = $iDocTypeID ";
  67 + }
  68 + $sQuery .= "AND SL.name='Live' ";
  69 + //only check in the parent_folder_ids if we're not searching from the
  70 + //root folder down
  71 + if (isset($iFolderID) && ($iFolderID != 1)) {
  72 + $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) ";
  73 + }
  74 + $sQuery .= "ORDER BY score DESC";
79 75
80 $aColumns = array("folder_image_url", "document_name","score"); 76 $aColumns = array("folder_image_url", "document_name","score");
81 $aColumnTypes = array(4,3,1); 77 $aColumnTypes = array(4,3,1);
@@ -100,14 +96,12 @@ function getSeachResultsByFolder($iFolderID, $iStartIndex, $sKeywords) { @@ -100,14 +96,12 @@ function getSeachResultsByFolder($iFolderID, $iStartIndex, $sKeywords) {
100 "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " . 96 "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " .
101 "AND SDUL.user_id = " . $_SESSION["userID"] . " " . 97 "AND SDUL.user_id = " . $_SESSION["userID"] . " " .
102 "AND SL.name='Live' "; 98 "AND SL.name='Live' ";
103 - //only check in the parent_folder_ids if we're not searching from the  
104 - //root folder down  
105 - if ($iFolderID != 1) {  
106 - $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) ";  
107 - }  
108 - $sQuery .= "ORDER BY score DESC";  
109 -  
110 - //var_dump($sQuery); 99 + //only check in the parent_folder_ids if we're not searching from the
  100 + //root folder down
  101 + if (isset($iFolderID) && ($iFolderID != 1)) {
  102 + $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) ";
  103 + }
  104 + $sQuery .= "ORDER BY score DESC";
111 105
112 $aColumns = array("folder_image_url", "document_name","score"); 106 $aColumns = array("folder_image_url", "document_name","score");
113 $aColumnTypes = array(4,3,1); 107 $aColumnTypes = array(4,3,1);
@@ -130,5 +124,4 @@ function getSearchVariablesHtml($sSearchText, $sBrowseType, $iFolderID, $iDocume @@ -130,5 +124,4 @@ function getSearchVariablesHtml($sSearchText, $sBrowseType, $iFolderID, $iDocume
130 $sToRender .= "<input type=\"hidden\" name=\"fDocType\" value=\"$iDocType\" />\n"; 124 $sToRender .= "<input type=\"hidden\" name=\"fDocType\" value=\"$iDocType\" />\n";
131 return $sToRender; 125 return $sToRender;
132 } 126 }
133 -  
134 -?> 127 +?>
135 \ No newline at end of file 128 \ No newline at end of file