ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMDSearch.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
37{
38 var $mode = '';
39
40 /*
41 * instance of query parser
42 */
43 var $query_parser = null;
44
45 var $db = null;
46
51 function ilMDSearch(&$qp_obj)
52 {
53 global $ilDB;
54
55 $this->query_parser =& $qp_obj;
56 $this->db =& $ilDB;
57
58 include_once 'Services/Search/classes/class.ilSearchResult.php';
59
60 $this->search_result = new ilSearchResult();
61 }
62
69 function setMode($a_mode)
70 {
71 $this->mode = $a_mode;
72 }
73 function getMode()
74 {
75 return $this->mode;
76 }
77
78
79 function &performSearch()
80 {
81 switch($this->getMode())
82 {
83 case 'all':
84 break;
85 case 'keyword':
86 return $this->__searchKeywordsOnly();
87 break;
88
89 default:
90 echo "ilMDSearch::performSearch() no mode given";
91 return false;
92 }
93 }
94
95
96
97 // Private
99 {
100 $where = " WHERE ";
101 $field = " keyword ";
102 $counter = 0;
103 foreach($this->query_parser->getQuotedWords() as $word)
104 {
105 if($counter++)
106 {
107 $where .= strtoupper($this->query_parser->getCombination());
108 }
109 $where .= $field;
110 $where .= ("LIKE (".$ilDB->quote("%".$word."%").")");
111 }
112
113 $query = "SELECT * FROM il_meta_keyword".
114 $where.
115 "ORDER BY meta_keyword_id DESC";
116
117 $res = $this->db->query($query);
118 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
119 {
120 $this->search_result->addEntry($row->obj_id,$row->obj_type,$row->rbac_id);
121 }
122
123 return $this->search_result;
124 }
125}
126?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setMode($a_mode)
Define meta elements to search.
ilMDSearch(&$qp_obj)
Constructor @access public.
global $ilDB