19declare(strict_types=1);
40 public function setMode(
string $a_mode): void
42 $this->mode = $a_mode;
64 case 'typical_age_range':
70 case 'classification':
97 case 'title_description':
110 throw new InvalidArgumentException(
'ilMDSearch: no valid mode given');
135 $where = $this->__createObjectPropertiesWhereCondition(...
$fields);
138 $query =
"SELECT obj_id,type " .
140 "FROM object_data " .
141 $where .
" " . $and .
' ' .
142 "ORDER BY obj_id DESC";
144 $res = $this->db->query($query);
146 $this->search_result->addEntry(
149 $this->__prepareFound($row)
162 $coverage_query = $general_query =
'';
163 if ($this->options[
'lom_coverage'] ??
null) {
165 $and = $this->__createCoverageAndCondition();
167 $coverage_query =
"SELECT rbac_id,obj_type,obj_id " .
169 "FROM il_meta_coverage " .
173 if ($this->options[
'lom_structure'] ??
null) {
175 $general_query =
"SELECT rbac_id,obj_type,obj_id " .
176 "FROM il_meta_general " .
186 $res = $this->db->query($query);
188 if ($this->options[
'lom_coverage'] ??
null) {
190 if (!in_array(0, $found)) {
191 $this->search_result->addEntry(
193 (
string) $row->obj_type,
196 (
string) $row->obj_type
200 $this->search_result->addEntry(
202 (
string) $row->obj_type,
205 (
string) $row->obj_type
215 if (!($this->options[
'lom_language'] ??
null)) {
219 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_language " .
220 "WHERE language = " . $this->db->quote($this->options[
'lom_language'],
'text') .
" " .
222 "AND parent_type = 'meta_general'";
224 $res = $this->db->query($query);
225 #var_dump("<pre>",$query,"<pre>");
227 $this->search_result->addEntry(
229 (
string) $row->obj_type,
232 (
string) $row->obj_type
240 if (!($this->options[
'lom_role'] ??
null)) {
244 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_contribute " .
245 "WHERE role = " . $this->db->quote($this->options[
'lom_role'],
'text') .
" " .
248 $res = $this->db->query($query);
249 #var_dump("<pre>",$query,"<pre>");
251 $this->search_result->addEntry(
253 (
string) $row->obj_type,
256 (
string) $row->obj_type
267 $where = $this->__createEntityWhereCondition();
270 $query =
"SELECT rbac_id,obj_id,obj_type " .
272 "FROM il_meta_entity " .
273 $where .
" " . $and .
' ';
275 $res = $this->db->query($query);
278 if (!in_array(0, $found)) {
279 $this->search_result->addEntry(
281 (
string) $row->obj_type,
284 (
string) $row->obj_type
296 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_or_composite " .
299 $os_query = $browser_query =
'';
300 if ($this->options[
'lom_operating_system'] ??
null) {
301 $os_query = $query .
" AND type = 'operating system' AND " .
304 if ($this->options[
'lom_browser'] ??
null) {
305 $browser_query = $query .
" AND type = 'browser' AND " .
314 $res = $this->db->query($query);
315 #var_dump("<pre>",$query,"<pre>");
317 $this->search_result->addEntry(
319 (
string) $row->obj_type,
322 (
string) $row->obj_type
330 $query_start =
"SELECT rbac_id,obj_id,obj_type ";
333 $ed_query = $lr_type_query = $end_user_query = $context_query =
'';
335 $ed_query = $query_start .
'FROM il_meta_educational ' . $where . $and;
337 if ($this->options[
'lom_resource'] ??
null) {
338 $where =
" WHERE learning_resource_type = " . $this->db->quote($this->options[
'lom_resource'],
'text');
339 $lr_type_query = $query_start .
'FROM il_meta_lr_type ' . $where . $and;
341 if ($this->options[
'lom_user_role'] ??
null) {
342 $where =
" WHERE intended_end_user_role = " . $this->db->quote($this->options[
'lom_user_role'],
'text');
343 $end_user_query = $query_start .
'FROM il_meta_end_usr_role ' . $where . $and;
345 if ($this->options[
'lom_context'] ??
null) {
346 $where =
" WHERE context = " . $this->db->quote($this->options[
'lom_context'],
'text');
347 $context_query = $query_start .
'FROM il_meta_context ' . $where . $and;
360 $res = $this->db->query($query);
362 $this->search_result->addEntry(
364 (
string) $row->obj_type,
367 (
string) $row->obj_type
376 !($this->options[
'typ_age_1'] ??
null) or
377 !($this->options[
'typ_age_2'] ??
null)
382 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_typical_age_range " .
383 "WHERE typical_age_range_min >= '" . (
int) $this->options[
'typ_age_1'] .
"' " .
384 "AND typical_age_range_max <= '" . (
int) $this->options[
'typ_age_2'] .
"'";
387 $res = $this->db->query($query);
388 #var_dump("<pre>",$query,"<pre>");
390 $this->search_result->addEntry(
392 (string) $row->obj_type,
395 (
string) $row->obj_type
403 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_rights ";
409 $query = $query . $where . $and;
410 $res = $this->db->query($query);
411 #var_dump("<pre>",$query,"<pre>");
413 $this->search_result->addEntry(
415 (string) $row->obj_type,
418 (
string) $row->obj_type
426 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_classification ";
432 $query = $query . $where . $and;
433 $res = $this->db->query($query);
434 #var_dump("<pre>",$query,"<pre>");
436 $this->search_result->addEntry(
438 (string) $row->obj_type,
441 (
string) $row->obj_type
452 $where = $this->__createTaxonWhereCondition();
455 $query =
"SELECT rbac_id,obj_id,obj_type " .
457 "FROM il_meta_taxon " .
458 $where .
" " . $and .
' ';
460 $res = $this->db->query($query);
463 if (!in_array(0, $found)) {
464 $this->search_result->addEntry(
466 (
string) $row->obj_type,
469 (
string) $row->obj_type
482 if ($a_in_classification) {
483 $and .=
" AND parent_type = 'meta_classification' ";
485 $where = $this->__createKeywordWhereCondition();
488 $query =
"SELECT rbac_id,obj_id,obj_type " .
490 "FROM il_meta_keyword " .
491 $where .
" " . $and .
' ';
493 $res = $this->db->query($query);
496 if (!in_array(0, $found) or !$a_in_classification) {
497 $this->search_result->addEntry(
499 (
string) $row->obj_type,
502 (
string) $row->obj_type
514 if ($this->options[
'lom_version'] ??
null) {
515 $where = $this->__createLifecycleWhereCondition();
518 $where =
"WHERE 1 = 1 ";
522 if ($this->options[
'lom_status'] ??
null) {
523 $and .= (
" AND lifecycle_status = " . $this->db->quote($this->options[
'lom_status'],
'text') .
"");
526 $query =
"SELECT rbac_id,obj_id,obj_type " .
528 "FROM il_meta_lifecycle " .
529 $where .
" " . $and .
' ';
531 $res = $this->db->query($query);
534 if (!in_array(0, $found)) {
535 $this->search_result->addEntry(
537 (
string) $row->obj_type,
540 (
string) $row->obj_type
550 if (!($this->options[
'lom_format'] ??
null)) {
554 $query =
"SELECT rbac_id,obj_id,obj_type FROM il_meta_format " .
555 "WHERE format LIKE(" . $this->db->quote($this->options[
'lom_format'],
ilDBConstants::T_TEXT) .
") " .
558 $res = $this->db->query($query);
559 #var_dump("<pre>",$query,"<pre>");
561 $this->search_result->addEntry(
563 (
string) $row->obj_type,
566 (
string) $row->obj_type
579 if ($this->options[
'lom_costs'] ??
null) {
581 $where .= ($and .
"costs = " . $this->db->quote($this->options[
'lom_costs'],
'text') .
" ");
583 if ($this->options[
'lom_copyright'] ??
null) {
585 $where .= ($and .
"cpr_and_or = " . $this->db->quote($this->options[
'lom_copyright'],
'text') .
" ");
595 if ($this->options[
'lom_purpose'] ??
null) {
597 $where .= ($and .
"purpose = " . $this->db->quote($this->options[
'lom_purpose'],
ilDBConstants::T_TEXT) .
" ");
607 if ($this->options[
'lom_interactivity'] ??
null) {
609 $where .= ($and .
"interactivity_type = " . $this->db->quote($this->options[
'lom_interactivity'],
'text') .
" ");
612 ($this->options[
'lom_level_start'] ??
null) or
613 ($this->options[
'lom_level_end'] ??
null)) {
617 (
int) $this->options[
'lom_level_start'],
618 (
int) $this->options[
'lom_level_end'],
619 array(
'VeryLow',
'Low',
'Medium',
'High',
'VeryHigh')
625 ($this->options[
'lom_density_start'] ??
null) or
626 ($this->options[
'lom_density_end'] ??
null)
631 (
int) $this->options[
'lom_density_start'],
632 (
int) $this->options[
'lom_density_end'],
633 array(
'VeryLow',
'Low',
'Medium',
'High',
'VeryHigh')
639 ($this->options[
'lom_difficulty_start'] ??
null) or
640 ($this->options[
'lom_difficulty_end'] ??
null)
645 (
int) $this->options[
'lom_difficulty_start'],
646 (
int) $this->options[
'lom_difficulty_end'],
647 array(
'VeryEasy',
'Easy',
'Medium',
'Difficult',
'VeryDifficult')
661 $a_val2 = $a_val2 ?: count(
$options);
663 if ($a_val1 > $a_val2) {
687 $in .= implode(
"','", $a_fields);
695 $non_empty_queries = [];
696 foreach ($individual_queries as $query) {
698 $non_empty_queries[] = $query;
702 if (count($non_empty_queries) < 2) {
703 return $non_empty_queries[0] ??
'';
707 foreach ($non_empty_queries as $query) {
708 if ($total_query ===
'') {
709 $total_query = $query;
712 $total_query =
"SELECT t1.rbac_id, t1.obj_type, t1.obj_id " .
713 "FROM (" . $total_query .
") AS t1 JOIN (" . $query .
714 ") AS t2 ON t1.rbac_id = t2.rbac_id AND t1.obj_type = t2.obj_type AND t1.obj_id = t2.obj_id";
__prepareFound(object $row)
setFields(array $a_fields)
ilSearchResult $search_result
__searchTypicalAgeRange()
__searchKeyword(bool $a_in_classification=false)
__createClassificationWhere()
__createEducationalWhere()
searchObjectProperties(string ... $fields)
__getInStatement(array $a_fields)
__getDifference(int $a_val1, int $a_val2, array $options)
& __searchTitleDescription()
joinOnRessourceIDs(string ... $individual_queries)
setOptions(array &$options)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...