ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAdvancedMDSearch.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 
33 include_once 'Services/Search/classes/class.ilAbstractSearch.php';
34 
36 {
37  protected $definition;
38 
46  public function __construct($query_parser)
47  {
49  }
50 
58  public function setDefinition($a_def)
59  {
60  $this->definition = $a_def;
61  }
62 
69  public function getDefinition()
70  {
71  return $this->definition;
72  }
73 
81  public function performSearch()
82  {
83  global $ilDB;
84 
85  $this->setFields(array('value'));
86 
87  $and = '';
88  if(count($this->getFilter()))
89  {
90  $and = "AND ".$ilDB->in('type',$this->getFilter(),false,'text');
91  }
92 
93 
94  switch($this->getDefinition()->getFieldType())
95  {
98  $query = "SELECT amv.obj_id,type ".
99  "FROM adv_md_values amv ".
100  "JOIN object_data od ON amv.obj_id = od.obj_id ".
101  "WHERE value >= ".$ilDB->quote($this->range_start ,'text')." ".
102  "AND value <= ".$ilDB->quote($this->range_end ,'text')." ".
103  "AND field_id = ".$this->db->quote($this->getDefinition()->getFieldId() ,'integer')." ".
104  $and;
105  break;
106 
109  $where = $this->__createWhereCondition();
110  $locate = $this->__createLocateString();
111 
112  $query = "SELECT amv.obj_id,type ".
113  $locate.
114  "FROM adv_md_values amv ".
115  "JOIN object_data od ON amv.obj_id = od.obj_id ".
116  $where.
117  "AND field_id = ".$this->db->quote($this->getDefinition()->getFieldId() ,'integer')." ".
118  $and;
119  break;
120 
121  }
122 
123  if($query)
124  {
125  $res = $this->db->query($query);
126  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
127  {
128  $this->search_result->addEntry($row->obj_id,$row->type,$this->__prepareFound($row));
129  }
130  }
131  return $this->search_result;
132  }
133 
142  public function setTimeRange($start,$end)
143  {
144  $this->range_start = $start;
145  $this->range_end = $end;
146  }
147 
148 }
149 
150 ?>