Commit bb0c209631901c5fe54ab61622d878e837afacf6

Authored by nbm
1 parent b865c645

Obsolted by simple search.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4325 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/search/standardSearchBL.php deleted
1   -<?php
2   -/**
3   - * $Id$
4   - *
5   - * Business logic used to perform document searches
6   - *
7   - * Expected form variables
8   - * o fSearchText - text to search on
9   - * o fBrowseType - current browse type
10   - * o fFolderID - folder currently being browsed (if a folder is being browsed)
11   - * o fDocumentID - document currently being browsed (if a document is being browsed)
12   - * o fCategoryName - name of category being browsed (if a category is being browsed)
13   - * o fDocTypeID - name of document type being browsed (if a doc type is being browsed)
14   - *
15   - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com
16   - *
17   - * This program is free software; you can redistribute it and/or modify
18   - * it under the terms of the GNU General Public License as published by
19   - * the Free Software Foundation; either version 2 of the License, or
20   - * (at your option) any later version.
21   - *
22   - * This program is distributed in the hope that it will be useful,
23   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
24   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25   - * GNU General Public License for more details.
26   - *
27   - * You should have received a copy of the GNU General Public License
28   - * along with this program; if not, write to the Free Software
29   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30   - *
31   - * @version $Revision$
32   - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
33   - * @package search
34   - */
35   -
36   -require_once("../../../../config/dmsDefaults.php");
37   -
38   -KTUtil::extractGPC('fBrowseType', 'fCategoryName', 'fDocTypeID', 'fDocumentID', 'fFolderID', 'fSearchText', 'fStartIndex');
39   -
40   -if (checkSession()) {
41   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternBrowsableSearchResults.inc");
42   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
43   - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
44   - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
45   - require_once("$default->fileSystemRoot/presentation/Html.inc");
46   - require_once("standardSearchUI.inc");
47   -
48   - if (!isset($fStartIndex)) {
49   - $fStartIndex = 1;
50   - }
51   -
52   - if (strlen($fBrowseType) > 0) {
53   - //the user was browsing by a specific type
54   - switch ($fBrowseType) {
55   - case "folder" :
56   - //user was browsing a specific folder - search that folder
57   - if (!$fFolderID) {
58   - //start at the root folder
59   - $fFolderID = 1;
60   - }
61   - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
62   - $oPatternCustom = & new PatternCustom();
63   - $oPatternCustom->setHtml(getSeachResultsByFolder($fFolderID, $fStartIndex, $fSearchText));
64   - $main->setCentralPayload($oPatternCustom);
65   - $main->render();
66   - break;
67   - case "category" :
68   - //user was browsing by category - search all documents in that category
69   - if (!$fCategoryName) {
70   - //no category name specified, so just start at the root folder
71   - $fFolderID = 1;
72   - }
73   - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
74   - $oPatternCustom = & new PatternCustom();
75   - $oPatternCustom->setHtml(getSearchResultsByCategory($fFolderID, $fSearchText, $fStartIndex, $fCategoryName));
76   - $main->setCentralPayload($oPatternCustom);
77   - $main->render();
78   - break;
79   - case "documentType" :
80   - //echo "searching by documentType browseType";
81   - //user was browsing by document type - search all documents in that doc type
82   - if (!$fDocTypeID) {
83   - //no document type specified, so just start at the root folder
84   - $fFolderID = 1;
85   - }
86   - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
87   - $oPatternCustom = & new PatternCustom();
88   - $oPatternCustom->setHtml(getSearchResultsByDocumentType($fFolderID, $fSearchText, $fStartIndex, $fDocTypeID));
89   - $main->setCentralPayload($oPatternCustom);
90   - $main->render();
91   - break;
92   - default:
93   - //search from the root folder down i.e. all documents
94   - break;
95   - }
96   - } else if (strlen($fFolderID) > 0) {
97   - //the user was browsing a folder, search that folder
98   - //echo "searching by folder id";
99   - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
100   - $oPatternCustom = & new PatternCustom();
101   - $oPatternCustom->setHtml(getSeachResultsByFolder($fFolderID, $fStartIndex, $fSearchText));
102   - $main->setCentralPayload($oPatternCustom);
103   - $main->render();
104   -
105   - } else if (strlen($fDocumentID) > 0) {
106   - //echo "searching by document id";
107   - //the user was viewing a document, search in that document's folder
108   - $oDocument = Document::get($fDocumentID);
109   - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
110   - $oPatternCustom = & new PatternCustom();
111   - $oPatternCustom->setHtml(getSeachResultsByFolder($oDocument->getFolderID(), $fStartIndex, $fSearchText));
112   - $main->setCentralPayload($oPatternCustom);
113   - $main->render();
114   - } else {
115   - //echo "searching by folder";
116   - //search from the root folder down i.e. all documents
117   - $fFolderID = 1;
118   - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
119   - $oPatternCustom = & new PatternCustom();
120   - $oPatternCustom->setHtml(getSeachResultsByFolder($fFolderID, $fStartIndex, $fSearchText));
121   - $main->setCentralPayload($oPatternCustom);
122   - $main->render();
123   - }
124   -}
125   -//echo "not searching"
126   -?>
127   -
presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc deleted
1   -<?php
2   -/**
3   - * $Id$
4   - *
5   - * Presentation functionality used to searchDocumentBL.php.
6   - *
7   - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com
8   - *
9   - * This program is free software; you can redistribute it and/or modify
10   - * it under the terms of the GNU General Public License as published by
11   - * the Free Software Foundation; either version 2 of the License, or
12   - * (at your option) any later version.
13   - *
14   - * This program is distributed in the hope that it will be useful,
15   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17   - * GNU General Public License for more details.
18   - *
19   - * You should have received a copy of the GNU General Public License
20   - * along with this program; if not, write to the Free Software
21   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22   - *
23   - * @version $Revision$
24   - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
25   - * @package search
26   - */
27   -
28   -function getHeading() {
29   - return renderHeading(_("Standard Search"));
30   -}
31   -
32   -function getMessage() {
33   - $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>";
34   -}
35   -
36   -function getSearchResultsByCategory($iFolderID, $sKeywords, $iStartIndex, $sCategory) {
37   - global $default;
38   -
39   - // XXX: Icky MySQL-specific stuff.
40   - $sVersion = DBUtil::getOneResultKey("SHOW VARIABLES LIKE 'version'", "Value");
41   - if ((int)substr($sVersion, 0, 1) >= 4) {
42   - $boolean_mode = "IN BOOLEAN MODE";
43   - } else {
44   - $boolean_mode = "";
45   - }
46   -
47   -
48   - /*ok*/ $sQuery = "SELECT DISTINCT '" . "$default->graphicsUrl/widgets/dfolder.gif" . "' AS folder_image_url, " .
49   - "F.id AS folder_id, D.id AS document_id, D.name AS document_name, " .
50   - "ROUND(MATCH(DT.document_text) AGAINST (? $boolean_mode) OR 1, 3) AS score " .
51   - "FROM $default->documents_table AS D INNER JOIN $default->document_text_table AS DT ON D.id = DT.document_id " .
52   - "INNER JOIN $default->document_fields_link_table AS DFL ON DT.document_id=DFL.document_id " .
53   - "INNER JOIN $default->document_fields_table AS DF ON DF.id = DFL.document_field_id " .
54   - "INNER JOIN $default->status_table AS SL ON D.status_id = SL.id " .
55   - "INNER JOIN $default->folders_table AS F on F.ID = D.folder_id " .
56   - "INNER JOIN $default->search_permissions_table AS SDUL ON SDUL.document_id = D.id " .
57   - "WHERE MATCH(DT.document_text) AGAINST (? $boolean_mode) " .
58   - "AND (F.is_public OR SDUL.user_id = ?) " .
59   - "AND SL.name='Live' ";
60   - $aParams = array($sKeywords, $sKeywords, $_SESSION["userID"]);
61   - //only check in the parent_folder_ids if we're not searching from the
62   - //root folder down
63   - if (isset($iFolderID) && ($iFolderID != 1)) {
64   - $iFolderID = (int)$iFolderID;
65   - $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) ";
66   - }
67   - $sQuery .= "AND DF.name LIKE 'Category' ";
68   - if (isset($sCategory)) {
69   - $sQuery .= "AND DFL.value LIKE ? ";
70   - $aParams[] = $sCategory;
71   - }
72   - $sQuery .= "ORDER BY score DESC";
73   -
74   - $aColumns = array("folder_image_url", "document_name","score");
75   - $aColumnTypes = array(4,3,1);
76   - $aColumnHeaders = array("<font color=\"ffffff\">" . _("Folder") . "</font>","<font color=\"ffffff\">" . _("Document") . "</font>","<font color=\"ffffff\">" . _("Score") . "</font>");
77   - $aLinkURLs = array("$default->rootUrl/control.php?action=browse","$default->rootUrl/control.php?action=viewDocument");
78   - $aDBQueryStringColumns = array("document_id","folder_id");
79   - $aQueryStringVariableNames = array("fDocumentID", "fFolderID");
80   -
81   - $oPatternBrowse = & new PatternBrowseableSearchResults(array($sQuery, $aParams), 10, $aColumns, $aColumnTypes, $aColumnHeaders, $aLinkURLs, $aDBQueryStringColumns, $aQueryStringVariableNames);
82   - $oPatternBrowse->setStartIndex($iStartIndex);
83   - $oPatternBrowse->setSearchText($sKeywords);
84   - return getHeading() . $oPatternBrowse->render() . getSearchVariablesHtml($sKeywords, "category", $iFolderID, "", $sCategory, "") . getMessage();
85   -}
86   -
87   -function getSearchResultsByDocumentType($iFolderID, $sKeywords, $iStartIndex, $iDocTypeID) {
88   - global $default;
89   -
90   - // XXX: Icky MySQL-specific stuff.
91   - $sVersion = DBUtil::getOneResultKey("SHOW VARIABLES LIKE 'version'", "Value");
92   - if ((int)substr($sVersion, 0, 1) >= 4) {
93   - $boolean_mode = "IN BOOLEAN MODE";
94   - } else {
95   - $boolean_mode = "";
96   - }
97   -
98   - /*ok*/ $sQuery = "SELECT DISTINCT '" . "$default->graphicsUrl/widgets/dfolder.gif" . "' AS folder_image_url, " .
99   - "F.id AS folder_id, D.id AS document_id, D.name AS document_name, " .
100   - "ROUND(MATCH(DT.document_text) AGAINST (? $boolean_mode),3) AS score " .
101   - "FROM $default->documents_table AS D INNER JOIN $default->document_text_table AS DT ON D.id = DT.document_id " .
102   - "INNER JOIN $default->status_table AS SL ON D.status_id = SL.id " .
103   - "INNER JOIN $default->folders_table AS F on F.ID = D.folder_id " .
104   - "INNER JOIN $default->search_permissions_table AS SDUL ON SDUL.document_id = D.id " .
105   - "WHERE MATCH(DT.document_text) AGAINST (? $boolean_mode) " .
106   - "AND (F.is_public OR SDUL.user_id = ?) ";
107   - $aParams = array($sKeywords, $sKeywords, $_SESSION["userID"]);
108   - if (isset($iDocTypeID)) {
109   - $sQuery .= "AND D.document_type_id = ? ";
110   - $aParams[] = $iDocTypeID;
111   - }
112   - $sQuery .= "AND SL.name='Live' ";
113   - //only check in the parent_folder_ids if we're not searching from the
114   - //root folder down
115   - if (isset($iFolderID) && ($iFolderID != 1)) {
116   - $iFolderID = (int)$iFolderID;
117   - $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) ";
118   - }
119   - $sQuery .= "ORDER BY score DESC";
120   -
121   - $aColumns = array("folder_image_url", "document_name","score");
122   - $aColumnTypes = array(4,3,1);
123   - $aColumnHeaders = array("<font color=\"ffffff\">" . _("Folder") . "</font>","<font color=\"ffffff\">" . _("Document") . "</font>","<font color=\"ffffff\">" . _("Score") . "</font>");
124   - $aLinkURLs = array("$default->rootUrl/control.php?action=browse","$default->rootUrl/control.php?action=viewDocument");
125   - $aDBQueryStringColumns = array("document_id","folder_id");
126   - $aQueryStringVariableNames = array("fDocumentID", "fFolderID");
127   -
128   - $oPatternBrowse = & new PatternBrowseableSearchResults(array($sQuery, $aParams), 10, $aColumns, $aColumnTypes, $aColumnHeaders, $aLinkURLs, $aDBQueryStringColumns, $aQueryStringVariableNames);
129   - $oPatternBrowse->setStartIndex($iStartIndex);
130   - $oPatternBrowse->setSearchText($sKeywords);
131   - return getHeading() . $oPatternBrowse->render() . getSearchVariablesHtml($sKeywords, "documentType", $iFolderID, "", "", $iDocTypeID) . getMessage();
132   -
133   -}
134   -
135   -function getSeachResultsByFolder($iFolderID, $iStartIndex, $sKeywords) {
136   - global $default;
137   -
138   - // XXX: Icky MySQL-specific stuff.
139   - $sVersion = DBUtil::getOneResultKey("SHOW VARIABLES LIKE 'version'", "Value");
140   - if ((int)substr($sVersion, 0, 1) >= 4) {
141   - $boolean_mode = "IN BOOLEAN MODE";
142   - } else {
143   - $boolean_mode = "";
144   - }
145   -
146   - /*ok*/ $sQuery = "SELECT DISTINCT '" . "$default->graphicsUrl/widgets/dfolder.gif" . "' AS folder_image_url, " .
147   - "F.id AS folder_id, D.id AS document_id, D.name AS document_name, " .
148   - "ROUND(MATCH(DT.document_text) AGAINST (? $boolean_mode),3) AS score " .
149   - "FROM $default->documents_table AS D INNER JOIN $default->document_text_table AS DT ON D.id = DT.document_id " .
150   - "INNER JOIN $default->status_table AS SL ON D.status_id = SL.id " .
151   - "INNER JOIN $default->folders_table AS F on F.ID = D.folder_id " .
152   - "INNER JOIN $default->search_permissions_table AS SDUL ON SDUL.document_id = D.id " .
153   - "WHERE MATCH(DT.document_text) AGAINST (? $boolean_mode) " .
154   - "AND (F.is_public OR SDUL.user_id = ?) " .
155   - "AND SL.name='Live' ";
156   - $aParams = array($sKeywords, $sKeywords, $_SESSION["userID"]);
157   - //only check in the parent_folder_ids if we're not searching from the
158   - //root folder down
159   - if (isset($iFolderID) && ($iFolderID != 1)) {
160   - $iFolderID = (int)$iFolderID;
161   - $sQuery .= "AND (F.parent_folder_ids LIKE '%,$iFolderID,%' OR F.id = $iFolderID) ";
162   - }
163   - $sQuery .= "ORDER BY score DESC";
164   -
165   - $aColumns = array("folder_image_url", "document_name","score");
166   - $aColumnTypes = array(4,3,1);
167   - $aColumnHeaders = array("<font color=\"ffffff\">" . _("Folder") . "</font>", "<font color=\"ffffff\">" . _("Document") . "</font>", "<font color=\"ffffff\">" . _("Score") . "</font>");
168   - $aLinkURLs = array("$default->rootUrl/control.php?action=browse","$default->rootUrl/control.php?action=viewDocument");
169   - $aDBQueryStringColumns = array("document_id","folder_id");
170   - $aQueryStringVariableNames = array("fDocumentID", "fFolderID");
171   -
172   - $oPatternBrowse = & new PatternBrowseableSearchResults(array($sQuery, $aParams), 10, $aColumns, $aColumnTypes, $aColumnHeaders, $aLinkURLs, $aDBQueryStringColumns, $aQueryStringVariableNames);
173   - $oPatternBrowse->setStartIndex($iStartIndex);
174   - $oPatternBrowse->setSearchText($sKeywords);
175   - return getHeading() . $oPatternBrowse->render() . getSearchVariablesHtml($sKeywords, "", $iFolderID, "", "", "") . getMessage();
176   -}
177   -
178   -function getSearchVariablesHtml($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType) {
179   - $sToRender = "<input type=\"hidden\" name=\"fSearchText\" value=\"$sSearchText\" />\n";
180   - $sToRender .= "<input type=\"hidden\" name=\"fBrowseType\" value=\"$sBrowseType\" />\n";
181   - $sToRender .= "<input type=\"hidden\" name=\"fFolderID\" value=\"$iFolderID\" />\n";
182   - $sToRender .= "<input type=\"hidden\" name=\"fDocumentID\" value=\"$iDocumentID\" />\n";
183   - $sToRender .= "<input type=\"hidden\" name=\"fCategoryName\" value=\"$sCategoryName\" />\n";
184   - $sToRender .= "<input type=\"hidden\" name=\"fDocType\" value=\"$iDocType\" />\n";
185   - return $sToRender;
186   -}
187   -?>