ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilObjectSearch.php
Go to the documentation of this file.
1 <?php
2 
3 declare(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  private ?ilDate $cdate_start_date = null;
40  private ?ilDate $cdate_end_date = null;
41 
42 
43  public function __construct(ilQueryParser $qp_obj)
44  {
45  parent::__construct($qp_obj);
46  $this->setFields(array('title','description'));
47  }
48 
49 
50  public static function raiseContentChanged(int $obj_id): void
51  {
52  global $DIC;
53 
54  $DIC->event()->raise(
55  'components/ILIAS/Search',
56  'contentChanged',
57  [
58  "obj_id" => $obj_id
59  ]
60  );
61  }
62 
63  public function performSearch(): ilSearchResult
64  {
65  $in = $this->__createInStatement();
66  $where = $this->__createWhereCondition();
67 
68 
69 
70  $cdate = '';
71  if ($this->getCreationDateFilterStartDate() && is_null($this->getCreationDateFilterEndDate())) {
72  $cdate = 'AND create_date >= ' . $this->db->quote($this->getCreationDateFilterStartDate()->get(IL_CAL_DATE), 'text') . ' ';
73  } elseif ($this->getCreationDateFilterEndDate() && is_null($this->getCreationDateFilterStartDate())) {
74  $cdate = 'AND create_date <= ' . $this->db->quote($this->getCreationDateFilterEndDate()->get(IL_CAL_DATE), 'text') . ' ';
75  } elseif ($this->getCreationDateFilterStartDate() && $this->getCreationDateFilterEndDate()) {
76  $cdate = 'AND create_date >= ' . $this->db->quote($this->getCreationDateFilterStartDate()->get(IL_CAL_DATE), 'text') . ' ' .
77  'AND create_date <= ' . $this->db->quote($this->getCreationDateFilterEndDate()->get(IL_CAL_DATE), 'text') . ' ';
78  }
79 
80  $locate = $this->__createLocateString();
81 
82  $query = "SELECT obj_id,type " .
83  $locate .
84  "FROM object_data " .
85  $where . " " . $cdate . ' ' . $in . ' ' .
86  "ORDER BY obj_id DESC";
87 
88  ilLoggerFactory::getLogger('src')->debug('Object search query: ' . $query);
89 
90  $res = $this->db->query($query);
91  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
92  $this->search_result->addEntry((int) $row->obj_id, (string) $row->type, $this->__prepareFound($row));
93  }
94  return $this->search_result;
95  }
96 
97 
98 
99  public function __createInStatement(): string
100  {
101  $in = ' AND ' . $this->db->in('type', (array) $this->object_types, false, 'text');
102  if ($this->getIdFilter()) {
103  $in .= ' AND ';
104  $in .= $this->db->in('obj_id', $this->getIdFilter(), false, 'integer');
105  }
106  return $in;
107  }
108 
109 
110  public function setCreationDateFilterStartDate(?ilDate $day): void
111  {
112  $this->cdate_start_date = $day;
113  }
114 
116  {
118  }
119 
120  public function setCreationDateFilterEndDate(?ilDate $day): void
121  {
122  $this->cdate_end_date = $day;
123  }
124 
126  {
127  return $this->cdate_end_date;
128  }
129 }
$res
Definition: ltiservices.php:69
setCreationDateFilterStartDate(?ilDate $day)
static getLogger(string $a_component_id)
Get component logger.
__construct(ilQueryParser $qp_obj)
setFields(array $a_fields)
setCreationDateFilterEndDate(?ilDate $day)
static raiseContentChanged(int $obj_id)
global $DIC
Definition: shib_login.php:25
const IL_CAL_DATE
__construct(Container $dic, ilPlugin $plugin)
ilSearchResult $search_result