19 declare(strict_types=1);
33 protected \ilDBInterface
$db;
39 $this->db = (
$db) ?: $DIC->database();
40 $this->lom_services = $DIC->learningObjectMetadata();
48 string $title_filter =
"",
49 string $format_filter =
"",
50 string $keyword_filter =
'',
51 string $caption_filter =
"" 55 $query =
"SELECT DISTINCT mep_tree.*, object_data.* " .
56 "FROM mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) " .
57 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ";
59 if ($format_filter !=
"" or $caption_filter !=
'') {
60 $query .=
" JOIN media_item ON (media_item.mob_id = object_data.obj_id) ";
64 " WHERE mep_tree.mep_id = " . $db->
quote($pool_id,
"integer") .
65 " AND object_data.type = " . $db->quote(
"mob",
"text");
68 if (trim($title_filter) !=
"") {
69 $query .=
" AND " . $db->like(
"object_data.title",
"text",
"%" . trim($title_filter) .
"%");
71 if (!in_array($format_filter, [
"",
"mob"])) {
72 $filter = ($format_filter ===
"unknown")
75 $query .=
" AND " . $db->equals(
"media_item.format", $filter,
"text",
true);
77 if (trim($caption_filter)) {
78 $query .=
'AND ' . $db->like(
'media_item.caption',
'text',
'%' . trim($caption_filter) .
'%');
82 " ORDER BY object_data.title";
86 $set = $db->query($query);
87 while ($rec = $db->fetchAssoc($set)) {
88 $obj_ids[] = $rec[
'obj_id'];
89 $rec[
"foreign_id"] = $rec[
"obj_id"];
95 if ($keyword_filter) {
98 foreach ($objs as $obj) {
99 if (in_array($obj[
'foreign_id'],
$res)) {
103 return (array) $filtered;
113 string $title_filter =
"",
114 string $format_filter =
"",
115 string $keyword_filter =
'',
116 string $caption_filter =
"" 119 if (!in_array($format_filter, [
"pg",
""])) {
124 if ($caption_filter !=
"") {
130 $query =
"SELECT DISTINCT mep_tree.*, mep_item.* " .
131 "FROM mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) ";
134 " WHERE mep_tree.mep_id = " . $db->
quote($pool_id,
"integer") .
135 " AND mep_item.type = " . $db->quote(
"pg",
"text");
138 if (trim($title_filter) !=
"") {
139 $query .=
" AND " . $db->like(
"mep_item.title",
"text",
"%" . trim($title_filter) .
"%");
144 $set = $db->query($query);
145 while ($rec = $db->fetchAssoc($set)) {
149 $obj_ids[] = $rec[
'obj_id'];
153 if ($keyword_filter) {
156 foreach ($objs as $obj) {
157 if (in_array($obj[
'obj_id'],
$res)) {
171 string $title_filter =
"",
172 string $format_filter =
"",
173 string $keyword_filter =
"",
174 string $caption_filter =
"" 192 return \ilArrayUtil::sortArray(array_merge($mobs, $snippets),
"title",
"asc");
204 if (trim($keywords) ===
"" || empty($sub_ids)) {
208 $searcher = $this->lom_services->search();
209 $paths = $this->lom_services->paths();
212 foreach (explode(
' ', $keywords) as $keyword) {
213 $basic_clauses[] = $searcher->getClauseFactory()->getBasicClause(
219 $search_clause = $searcher->getClauseFactory()->getJoinedClauses(
225 foreach ($sub_ids as $sub_id) {
226 $filters[] = $searcher->getFilter($pool_id, $sub_id, $type);
229 $search_results = $searcher->execute($search_clause,
null,
null, ...$filters);
230 $filtered_sub_ids = [];
231 foreach ($search_results as $result) {
232 $filtered_sub_ids[] = $result->subID();
234 return $filtered_sub_ids;
quote($value, string $type)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null