ILIAS  release_8 Revision v8.24
class.ilMetaDataSearch.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 private string $mode = '';
40
41
42 public function setMode(string $a_mode): void
43 {
44 $this->mode = $a_mode;
45 }
46 public function getMode(): string
47 {
48 return $this->mode;
49 }
50
51
52 public function performSearch(): ilSearchResult
53 {
54 switch ($this->getMode()) {
55 case 'keyword':
56 return $this->__searchKeywords();
57
58 case 'contribute':
59 return $this->__searchContribute();
60
61 case 'title':
62 return $this->__searchTitles();
63
64 case 'description':
65 return $this->__searchDescriptions();
66 }
67 throw new InvalidArgumentException('ilMDSearch: no mode given');
68 }
69
70
71
72 // Private
73 public function __createInStatement(): string
74 {
75 if (!$this->getFilter()) {
76 return '';
77 } else {
78 $type = "('";
79 $type .= implode("','", $this->getFilter());
80 $type .= "')";
81 return " AND obj_type IN " . $type;
82 }
83 }
85 {
86 $this->setFields(array('entity'));
87
88 $in = $this->__createInStatement();
89 $where = $this->__createContributeWhereCondition();
90 $locate = $this->__createLocateString();
91
92 $query = "SELECT rbac_id,obj_id,obj_type " .
93 $locate .
94 "FROM il_meta_entity " .
95 $where . " " . $in . ' ';
96
97 $res = $this->db->query($query);
98 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
99 $this->search_result->addEntry(
100 (int) $row->rbac_id,
101 (string) $row->obj_type,
102 $this->__prepareFound($row),
103 (int) $row->obj_id
104 );
105 }
106
108 }
109
110
112 {
113 $this->setFields(array('keyword'));
114
115 $in = $this->__createInStatement();
116 $where = $this->__createKeywordWhereCondition();
117 $locate = $this->__createLocateString();
118
119 $query = "SELECT rbac_id,obj_id,obj_type " .
120 $locate .
121 "FROM il_meta_keyword " .
122 $where . " " . $in . ' ';
123
124 $res = $this->db->query($query);
125 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
126 $this->search_result->addEntry(
127 (int) $row->rbac_id,
128 (string) $row->obj_type,
129 $this->__prepareFound($row),
130 (int) $row->obj_id
131 );
132 }
134 }
136 {
137 $this->setFields(array('title'));
138
139 $in = $this->__createInStatement();
140 $where = $this->__createTitleWhereCondition();
141 $locate = $this->__createLocateString();
142
143 $query = "SELECT rbac_id,obj_id,obj_type " .
144 $locate .
145 "FROM il_meta_general " .
146 $where . " " . $in . ' ';
147
148 $res = $this->db->query($query);
149 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
150 $this->search_result->addEntry(
151 (int) $row->rbac_id,
152 (string) $row->obj_type,
153 $this->__prepareFound($row),
154 (int) $row->obj_id
155 );
156 }
158 }
160 {
161 $this->setFields(array('description'));
162
163 $in = $this->__createInStatement();
164 $where = $this->__createDescriptionWhereCondition();
165 $locate = $this->__createLocateString();
166
167 $query = "SELECT rbac_id,obj_id,obj_type " .
168 $locate .
169 "FROM il_meta_description " .
170 $where . " " . $in . ' ';
171
172 $res = $this->db->query($query);
173 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
174 $this->search_result->addEntry(
175 (int) $row->rbac_id,
176 (string) $row->obj_type,
177 $this->__prepareFound($row),
178 (int) $row->obj_id
179 );
180 }
182 }
183}
setFields(array $a_fields)
ilSearchResult $search_result
$res
Definition: ltiservices.php:69
$query
$type