ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
35 include_once 'Services/Search/classes/class.ilAbstractSearch.php';
36 
38 {
41  const CDATE_OPERATOR_ON = 3;
42 
43  private $cdate_operator = null;
44  private $cdate_date = null;
45 
46 
51  public function __construct(&$qp_obj)
52  {
53  parent::__construct($qp_obj);
54 
55  $this->setFields(array('title','description'));
56  }
57 
58 
59 
60 
61  public 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  if ($this->getCreationDateFilterOperator()) {
73  switch ($this->getCreationDateFilterOperator()) {
74  case self::CDATE_OPERATOR_AFTER:
75  $cdate = 'AND create_date >= ' . $ilDB->quote($this->getCreationDateFilterDate()->get(IL_CAL_DATE), 'text') . ' ';
76  break;
77 
78  case self::CDATE_OPERATOR_BEFORE:
79  $cdate = 'AND create_date <= ' . $ilDB->quote($this->getCreationDateFilterDate()->get(IL_CAL_DATE), 'text') . ' ';
80  break;
81 
82  case self::CDATE_OPERATOR_ON:
83  $cdate = 'AND ' . $ilDB->like(
84  'create_date',
85  'text',
86  $this->getCreationDateFilterDate()->get(IL_CAL_DATE) . '%'
87  );
88  break;
89  }
90  }
91  }
92 
93  $locate = $this->__createLocateString();
94 
95  $query = "SELECT obj_id,type " .
96  $locate .
97  "FROM object_data " .
98  $where . " " . $cdate . ' ' . $in . ' ' .
99  "ORDER BY obj_id DESC";
100 
101  ilLoggerFactory::getLogger('src')->debug('Object search query: ' . $query);
102 
103  $res = $this->db->query($query);
104  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
105  $this->search_result->addEntry($row->obj_id, $row->type, $this->__prepareFound($row));
106  }
107  return $this->search_result;
108  }
109 
110 
111 
112  // Protected can be overwritten in Like or Fulltext classes
113  public function __createInStatement()
114  {
115  global $ilDB;
116 
117  $in = ' AND ' . $ilDB->in('type', (array) $this->object_types, false, 'text');
118  if ($this->getIdFilter()) {
119  $in .= ' AND ';
120  $in .= $ilDB->in('obj_id', $this->getIdFilter(), false, 'integer');
121  }
122  return $in;
123  }
124 
125 
129  public function setCreationDateFilterDate(ilDate $day)
130  {
131  $this->cdate_date = $day;
132  }
133 
134  public function setCreationDateFilterOperator($a_operator)
135  {
136  $this->cdate_operator = $a_operator;
137  }
138 
139  public function getCreationDateFilterDate()
140  {
141  return $this->cdate_date;
142  }
143 
145  {
146  return $this->cdate_operator;
147  }
148 }
__construct(&$qp_obj)
Constructor public.
__createLocateString()
build locate string in case of AND search
setFields($a_fields)
Set fields to search.
Class for single dates.
foreach($_POST as $key=> $value) $res
getIdFilter()
Get Id filter.
setCreationDateFilterDate(ilDate $day)
Set creation date filter.
$query
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
setCreationDateFilterOperator($a_operator)
const IL_CAL_DATE
global $ilDB
static getLogger($a_component_id)
Get component logger.