ILIAS  release_8 Revision v8.24
class.ilAdvancedSearchGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
37{
38 public const TYPE_LOM = 1;
39 public const TYPE_ADV_MD = 2;
40
41 protected string $last_section = 'adv_search';
42
44
45
46
47
48 private bool $stored = false;
49 private array $options = array();
50 protected array $filter = array();
51
54
55 public function __construct()
56 {
57 global $DIC;
58
59 $this->tabs_gui = $DIC->tabs();
60 $this->help_gui = $DIC->help();
61
62
64
65 $this->lng->loadLanguageModule('meta');
67
68 $this->__setSearchOptions();
69 }
70
71 public function getRootNode(): int
72 {
73 return ROOT_FOLDER_ID;
74 }
75
76
77 public function executeCommand(): bool
78 {
79 $next_class = $this->ctrl->getNextClass($this);
80 $cmd = $this->ctrl->getCmd();
81
82 switch ($next_class) {
83 case "ilpropertyformgui":
84
85
86 case 'ilobjectcopygui':
87 $this->prepareOutput();
88 $this->ctrl->setReturn($this, '');
89
90 $cp = new ilObjectCopyGUI($this);
91 $this->ctrl->forwardCommand($cp);
92 break;
93
94 default:
95 $this->initUserSearchCache();
96 if (!$cmd) {
97 $last_sub_section = (int) ilSession::get('search_last_sub_section');
98 switch ($last_sub_section) {
100 $cmd = "showSavedAdvMDResults";
101 break;
102
103 default:
104 $cmd = "showSavedResults";
105 break;
106 }
107 }
108 $this->prepareOutput();
109 $this->handleCommand($cmd);
110 break;
111 }
112 return true;
113 }
114 public function reset(): void
115 {
116 $this->initSearchType(self::TYPE_LOM);
117 $this->options = array();
118 $this->search_cache->setQuery(array());
119 $this->search_cache->save();
120 $this->showSearch();
121 }
122
123 public function searchInResults(): bool
124 {
125 $this->initSearchType(self::TYPE_LOM);
126 $this->search_mode = 'in_results';
127 $this->search_cache->setResultPageNumber(1);
128 ilSession::clear('adv_max_page');
129 $this->performSearch();
130
131 return true;
132 }
133
134 protected function remoteSearch(): void
135 {
136 $root_id = 0;
137 if ($this->http->wrapper()->post()->has('root_id')) {
138 $root_id = $this->http->wrapper()->post()->retrieve(
139 'root_id',
140 $this->refinery->kindlyTo()->int()
141 );
142 }
143 $queryString = '';
144 if ($this->http->wrapper()->post()->has('queryString')) {
145 $queryString = $this->http->wrapper()->post()->retrieve(
146 'queryString',
147 $this->refinery->kindlyTo()->string()
148 );
149 }
150 $this->search_cache->setRoot($root_id);
151 $this->search_cache->setResultPageNumber(1);
152 $this->search_cache->setQuery(array('lom_content' => $queryString));
153 $this->search_cache->save();
154
155 $this->options = $this->search_cache->getQuery();
156 $this->options['type'] = 'all';
157
158 $this->performSearch();
159 }
160
161
162
163 public function performSearch(): bool
164 {
165 global $DIC;
166 $this->initSearchType(self::TYPE_LOM);
167 $page_number = $this->initPageNumberFromQuery();
168 if (!$page_number and $this->search_mode != 'in_results') {
169 ilSession::clear('adv_max_page');
170 $this->search_cache->deleteCachedEntries();
171 }
172
173 if ($this->http->wrapper()->post()->has('query')) {
174 $this->search_cache->setQuery(
175 $this->getQueryFromPost()
176 );
177 }
178 $res = new ilSearchResult();
179 if ($res_con = $this->__performContentSearch()) {
180 $this->__storeEntries($res, $res_con);
181 }
182 if ($res_lan = $this->__performLanguageSearch()) {
183 $this->__storeEntries($res, $res_lan);
184 }
185 if ($res_gen = $this->__performGeneralSearch()) {
186 $this->__storeEntries($res, $res_gen);
187 }
188 if ($res_lif = $this->__performLifecycleSearch()) {
189 $this->__storeEntries($res, $res_lif);
190 }
191 if ($res_con = $this->__performContributeSearch()) {
192 $this->__storeEntries($res, $res_con);
193 }
194 if ($res_ent = $this->__performEntitySearch()) {
195 $this->__storeEntries($res, $res_ent);
196 }
197 if ($res_req = $this->__performRequirementSearch()) {
198 $this->__storeEntries($res, $res_req);
199 }
200 if ($res_for = $this->__performFormatSearch()) {
201 $this->__storeEntries($res, $res_for);
202 }
203 if ($res_edu = $this->__performEducationalSearch()) {
204 $this->__storeEntries($res, $res_edu);
205 }
206 if ($res_typ = $this->__performTypicalAgeRangeSearch()) {
207 $this->__storeEntries($res, $res_typ);
208 }
209 if ($res_rig = $this->__performRightsSearch()) {
210 $this->__storeEntries($res, $res_rig);
211 }
212 if ($res_cla = $this->__performClassificationSearch()) {
213 $this->__storeEntries($res, $res_cla);
214 }
215 if ($res_tax = $this->__performTaxonSearch()) {
216 $this->__storeEntries($res, $res_tax);
217 }
218 if ($res_key = $this->__performKeywordSearch()) {
219 $this->__storeEntries($res, $res_key);
220 }
221
222 $this->searchAdvancedMD($res);
223
224 if ($this->search_mode == 'in_results') {
225 $old_result_obj = new ilSearchResult($this->user->getId());
226 $old_result_obj->read(ilUserSearchCache::ADVANCED_MD_SEARCH);
227
228 $res->diffEntriesFromResult();
229 }
230
231 $res->filter($this->getRootNode(), (ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND));
232 $res->save();
233 $this->showSearch();
234
235 if (!count($res->getResults())) {
236 $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_no_match'));
237 }
238
239 if ($res->isLimitReached()) {
240 #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
241 #ilUtil::sendInfo($message);
242 }
243
244 $this->addPager($res, 'adv_max_page');
245
247 $presentation->setResults($res->getResultsForPresentation());
248 $presentation->setPreviousNext($this->prev_link, $this->next_link);
249
250 if ($presentation->render()) {
251 $this->tpl->setVariable('RESULTS', $presentation->getHTML());
252 }
253 return true;
254 }
255
256
258 {
259 if (is_object($this->form)) {
260 return $this->form;
261 }
262 $this->form = new ilPropertyFormGUI();
263 $this->form->setFormAction($this->ctrl->getFormAction($this, 'performAdvMDSearch'));
264 $this->form->setTitle($this->lng->txt('adv_md_search_title'));
265 $this->form->addCommandButton('performAdvMDSearch', $this->lng->txt('search'));
266 #$this->form->setSubformMode('right');
267
268 $content = new ilTextInputGUI($this->lng->txt('meta_title') . '/' .
269 $this->lng->txt('meta_keyword') . '/' .
270 $this->lng->txt('meta_description'), 'title');
271 $content->setValue($this->options['title']);
272 $content->setSize(30);
273 $content->setMaxLength(255);
274 // $content->setSubformMode('right');
275 $group = new ilRadioGroupInputGUI('', 'title_ao');
276 $group->setValue($this->options['title_ao']);
277 $radio_option = new ilRadioOption($this->lng->txt("search_any_word"), '0');
278 $group->addOption($radio_option);
279 $radio_option = new ilRadioOption($this->lng->txt("search_all_words"), '1');
280 $group->addOption($radio_option);
281 $content->addSubItem($group);
282 $this->form->addItem($content);
283
284 $type = new ilSelectInputGUI($this->lng->txt('type'), 'type');
285 $options['adv_all'] = $this->lng->txt('search_any');
286 foreach (ilAdvancedMDRecord::_getActivatedObjTypes() as $obj_type) {
287 $options[$obj_type] = $this->lng->txt('objs_' . $obj_type);
288 }
289 $type->setOptions($options);
290 $type->setValue($this->options['type']);
291 $this->form->addItem($type);
292
294 $record_gui->setPropertyForm($this->form);
295 $record_gui->setSearchValues($this->options);
296 $record_gui->parse();
297 return null;
298 }
299
300
301 protected function performAdvMDSearch(): bool
302 {
303 $this->initSearchType(self::TYPE_ADV_MD);
304 $page_number = $this->initPageNumberFromQuery();
305 if (!$page_number and $this->search_mode != 'in_results') {
306 ilSession::clear('adv_max_page');
307 $this->search_cache->delete();
308 }
309 $res = new ilSearchResult();
310 if ($res_tit = $this->__performTitleSearch()) {
311 $this->__storeEntries($res, $res_tit);
312 }
313 $this->searchAdvancedMD($res);
314 if ($this->search_mode == 'in_results') {
315 $old_result_obj = new ilSearchResult($this->user->getId());
316 $old_result_obj->read(ilUserSearchCache::ADVANCED_MD_SEARCH);
317
318 $res->diffEntriesFromResult();
319 }
320 $res->filter($this->getRootNode(), true);
321 $res->save();
322 $this->showAdvMDSearch();
323
324 if (!count($res->getResults())) {
325 $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_no_match'));
326 }
327
328 if ($res->isLimitReached()) {
329 #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
330 #ilUtil::sendInfo($message);
331 }
332
333 $this->addPager($res, 'adv_max_page');
334
336 $presentation->setResults($res->getResultsForPresentation());
337 $presentation->setPreviousNext($this->prev_link, $this->next_link);
338
339 if ($presentation->render()) {
340 $this->tpl->setVariable('RESULTS', $presentation->getHTML());
341 }
342 return true;
343 }
344
345
346 public function showAdvMDSearch(): bool
347 {
348 $session_options = ilSession::get('search_adv_md');
349 if ($session_options !== null) {
350 $this->options = $session_options;
351 }
352 $this->setSubTabs();
353 $this->tabs_gui->setSubTabActive('search_adv_md');
354
355 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.advanced_adv_search.html', 'Services/Search');
356
358 $this->tpl->setVariable('SEARCH_FORM', $this->form->getHTML());
359 return true;
360 }
361
362
363 protected function initFormSearch(): bool
364 {
365 $this->form = new ilPropertyFormGUI();
366 $this->form->setFormAction($this->ctrl->getFormAction($this, 'performSearch'));
367 $this->form->setTitle($this->lng->txt('search_advanced'));
368 $this->form->addCommandButton('performSearch', $this->lng->txt('search'));
369 $this->form->addCommandButton('reset', $this->lng->txt('reset'));
370 foreach ($this->fields->getActiveSections() as $definition) {
371 if ($definition['name'] != 'default') {
372 $section = new ilFormSectionHeaderGUI();
373 $section->setTitle($definition['name']);
374 $this->form->addItem($section);
375 }
376
377 foreach ($definition['fields'] as $field_name) {
378 if (is_object($element = $this->fields->getFormElement($this->search_cache->getQuery(), $field_name, $this->form))) {
379 $this->form->addItem($element);
380 }
381 }
382 }
383 return true;
384 }
385
386
387
388 public function showSearch(): bool
389 {
390 $this->setSubTabs();
391 $this->tabs_gui->setSubTabActive('search_lom');
392
393 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.advanced_search.html', 'Services/Search');
394
395 $this->initFormSearch();
396 $this->tpl->setVariable('SEARCH_FORM', $this->form->getHTML());
397 return true;
398 }
399
400 public function prepareOutput(): void
401 {
402 parent::prepareOutput();
403
404 $this->help_gui->setScreenIdComponent("src");
405
406 $this->tabs_gui->addTab(
407 "search",
408 $this->lng->txt("search"),
409 $this->ctrl->getLinkTargetByClass('ilsearchgui')
410 );
411 $this->tabs_gui->addTab(
412 "adv_search",
413 $this->lng->txt("search_advanced"),
414 $this->ctrl->getLinkTarget($this)
415 );
416 $this->tabs_gui->activateTab("adv_search");
417 }
418
419
420 private function showSavedAdvMDResults(): bool
421 {
422 $this->initSearchType(self::TYPE_ADV_MD);
423 $result_obj = new ilSearchResult($this->user->getId());
424 $result_obj->read(ilUserSearchCache::ADVANCED_MD_SEARCH);
425
426 $this->showAdvMDSearch();
427
428 // Show them
429 if (count($result_obj->getResults())) {
430 $this->addPager($result_obj, 'adv_max_page');
431
433 $presentation->setResults($result_obj->getResultsForPresentation());
434 $presentation->setPreviousNext($this->prev_link, $this->next_link);
435
436 if ($presentation->render()) {
437 $this->tpl->setVariable('RESULTS', $presentation->getHTML());
438 }
439 }
440
441 return true;
442 }
443
444
445 public function showSavedResults(): bool
446 {
447 $this->initSearchType(self::TYPE_LOM);
448 $result_obj = new ilSearchResult($this->user->getId());
449 $result_obj->read(ilUserSearchCache::ADVANCED_SEARCH);
450
451 $this->showSearch();
452
453 // Show them
454 if (count($result_obj->getResults())) {
455 $this->addPager($result_obj, 'adv_max_page');
456
458 $presentation->setResults($result_obj->getResultsForPresentation());
459 $presentation->setPreviousNext($this->prev_link, $this->next_link);
460
461 if ($presentation->render()) {
462 $this->tpl->setVariable('RESULTS', $presentation->getHTML());
463 }
464 }
465
466 return true;
467 }
468
470 {
471 if (!($this->options['lom_content'] ?? null)) {
472 return null;
473 }
474
475 $res = new ilSearchResult();
476
477 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_content']));
478 #$query_parser->setCombination($this->options['content_ao']);
479 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR);
480 $query_parser->parse();
481
482 if (!isset($this->options['type'])) {
483 if ($tit_res = $this->__performTitleSearch()) {
484 $res->mergeEntries($tit_res);
485 }
486
487 return $res;
488 }
489
490 if ($this->options['type'] == 'all' or $this->options['type'] == 'lms') {
491 // LM content search
492 $lm_search = ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
493 $res_cont = $lm_search->performSearch();
494 $res->mergeEntries($res_cont);
495 }
496 if ($this->options['type'] == 'all' or $this->options['type'] == 'tst') {
497 $tst_search = ilObjectSearchFactory::_getTestSearchInstance($query_parser);
498 $res_tes = $tst_search->performSearch();
499 $res->mergeEntries($res_tes);
500 }
501 if ($this->options['type'] == 'all' or $this->options['type'] == 'mep') {
502 $med_search = ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
503 $res_med = $med_search->performSearch();
504 $res->mergeEntries($res_med);
505 }
506 if ($this->options['type'] == 'all' or $this->options['type'] == 'glo') {
508 $res_glo = $glo_search->performSearch();
509 $res->mergeEntries($res_glo);
510 }
511 if ($this->options['type'] == 'all' or $this->options['type'] == 'webr') {
512 $web_search = ilObjectSearchFactory::_getWebresourceSearchInstance($query_parser);
513 $res_web = $web_search->performSearch();
514 $res->mergeEntries($res_web);
515 }
516 if ($tit_res = $this->__performTitleSearch()) {
517 $res->mergeEntries($tit_res);
518 }
519
520 return $res;
521 }
522
523
525 {
526 if (!($this->options['lom_content'] ?? null)) {
527 return null;
528 }
529
530
531 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_content']));
532 #$query_parser->setCombination($this->options['title_ao']);
533 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR);
534 $query_parser->parse();
535 $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
536
537 $meta_search->setFilter($this->filter);
538 $meta_search->setMode('title_description');
539 $meta_search->setOptions($this->options);
540 $res_tit = $meta_search->performSearch();
541
542 $meta_search->setMode('keyword_all');
543 $res_key = $meta_search->performSearch();
544
545 // merge them
546 $res_tit->mergeEntries($res_key);
547
548
549 return $res_tit;
550 }
551
552
553
555 {
556 if (
557 !($this->options['lom_coverage'] ?? null) and
558 !($this->options['lom_structure'] ?? null)
559 ) {
560 return null;
561 }
562
563
564 if (($this->options['lom_coverage'] ?? null)) {
565 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_coverage']));
566 #$query_parser->setCombination($this->options['coverage_ao']);
567 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR);
568 $query_parser->parse();
569 } else {
570 $query_parser = new ilQueryParser('');
571 }
572 $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
573 $meta_search->setFilter($this->filter);
574 $meta_search->setMode('general');
575 $meta_search->setOptions($this->options);
576 $res = $meta_search->performSearch();
577
578 return $res;
579 }
580
582 {
583 // Return if 'any'
584 if (
585 !($this->options['lom_status'] ?? null) and
586 !($this->options['lom_version'] ?? null)
587 ) {
588 return null;
589 }
590
591 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_version']));
592 #$query_parser->setCombination($this->options['version_ao']);
593 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR);
594 $query_parser->parse();
595
596 $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
597 $meta_search->setFilter($this->filter);
598 $meta_search->setMode('lifecycle');
599 $meta_search->setOptions($this->options);
600 $res = $meta_search->performSearch();
601
602 return $res;
603 }
605 {
606 if (!($this->options['lom_language'] ?? null)) {
607 return null;
608 }
609
610
612 $meta_search->setFilter($this->filter);
613 $meta_search->setMode('language');
614 $meta_search->setOptions($this->options);
615 $res = $meta_search->performSearch();
616
617 return $res;
618 }
620 {
621 if (!strlen($this->options['lom_role'] ?? '')) {
622 return null;
623 }
624
625
627 $meta_search->setFilter($this->filter);
628 $meta_search->setMode('contribute');
629 $meta_search->setOptions($this->options);
630 $res = $meta_search->performSearch();
631
632 return $res;
633 }
635 {
636 // Return if 'any'
637 if (!($this->options['lom_role_entry'] ?? null)) {
638 return null;
639 }
640
641
642 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_role_entry']));
643 #$query_parser->setCombination($this->options['entity_ao']);
644 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR);
645 $query_parser->parse();
646
647 $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
648 $meta_search->setFilter($this->filter);
649 $meta_search->setMode('entity');
650 $meta_search->setOptions($this->options);
651 $res = $meta_search->performSearch();
652
653 return $res;
654 }
655
656
658 {
660 $meta_search->setFilter($this->filter);
661 $meta_search->setMode('requirement');
662 $meta_search->setOptions($this->options);
663 $res = $meta_search->performSearch();
664
665 return $res;
666 }
668 {
670 $meta_search->setFilter($this->filter);
671 $meta_search->setMode('format');
672 $meta_search->setOptions($this->options);
673 $res = $meta_search->performSearch();
674
675 return $res;
676 }
678 {
680 $meta_search->setFilter($this->filter);
681 $meta_search->setMode('educational');
682 $meta_search->setOptions($this->options);
683 $res = $meta_search->performSearch();
684
685 return $res;
686 }
688 {
690 $meta_search->setFilter($this->filter);
691 $meta_search->setMode('typical_age_range');
692 $meta_search->setOptions($this->options);
693 $res = $meta_search->performSearch();
694
695 return $res;
696 }
698 {
699 if (
700 !($this->options['lom_copyright'] ?? null) and
701 !($this->options['lom_costs'] ?? null)
702 ) {
703 return null;
704 }
705
706
708 $meta_search->setFilter($this->filter);
709 $meta_search->setMode('rights');
710 $meta_search->setOptions($this->options);
711 $res = $meta_search->performSearch();
712
713 return $res;
714 }
715
717 {
718 // Return if 'any'
719 if (!($this->options['lom_purpose'] ?? null)) {
720 return null;
721 }
722
723
725 $meta_search->setFilter($this->filter);
726 $meta_search->setMode('classification');
727 $meta_search->setOptions($this->options);
728 $res = $meta_search->performSearch();
729
730 return $res;
731 }
732
734 {
735 // Return if 'any'
736 if (!($this->options['lom_taxon'] ?? null)) {
737 return null;
738 }
739
740 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_taxon']));
741 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR);
742 $query_parser->parse();
743
744 $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
745 $meta_search->setFilter($this->filter);
746 $meta_search->setMode('taxon');
747 $meta_search->setOptions($this->options);
748 $res = $meta_search->performSearch();
749
750 return $res;
751 }
752
753 private function searchAdvancedMD(ilSearchResult $res): void
754 {
755 $this->initFormSearch();
756
757 foreach (array_keys($this->options) as $key) {
758 if (substr((string) $key, 0, 3) != 'adv') {
759 continue;
760 }
761
762 // :TODO: ?
763 if (!$key) {
764 continue;
765 }
766
767 $field_id = substr($key, 4);
768 $field = ilAdvancedMDFieldDefinition::getInstance((int) $field_id);
769
770 $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false);
771 $field_form->setElementId("query[" . $key . "]");
772 $field_form->setForm($this->form);
773
774 // reload search values
775 $field_form->importFromPost($this->options);
776 $field_form->validate();
777
778 $parser_value = $field->getSearchQueryParserValue($field_form);
779 if (!strlen($parser_value)) {
780 continue;
781 }
782 $adv_md_search = ilObjectSearchFactory::_getAdvancedMDSearchInstance(new ilQueryParser($parser_value));
783 $adv_md_search->setFilter($this->filter);
784 $adv_md_search->setDefinition($field);
785 $adv_md_search->setSearchElement($field_form);
786 $res_field = $adv_md_search->performSearch();
787 $this->__storeEntries($res, $res_field);
788 }
789 }
790
792 {
793 // Return if 'any'
794 if (!($this->options['lom_keyword'] ?? null)) {
795 return null;
796 }
797
798 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_keyword']));
799 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR);
800 $query_parser->parse();
801
802 $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
803 $meta_search->setFilter($this->filter);
804 $meta_search->setMode('keyword');
805 $meta_search->setOptions($this->options);
806 $res = $meta_search->performSearch();
807 return $res;
808 }
809
810 public function __setSearchOptions(): bool
811 {
812 $query = $this->getQueryFromPost();
813
814 $post_cmd = (array) ($this->http->request()->getParsedBody()['cmd'] ?? []);
815
816 if (isset($post_cmd['performSearch'])) {
817 $this->options = $query;
818 ilSession::set('search_adv', $this->options);
819 } elseif (isset($post_cmd['performAdvMDSearch'])) {
820 $this->options = (array) $this->http->request()->getParsedBody();
821 ilSession::set('search_adv_md', $this->options);
822 } else {
823 $this->options = ilSession::get('search_adv') ?? [];
824 }
825 $this->filter = array();
826
827 $this->options['type'] = 'all';
828 switch ($this->options['type']) {
829 case 'cat':
830 $this->filter[] = 'cat';
831 break;
832
833 case 'webr':
834 $this->filter[] = 'webr';
835 break;
836
837 case 'lms':
838 $this->filter[] = 'lm';
839 $this->filter[] = 'dbk';
840 $this->filter[] = 'pg';
841 $this->filter[] = 'st';
842 $this->filter[] = 'sahs';
843 $this->filter[] = 'htlm';
844 break;
845
846 case 'glo':
847 $this->filter[] = 'glo';
848 break;
849
850 case 'tst':
851 $this->filter[] = 'tst';
852 $this->filter[] = 'svy';
853 $this->filter[] = 'qpl';
854 $this->filter[] = 'spl';
855 break;
856
857 case 'mep':
858 $this->filter[] = 'mep';
859 $this->filter[] = 'mob';
860 $this->filter[] = 'mpg';
861 break;
862
863 case 'crs':
864 $this->filter[] = 'crs';
865 break;
866
867 case 'file':
868 $this->filter[] = 'file';
869 break;
870
871 case 'adv_all':
873 break;
874
875 case 'all':
876 default:
877 $this->filter[] = 'cat';
878 $this->filter[] = 'sess';
879 $this->filter[] = 'webr';
880 $this->filter[] = 'crs';
881 $this->filter[] = 'mep';
882 $this->filter[] = 'tst';
883 $this->filter[] = 'svy';
884 $this->filter[] = 'qpl';
885 $this->filter[] = 'spl';
886 $this->filter[] = 'glo';
887 $this->filter[] = 'lm';
888 $this->filter[] = 'dbk';
889 $this->filter[] = 'pg';
890 $this->filter[] = 'st';
891 $this->filter[] = 'sahs';
892 $this->filter[] = 'htlm';
893 $this->filter[] = 'file';
894 $this->filter[] = 'mob';
895 $this->filter[] = 'mpg';
896 }
897 return true;
898 }
899
900 public function __getFilterSelect(): string
901 {
902 $options = array('all' => $this->lng->txt('search_any'),
903 'crs' => $this->lng->txt('objs_crs'),
904 'lms' => $this->lng->txt('obj_lrss'),
905 'glo' => $this->lng->txt('objs_glo'),
906 'mep' => $this->lng->txt('objs_mep'),
907 'tst' => $this->lng->txt('search_tst_svy'),
908 'file' => $this->lng->txt('objs_file'),
909 'webr' => $this->lng->txt('objs_webr'),
910 'sess' => $this->lng->txt('objs_sess')
911 );
912
913
914 return ilLegacyFormElementsUtil::formSelect($this->options['type'], 'search_adv[type]', $options, false, true);
915 }
916
917
918 public function __storeEntries(ilSearchResult $res, ilSearchResult $new_res): bool
919 {
920 if (!$this->stored) {
921 $res->mergeEntries($new_res);
922 $this->stored = true;
923 return true;
924 } else {
925 $res->intersectEntries($new_res);
926 return true;
927 }
928 }
929
930 private function initUserSearchCache(): void
931 {
932 $this->search_cache = ilUserSearchCache::_getInstance($this->user->getId());
933 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH);
934 $page_number = $this->initPageNumberFromQuery();
935 if ($page_number) {
936 $this->search_cache->setResultPageNumber($page_number);
937 }
938 $post_cmd = (array) ($this->http->request()->getParsedBody()['cmd'] ?? []);
939 $post_query = (array) ($this->http->request()->getParsedBody()['query'] ?? []);
940 if ($post_cmd['performSearch'] ?? null) {
941 $this->search_cache->setQuery($post_query['lomContent'] ?? '');
942 $this->search_cache->save();
943 }
944 }
945
946 public function setSubTabs(): bool
947 {
949 return true;
950 }
951 $this->tabs_gui->addSubTabTarget('search_lom', $this->ctrl->getLinkTarget($this, 'showSavedResults'));
952 return true;
953 }
954
955
956 private function toUnixTime(array $date, array $time = array()): int
957 {
958 return mktime($time['h'], $time['m'], 0, $date['m'], $date['d'], $date['y']);
959 }
960
961
962 private function initSearchType(int $type): void
963 {
964 if ($type == self::TYPE_LOM) {
965 ilSession::set('search_last_sub_section', self::TYPE_LOM);
966 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH);
967 } else {
968 ilSession::set('search_last_sub_section', self::TYPE_ADV_MD);
969 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_MD_SEARCH);
970 }
971 }
972
973 private function getQueryFromPost(): array
974 {
975 $query = [];
976 if ($this->http->wrapper()->post()->has('query')) {
977 $query = $this->http->wrapper()->post()->retrieve(
978 'query',
979 $this->refinery->kindlyTo()->dictOf(
980 $this->refinery->byTrying([
981 $this->refinery->kindlyTo()->string(),
982 $this->refinery->kindlyTo()->dictOf(
983 $this->refinery->kindlyTo()->string()
984 )
985 ])
986 )
987 );
988 }
989 return $query;
990 }
991}
static getSearchableDefinitionIds()
Get searchable definition ids (performance is key)
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
static _getActivatedObjTypes()
get activated obj types
searchAdvancedMD(ilSearchResult $res)
ilLuceneAdvancedSearchFields $fields
toUnixTime(array $date, array $time=array())
__storeEntries(ilSearchResult $res, ilSearchResult $new_res)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Help GUI class.
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
GUI class for the workflow of copying objects.
static _getAdvancedSearchInstance(ilQueryParser $query_parser)
static _getGlossaryDefinitionSearchInstance(ilQueryParser $query_parser)
static _getWebresourceSearchInstance(ilQueryParser $query_parser)
static _getAdvancedMDSearchInstance(ilQueryParser $query_parser)
static _getMediaPoolSearchInstance(ilQueryParser $query_parser)
static _getLMContentSearchInstance(ilQueryParser $query_parser)
static _getTestSearchInstance(ilQueryParser $query_parser)
This class represents a property form user interface.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addPager($result, string $a_session_key)
handleCommand(string $a_cmd)
ilPropertyFormGUI $form
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text property in a property form.
static _getInstance(int $a_usr_id)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
$errors fields
Definition: imgupload.php:67
$res
Definition: ltiservices.php:69
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193
form( $class_path, string $cmd)
$query
$type