ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
35 include_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 
54  function setMode($a_mode)
55  {
56  $this->mode = $a_mode;
57  }
58  function getMode()
59  {
60  return $this->mode;
61  }
62 
63 
64  function &performSearch()
65  {
66  switch($this->getMode())
67  {
68  case 'keyword':
69  return $this->__searchKeywords();
70 
71  case 'contribute':
72  return $this->__searchContribute();
73 
74  case 'title':
75  return $this->__searchTitles();
76 
77  case 'description':
78  return $this->__searchDescriptions();
79 
80  default:
81  echo "ilMDSearch::performSearch() no mode given";
82  return false;
83  }
84  }
85 
86 
87 
88  // Private
90  {
91  if(!$this->getFilter())
92  {
93  return '';
94  }
95  else
96  {
97  $type = "('";
98  $type .= implode("','",$this->getFilter());
99  $type .= "')";
100 
101  $in = " AND obj_type IN ".$type;
102 
103  return $in;
104  }
105  }
107  {
108  $this->setFields(array('entity'));
109 
110  $in = $this->__createInStatement();
111  $where = $this->__createContributeWhereCondition();
112  $locate = $this->__createLocateString();
113 
114  $query = "SELECT rbac_id,obj_id,obj_type ".
115  $locate.
116  "FROM il_meta_entity ".
117  $where." ".$in.' ';
118 
119  $res = $this->db->query($query);
120  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
121  {
122  $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
123  }
124 
125  return $this->search_result;
126  }
127 
128 
129  function __searchKeywords()
130  {
131  $this->setFields(array('keyword'));
132 
133  $in = $this->__createInStatement();
134  $where = $this->__createKeywordWhereCondition();
135  $locate = $this->__createLocateString();
136 
137  $query = "SELECT rbac_id,obj_id,obj_type ".
138  $locate.
139  "FROM il_meta_keyword ".
140  $where." ".$in.' ';
141 
142  $res = $this->db->query($query);
143  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
144  {
145  $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
146  }
147 
148  return $this->search_result;
149  }
150  function __searchTitles()
151  {
152  $this->setFields(array('title'));
153 
154  $in = $this->__createInStatement();
155  $where = $this->__createTitleWhereCondition();
156  $locate = $this->__createLocateString();
157 
158  $query = "SELECT rbac_id,obj_id,obj_type ".
159  $locate.
160  "FROM il_meta_general ".
161  $where." ".$in.' ';
162 
163  $res = $this->db->query($query);
164  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
165  {
166  $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
167  }
168 
169  return $this->search_result;
170  }
172  {
173  $this->setFields(array('description'));
174 
175  $in = $this->__createInStatement();
176  $where = $this->__createDescriptionWhereCondition();
177  $locate = $this->__createLocateString();
178 
179  $query = "SELECT rbac_id,obj_id,obj_type ".
180  $locate.
181  "FROM il_meta_description ".
182  $where." ".$in.' ';
183 
184  $res = $this->db->query($query);
185  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
186  {
187  $this->search_result->addEntry($row->rbac_id,$row->obj_type,$this->__prepareFound($row),$row->obj_id);
188  }
189 
190  return $this->search_result;
191  }
192 }
193 ?>
__createLocateString()
build locate string in case of AND search
setFields($a_fields)
Set fields to search.
getFilter()
get object type to search in
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
setMode($a_mode)
Define meta elements to search.