From 05a7d7dcaba236c96ffd368d49319b04a68436ae Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 29 Jul 2003 14:54:13 +0000 Subject: [PATCH] (#2785) tidied formatting and only restrict search by folderID when one is present --- presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc | 65 +++++++++++++++++++++++++++++------------------------------------ 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc b/presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc index 5049601..1d4cc72 100644 --- a/presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc @@ -14,11 +14,12 @@ function getHeading() { } function getMessage() { - $sRefreshMessage = "
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
"; + $sRefreshMessage = "
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
"; } function getSearchResultsByCategory($iFolderID, $sKeywords, $iStartIndex, $sCategory) { global $default; + $default->log->info("getSearchResultsByCategory($iFolderID, $sKeywords, $iStartIndex, $sCategory)"); $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 " . "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_document_text_table AS DT ON D.id = DT.document_id " . "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 "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " . "AND SDUL.user_id = " . $_SESSION["userID"] . " " . "AND SL.name='Live' "; - //only check in the parent_folder_ids if we're not searching from the - //root folder down - if ($iFolderID != 1) { - $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) "; - } - $sQuery .= "AND DF.name LIKE 'Category' "; - if (isset($sCategory)) { - $sQuery .= "AND DFL.value LIKE '$sCategory' "; - } - $sQuery .= "ORDER BY score DESC"; + //only check in the parent_folder_ids if we're not searching from the + //root folder down + if (isset($iFolderID) && ($iFolderID != 1)) { + $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) "; + } + $sQuery .= "AND DF.name LIKE 'Category' "; + if (isset($sCategory)) { + $sQuery .= "AND DFL.value LIKE '$sCategory' "; + } + $sQuery .= "ORDER BY score DESC"; - - //var_dump($sQuery); - $aColumns = array("folder_image_url", "document_name","score"); $aColumnTypes = array(4,3,1); $aColumnHeaders = array("Folder","Document","Score"); @@ -64,18 +62,16 @@ function getSearchResultsByDocumentType($iFolderID, $sKeywords, $iStartIndex, $i "INNER JOIN $default->search_permissions_table AS SDUL ON SDUL.document_id = D.id " . "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " . "AND SDUL.user_id = " . $_SESSION["userID"] . " "; - if (isset($iDocTypeID)) { - $sQuery .= "AND D.document_type_id = $iDocTypeID "; - } - $sQuery .= "AND SL.name='Live' "; - //only check in the parent_folder_ids if we're not searching from the - //root folder down - if ($iFolderID != 1) { - $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) "; - } - $sQuery .= "ORDER BY score DESC"; - - //var_dump($sQuery); + if (isset($iDocTypeID)) { + $sQuery .= "AND D.document_type_id = $iDocTypeID "; + } + $sQuery .= "AND SL.name='Live' "; + //only check in the parent_folder_ids if we're not searching from the + //root folder down + if (isset($iFolderID) && ($iFolderID != 1)) { + $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) "; + } + $sQuery .= "ORDER BY score DESC"; $aColumns = array("folder_image_url", "document_name","score"); $aColumnTypes = array(4,3,1); @@ -100,14 +96,12 @@ function getSeachResultsByFolder($iFolderID, $iStartIndex, $sKeywords) { "WHERE MATCH(DT.document_text) AGAINST ('" . $sKeywords . "') " . "AND SDUL.user_id = " . $_SESSION["userID"] . " " . "AND SL.name='Live' "; - //only check in the parent_folder_ids if we're not searching from the - //root folder down - if ($iFolderID != 1) { - $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) "; - } - $sQuery .= "ORDER BY score DESC"; - - //var_dump($sQuery); + //only check in the parent_folder_ids if we're not searching from the + //root folder down + if (isset($iFolderID) && ($iFolderID != 1)) { + $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) "; + } + $sQuery .= "ORDER BY score DESC"; $aColumns = array("folder_image_url", "document_name","score"); $aColumnTypes = array(4,3,1); @@ -130,5 +124,4 @@ function getSearchVariablesHtml($sSearchText, $sBrowseType, $iFolderID, $iDocume $sToRender .= "\n"; return $sToRender; } - -?> +?> \ No newline at end of file -- libgit2 0.21.4