ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMetaDataSearch.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
35include_once 'Services/Search/classes/class.ilAbstractSearch.php';
36
38{
39 var $mode = '';
40
41 /*
42 * instance of query parser
43 */
44 var $query_parser = null;
45
46 var $db = null;
47
52 function ilMetaDataSearch(&$qp_obj)
53 {
54 parent::ilAbstractSearch($qp_obj);
55 }
56
63 function setMode($a_mode)
64 {
65 $this->mode = $a_mode;
66 }
67 function getMode()
68 {
69 return $this->mode;
70 }
71
72
73 function &performSearch()
74 {
75 switch($this->getMode())
76 {
77 case 'keyword':
78 return $this->__searchKeywords();
79
80 case 'contribute':
81 return $this->__searchContribute();
82
83 case 'title':
84 return $this->__searchTitles();
85
86 case 'description':
87 return $this->__searchDescriptions();
88
89 default:
90 echo "ilMDSearch::performSearch() no mode given";
91 return false;
92 }
93 }
94
95
96
97 // Private
99 {
100 if(!$this->getFilter())
101 {
102 return '';
103 }
104 else
105 {
106 $type = "('";
107 $type .= implode("','",$this->getFilter());
108 $type .= "')";
109
110 $in = " AND obj_type IN ".$type;
111
112 return $in;
113 }
114 }
116 {
117 $this->setFields(array('entity'));
118
119 $in = $this->__createInStatement();
120 $where = $this->__createContributeWhereCondition();
121 $locate = $this->__createLocateString();
122
123 $query = "SELECT rbac_id,obj_id,obj_type ".
124 $locate.
125 "FROM il_meta_entity ".
126 $where." ".$in.' ';
127
128 $res = $this->db->query($query);
129 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
130 {
131 $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
132 }
133
135 }
136
137
139 {
140 $this->setFields(array('keyword'));
141
142 $in = $this->__createInStatement();
143 $where = $this->__createKeywordWhereCondition();
144 $locate = $this->__createLocateString();
145
146 $query = "SELECT rbac_id,obj_id,obj_type ".
147 $locate.
148 "FROM il_meta_keyword ".
149 $where." ".$in.' ';
150
151 $res = $this->db->query($query);
152 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
153 {
154 $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
155 }
156
158 }
159 function __searchTitles()
160 {
161 $this->setFields(array('title'));
162
163 $in = $this->__createInStatement();
164 $where = $this->__createTitleWhereCondition();
165 $locate = $this->__createLocateString();
166
167 $query = "SELECT rbac_id,obj_id,obj_type ".
168 $locate.
169 "FROM il_meta_general ".
170 $where." ".$in.' ';
171
172 $res = $this->db->query($query);
173 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
174 {
175 $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
176 }
177
179 }
181 {
182 $this->setFields(array('description'));
183
184 $in = $this->__createInStatement();
185 $where = $this->__createDescriptionWhereCondition();
186 $locate = $this->__createLocateString();
187
188 $query = "SELECT rbac_id,obj_id,obj_type ".
189 $locate.
190 "FROM il_meta_description ".
191 $where." ".$in.' ';
192
193 $res = $this->db->query($query);
194 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
195 {
196 $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
197 }
198
200 }
201}
202?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
__createLocateString()
build locate string in case of AND search
setFields($a_fields)
Set fields to search.
getFilter()
get object type to search in
ilMetaDataSearch(&$qp_obj)
Constructor @access public.
setMode($a_mode)
Define meta elements to search.