ILIAS  Release_3_10_x_branch Revision 61812
 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  $this->setFields(array('value'));
84 
85  $and = '';
86  if(count($this->getFilter()))
87  {
88  $and = "AND type IN ('".implode("','",$this->getFilter())."')";
89  }
90 
91 
92  switch($this->getDefinition()->getFieldType())
93  {
96  $query = "SELECT amv.obj_id,type ".
97  "FROM adv_md_values AS amv ".
98  "JOIN object_data USING (obj_id) ".
99  "WHERE value >= ".(int) $this->range_start." ".
100  "AND value <= ".(int) $this->range_end." ".
101  "AND field_id = ".$this->db->quote($this->getDefinition()->getFieldId())." ".
102  $and;
103  break;
104 
107  $where = $this->__createWhereCondition();
108  $locate = $this->__createLocateString();
109 
110  $query = "SELECT amv.obj_id,type ".
111  $locate.
112  "FROM adv_md_values as amv ".
113  "JOIN object_data USING(obj_id) ".
114  $where.
115  "AND field_id = ".$this->db->quote($this->getDefinition()->getFieldId())." ".
116  $and;
117  break;
118 
119  }
120 
121  if($query)
122  {
123  $res = $this->db->query($query);
124  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
125  {
126  $this->search_result->addEntry($row->obj_id,$row->type,$this->__prepareFound($row));
127  }
128  }
129  return $this->search_result;
130  }
131 
140  public function setTimeRange($start,$end)
141  {
142  $this->range_start = $start;
143  $this->range_end = $end;
144  }
145 
146 }
147 
148 ?>