ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilMetaDataSearch.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
31{
32 private string $mode = '';
33
34
35 public function setMode(string $a_mode): void
36 {
37 $this->mode = $a_mode;
38 }
39 public function getMode(): string
40 {
41 return $this->mode;
42 }
43
44
45 public function performSearch(): ilSearchResult
46 {
47 switch ($this->getMode()) {
48 case 'keyword':
49 return $this->__searchKeywords();
50
51 case 'contribute':
52 return $this->__searchContribute();
53
54 case 'title':
55 return $this->__searchTitles();
56
57 case 'description':
58 return $this->__searchDescriptions();
59 }
60 throw new InvalidArgumentException('ilMDSearch: no mode given');
61 }
62
63
64
65 // Private
66 public function __createInStatement(): string
67 {
68 if (!$this->getFilter()) {
69 return '';
70 } else {
71 $type = "('";
72 $type .= implode("','", $this->getFilter());
73 $type .= "')";
74 return " AND obj_type IN " . $type;
75 }
76 }
78 {
79 $this->setFields(array('entity'));
80
81 $in = $this->__createInStatement();
82 $where = $this->__createContributeWhereCondition();
83 $locate = $this->__createLocateString();
84
85 $query = "SELECT rbac_id,obj_id,obj_type " .
86 $locate .
87 "FROM il_meta_entity " .
88 $where . " " . $in . ' ';
89
90 $res = $this->db->query($query);
91 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
92 $this->search_result->addEntry(
93 (int) $row->rbac_id,
94 (string) $row->obj_type,
95 $this->__prepareFound($row),
96 (int) $row->obj_id,
97 (string) $row->obj_type
98 );
99 }
100
102 }
103
104
106 {
107 $this->setFields(array('keyword'));
108
109 $in = $this->__createInStatement();
110 $where = $this->__createKeywordWhereCondition();
111 $locate = $this->__createLocateString();
112
113 $query = "SELECT rbac_id,obj_id,obj_type " .
114 $locate .
115 "FROM il_meta_keyword " .
116 $where . " " . $in . ' ';
117
118 $res = $this->db->query($query);
119 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
120 $this->search_result->addEntry(
121 (int) $row->rbac_id,
122 (string) $row->obj_type,
123 $this->__prepareFound($row),
124 (int) $row->obj_id,
125 (string) $row->obj_type
126 );
127 }
129 }
131 {
132 $this->setFields(array('title'));
133
134 $in = $this->__createInStatement();
135 $where = $this->__createTitleWhereCondition();
136 $locate = $this->__createLocateString();
137
138 $query = "SELECT rbac_id,obj_id,obj_type " .
139 $locate .
140 "FROM il_meta_general " .
141 $where . " " . $in . ' ';
142
143 $res = $this->db->query($query);
144 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
145 $this->search_result->addEntry(
146 (int) $row->rbac_id,
147 (string) $row->obj_type,
148 $this->__prepareFound($row),
149 (int) $row->obj_id,
150 (string) $row->obj_type
151 );
152 }
154 }
156 {
157 $this->setFields(array('description'));
158
159 $in = $this->__createInStatement();
160 $where = $this->__createDescriptionWhereCondition();
161 $locate = $this->__createLocateString();
162
163 $query = "SELECT rbac_id,obj_id,obj_type " .
164 $locate .
165 "FROM il_meta_description " .
166 $where . " " . $in . ' ';
167
168 $res = $this->db->query($query);
169 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
170 $this->search_result->addEntry(
171 (int) $row->rbac_id,
172 (string) $row->obj_type,
173 $this->__prepareFound($row),
174 (int) $row->obj_id,
175 (string) $row->obj_type
176 );
177 }
179 }
180}
setFields(array $a_fields)
ilSearchResult $search_result
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69