ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjectSearch.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
31{
32 private ?ilDate $cdate_start_date = null;
33 private ?ilDate $cdate_end_date = null;
34
35
36 public function __construct(ilQueryParser $qp_obj)
37 {
38 parent::__construct($qp_obj);
39 $this->setFields(array('title','description'));
40 }
41
42
43 public static function raiseContentChanged(int $obj_id): void
44 {
45 global $DIC;
46
47 $DIC->event()->raise(
48 'components/ILIAS/Search',
49 'contentChanged',
50 [
51 "obj_id" => $obj_id
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->getCreationDateFilterStartDate() && is_null($this->getCreationDateFilterEndDate())) {
65 $cdate = 'AND create_date >= ' . $this->db->quote($this->getCreationDateFilterStartDate()->get(IL_CAL_DATE), 'text') . ' ';
66 } elseif ($this->getCreationDateFilterEndDate() && is_null($this->getCreationDateFilterStartDate())) {
67 $cdate = 'AND create_date <= ' . $this->db->quote($this->getCreationDateFilterEndDate()->get(IL_CAL_DATE), 'text') . ' ';
68 } elseif ($this->getCreationDateFilterStartDate() && $this->getCreationDateFilterEndDate()) {
69 $cdate = 'AND create_date >= ' . $this->db->quote($this->getCreationDateFilterStartDate()->get(IL_CAL_DATE), 'text') . ' ' .
70 'AND create_date <= ' . $this->db->quote($this->getCreationDateFilterEndDate()->get(IL_CAL_DATE), 'text') . ' ';
71 }
72
73 $locate = $this->__createLocateString();
74
75 $query = "SELECT obj_id,type " .
76 $locate .
77 "FROM object_data " .
78 $where . " " . $cdate . ' ' . $in . ' ' .
79 "ORDER BY obj_id DESC";
80
81 ilLoggerFactory::getLogger('src')->debug('Object search query: ' . $query);
82
83 $res = $this->db->query($query);
84 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
85 $this->search_result->addEntry((int) $row->obj_id, (string) $row->type, $this->__prepareFound($row));
86 }
88 }
89
90
91
92 public function __createInStatement(): string
93 {
94 $in = ' AND ' . $this->db->in('type', (array) $this->object_types, false, 'text');
95 if ($this->getIdFilter()) {
96 $in .= ' AND ';
97 $in .= $this->db->in('obj_id', $this->getIdFilter(), false, 'integer');
98 }
99 return $in;
100 }
101
102
103 public function setCreationDateFilterStartDate(?ilDate $day): void
104 {
105 $this->cdate_start_date = $day;
106 }
107
109 {
111 }
112
113 public function setCreationDateFilterEndDate(?ilDate $day): void
114 {
115 $this->cdate_end_date = $day;
116 }
117
119 {
121 }
122}
const IL_CAL_DATE
setFields(array $a_fields)
ilSearchResult $search_result
Class for single dates.
static getLogger(string $a_component_id)
Get component logger.
setCreationDateFilterStartDate(?ilDate $day)
setCreationDateFilterEndDate(?ilDate $day)
static raiseContentChanged(int $obj_id)
__construct(ilQueryParser $qp_obj)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26