ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 );
98 }
99
101 }
102
103
105 {
106 $this->setFields(array('keyword'));
107
108 $in = $this->__createInStatement();
109 $where = $this->__createKeywordWhereCondition();
110 $locate = $this->__createLocateString();
111
112 $query = "SELECT rbac_id,obj_id,obj_type " .
113 $locate .
114 "FROM il_meta_keyword " .
115 $where . " " . $in . ' ';
116
117 $res = $this->db->query($query);
118 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
119 $this->search_result->addEntry(
120 (int) $row->rbac_id,
121 (string) $row->obj_type,
122 $this->__prepareFound($row),
123 (int) $row->obj_id
124 );
125 }
127 }
129 {
130 $this->setFields(array('title'));
131
132 $in = $this->__createInStatement();
133 $where = $this->__createTitleWhereCondition();
134 $locate = $this->__createLocateString();
135
136 $query = "SELECT rbac_id,obj_id,obj_type " .
137 $locate .
138 "FROM il_meta_general " .
139 $where . " " . $in . ' ';
140
141 $res = $this->db->query($query);
142 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
143 $this->search_result->addEntry(
144 (int) $row->rbac_id,
145 (string) $row->obj_type,
146 $this->__prepareFound($row),
147 (int) $row->obj_id
148 );
149 }
151 }
153 {
154 $this->setFields(array('description'));
155
156 $in = $this->__createInStatement();
157 $where = $this->__createDescriptionWhereCondition();
158 $locate = $this->__createLocateString();
159
160 $query = "SELECT rbac_id,obj_id,obj_type " .
161 $locate .
162 "FROM il_meta_description " .
163 $where . " " . $in . ' ';
164
165 $res = $this->db->query($query);
166 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
167 $this->search_result->addEntry(
168 (int) $row->rbac_id,
169 (string) $row->obj_type,
170 $this->__prepareFound($row),
171 (int) $row->obj_id
172 );
173 }
175 }
176}
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