Commit 3866b17a5cb9e843938c44b7ee8e134e0487e786

Authored by michael
1 parent 3cfc7147

removed commented out code

fixed renderHeading calls
only search for live documents


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1963 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc
1 <?php 1 <?php
2 -  
3 /** 2 /**
4 -* Presentation functionality used to searchDocumentBL.php  
5 -*  
6 -* @author Rob Cherry, Jam Warehouse South Africa (Pty) Ltd  
7 -* @date 20 February 2003  
8 -* @package presentation.lookAndFeel.documentmanagement  
9 -*/  
10 -  
11 -/*function renderHeading() {  
12 - global $default;  
13 - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));  
14 - $sColor = $default->siteMap->getSectionColour($sSectionName, "th");  
15 - $sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\"><font color=\"ffffff\">Standard Search</font></th></tr>\n";  
16 - $sToRender .= "<tr/>\n";  
17 - $sToRender .= "<tr/>\n";  
18 - return $sToRender;  
19 -}*/ 3 + * $Id$
  4 + *
  5 + * Presentation functionality used to searchDocumentBL.php
  6 + *
  7 + * @author Rob Cherry, Jam Warehouse South Africa (Pty) Ltd
  8 + * @date 20 February 2003
  9 + * @package presentation.lookAndFeel.documentmanagement
  10 + */
20 11
21 function getPage($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType, $sFolderIDs, $iStartIndex, $sSQLSearchString, $bSearchByDocument = false) { 12 function getPage($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType, $sFolderIDs, $iStartIndex, $sSQLSearchString, $bSearchByDocument = false) {
22 $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>"; 13 $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>";
23 - return "<table width=\"600\">" . renderHeading("Standard Search") . "</table>" . getSearchResults($sFolderIDs, $sSQLSearchString, $iStartIndex, $bSearchByDocument) . $sRefreshMessage . getSearchVariablesHtml($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType); 14 + return renderHeading("Standard Search") . getSearchResults($sFolderIDs, $sSQLSearchString, $iStartIndex, $bSearchByDocument) . $sRefreshMessage . getSearchVariablesHtml($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType);
24 } 15 }
25 16
26 -/*function getSearchResults($sIDs,$sSQLSearchString, $iStartIndex, $bSearchByDocument = false) {  
27 - global $default;  
28 - $sQuery = "SELECT DISTINCT '" . "$default->graphicsUrl/widgets/dfolder.gif" . "' AS folder_image_url, F.id folder_id, D.id document_id, D.name AS document_name " .  
29 - "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_folders_table AS F ON D.folder_id = F.id " .  
30 - "INNER JOIN $default->owl_document_words_table AS DWL ON DWL.document_id = D.id " .  
31 - "INNER JOIN $default->owl_words_lookup_table AS WL ON WL.id = DWL.word_id ";  
32 - if (strlen($sIDs) > 0) {  
33 - if ($bSearchByDocument) {  
34 - $sQuery .= "WHERE D.id IN ($sIDs) ";  
35 - } else {  
36 - $sQuery .= "WHERE F.id IN ($sIDs) ";  
37 - }  
38 - $sQuery .= "AND ($sSQLSearchString)";  
39 - } else {  
40 - $sQuery .= "WHERE ($sSQLSearchString)";  
41 - }  
42 -  
43 - $sQuery .= "ORDER BY D.name ASC";  
44 -  
45 - $aColumns = array("folder_image_url", "document_name");  
46 - $aColumnTypes = array(4,3);  
47 - $aColumnHeaders = array("<font color=\"ffffff\">Folder</font>","<font color=\"ffffff\">Document</font>");  
48 - $aLinkURLs = array("$default->rootUrl/control.php?action=browse","$default->rootUrl/control.php?action=viewDocument");  
49 - $aDBQueryStringColumns = array("document_id","folder_id");  
50 - $aQueryStringVariableNames = array("fDocumentID", "fFolderID");  
51 -  
52 - $oPatternBrowse = & new PatternBrowseableSearchResults($sQuery, 10, $aColumns, $aColumnTypes, $aColumnHeaders, $aLinkURLs, $aDBQueryStringColumns, $aQueryStringVariableNames);  
53 - $oPatternBrowse->setStartIndex($iStartIndex);  
54 - return $oPatternBrowse->render();  
55 -}*/  
56 -  
57 function getSearchResults($sFolderIDs, $sKeywords, $iStartIndex) { 17 function getSearchResults($sFolderIDs, $sKeywords, $iStartIndex) {
58 global $default; 18 global $default;
59 $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, MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') AS score " . 19 $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, MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') AS score " .
60 "FROM search_document_user_link AS SDUL INNER JOIN document_text AS DT ON SDUL.document_id = DT.document_id " . 20 "FROM search_document_user_link AS SDUL INNER JOIN document_text AS DT ON SDUL.document_id = DT.document_id " .
61 "INNER JOIN documents AS D ON D.id = SDUL.document_id " . 21 "INNER JOIN documents AS D ON D.id = SDUL.document_id " .
  22 + "INNER JOIN status_lookup AS SL ON D.status_id = SL.id " .
62 "INNER JOIN folders AS F on F.ID = D.folder_id " . 23 "INNER JOIN folders AS F on F.ID = D.folder_id " .
63 "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " . 24 "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " .
64 "AND SDUL.user_id = " . $_SESSION["userID"] . " " . 25 "AND SDUL.user_id = " . $_SESSION["userID"] . " " .
  26 + "AND SL.name='Live' " .
65 "AND F.id IN ($sFolderIDs) " . 27 "AND F.id IN ($sFolderIDs) " .
66 "ORDER BY score DESC"; 28 "ORDER BY score DESC";
67 29