ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjectSearch.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{
42
43 private $cdate_operator = null;
44 private $cdate_date = null;
45
46
51 function ilObjectSearch(&$qp_obj)
52 {
53 parent::ilAbstractSearch($qp_obj);
54
55 $this->setFields(array('title','description'));
56 }
57
58
59
60
61 function &performSearch()
62 {
63 global $ilDB;
64
65 $in = $this->__createInStatement();
66 $where = $this->__createWhereCondition();
67
68
69
70 $cdate = '';
71 if($this->getCreationDateFilterDate() instanceof ilDate)
72 {
74 {
75 switch($this->getCreationDateFilterOperator())
76 {
78 $cdate = 'AND create_date >= '.$ilDB->quote($this->getCreationDateFilterDate()->get(IL_CAL_DATE),'text').' ';
79 break;
80
82 $cdate = 'AND create_date <= '.$ilDB->quote($this->getCreationDateFilterDate()->get(IL_CAL_DATE),'text').' ';
83 break;
84
86 $cdate = 'AND '.$ilDB->like(
87 'create_date',
88 'text',
89 $this->getCreationDateFilterDate()->get(IL_CAL_DATE).'%'
90 );
91 break;
92 }
93 }
94
95
96 }
97
98 $locate = $this->__createLocateString();
99
100 $query = "SELECT obj_id,type ".
101 $locate.
102 "FROM object_data ".
103 $where." ".$cdate.' '.$in.' '.
104 "ORDER BY obj_id DESC";
105
106 ilLoggerFactory::getLogger('src')->debug('Object search query: '. $query);
107
108 $res = $this->db->query($query);
109 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
110 {
111 $this->search_result->addEntry($row->obj_id,$row->type,$this->__prepareFound($row));
112 }
114 }
115
116
117
118 // Protected can be overwritten in Like or Fulltext classes
120 {
121 global $ilDB;
122
123 $in = ' AND '.$ilDB->in('type',(array) $this->object_types,false,'text');
124 if($this->getIdFilter())
125 {
126 $in .= ' AND ';
127 $in .= $ilDB->in('obj_id',$this->getIdFilter(),false,'integer');
128 }
129 return $in;
130 }
131
132
136 public function setCreationDateFilterDate(ilDate $day)
137 {
138 $this->cdate_date = $day;
139 }
140
141 public function setCreationDateFilterOperator($a_operator)
142 {
143 $this->cdate_operator = $a_operator;
144 }
145
147 {
148 return $this->cdate_date;
149 }
150
152 {
154 }
155}
156?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
const IL_CAL_DATE
getIdFilter()
Get Id filter.
__createLocateString()
build locate string in case of AND search
setFields($a_fields)
Set fields to search.
Class for single dates.
static getLogger($a_component_id)
Get component logger.
setCreationDateFilterDate(ilDate $day)
Set creation date filter.
setCreationDateFilterOperator($a_operator)
ilObjectSearch(&$qp_obj)
Constructor @access public.
global $ilDB