ILIAS  release_8 Revision v8.24
class.ilObjectSearch.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4/*
5 +-----------------------------------------------------------------------------+
6 | ILIAS open source |
7 +-----------------------------------------------------------------------------+
8 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
9 | |
10 | This program is free software; you can redistribute it and/or |
11 | modify it under the terms of the GNU General Public License |
12 | as published by the Free Software Foundation; either version 2 |
13 | of the License, or (at your option) any later version. |
14 | |
15 | This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | GNU General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU General Public License |
21 | along with this program; if not, write to the Free Software |
22 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 +-----------------------------------------------------------------------------+
24*/
25
38{
39 public const CDATE_OPERATOR_BEFORE = 1;
40 public const CDATE_OPERATOR_AFTER = 2;
41 public const CDATE_OPERATOR_ON = 3;
42
43 private ?int $cdate_operator = null;
44 private ?ilDate $cdate_date = null;
45
46
47 public function __construct(ilQueryParser $qp_obj)
48 {
49 parent::__construct($qp_obj);
50 $this->setFields(array('title','description'));
51 }
52
53
54
55
56 public function performSearch(): ilSearchResult
57 {
58 $in = $this->__createInStatement();
59 $where = $this->__createWhereCondition();
60
61
62
63 $cdate = '';
64 if ($this->getCreationDateFilterDate() instanceof ilDate) {
65 if ($this->getCreationDateFilterOperator()) {
66 switch ($this->getCreationDateFilterOperator()) {
68 $cdate = 'AND create_date >= ' . $this->db->quote($this->getCreationDateFilterDate()->get(IL_CAL_DATE), 'text') . ' ';
69 break;
70
72 $cdate = 'AND create_date <= ' . $this->db->quote($this->getCreationDateFilterDate()->get(IL_CAL_DATE), 'text') . ' ';
73 break;
74
76 $cdate = 'AND ' . $this->db->like(
77 'create_date',
78 'text',
79 $this->getCreationDateFilterDate()->get(IL_CAL_DATE) . '%'
80 );
81 break;
82 }
83 }
84 }
85
86 $locate = $this->__createLocateString();
87
88 $query = "SELECT obj_id,type " .
89 $locate .
90 "FROM object_data " .
91 $where . " " . $cdate . ' ' . $in . ' ' .
92 "ORDER BY obj_id DESC";
93
94 ilLoggerFactory::getLogger('src')->debug('Object search query: ' . $query);
95
96 $res = $this->db->query($query);
97 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
98 $this->search_result->addEntry((int) $row->obj_id, (string) $row->type, $this->__prepareFound($row));
99 }
101 }
102
103
104
105 public function __createInStatement(): string
106 {
107 $in = ' AND ' . $this->db->in('type', (array) $this->object_types, false, 'text');
108 if ($this->getIdFilter()) {
109 $in .= ' AND ';
110 $in .= $this->db->in('obj_id', $this->getIdFilter(), false, 'integer');
111 }
112 return $in;
113 }
114
115
116 public function setCreationDateFilterDate(ilDate $day): void
117 {
118 $this->cdate_date = $day;
119 }
120
121 public function setCreationDateFilterOperator(int $a_operator): void
122 {
123 $this->cdate_operator = $a_operator;
124 }
125
127 {
128 return $this->cdate_date;
129 }
130
132 {
134 }
135}
const IL_CAL_DATE
setFields(array $a_fields)
ilSearchResult $search_result
Class for single dates.
static getLogger(string $a_component_id)
Get component logger.
setCreationDateFilterDate(ilDate $day)
setCreationDateFilterOperator(int $a_operator)
__construct(ilQueryParser $qp_obj)
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$query