ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAdvancedSearchGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
39include_once 'Services/Search/classes/class.ilSearchBaseGUI.php';
40include_once 'Services/MetaData/classes/class.ilMDUtilSelect.php';
41include_once './Services/Search/classes/Lucene/class.ilLuceneAdvancedSearchFields.php';
42
44{
45 const TYPE_LOM = 1;
46 const TYPE_ADV_MD = 2;
47
48 protected $last_section = 'adv_search';
49
50 protected $fields = array();
51
52
53
58 private $options = array();
59
60 protected $tabs_gui;
61
66 public function __construct()
67 {
68 global $DIC;
69
70 $ilTabs = $DIC['ilTabs'];
71
72 $this->tabs_gui = $ilTabs;
73
75
76 $this->lng->loadLanguageModule('meta');
78
80 }
81
82 public function getRootNode()
83 {
84 return ROOT_FOLDER_ID;
85 }
86
87
92 public function executeCommand()
93 {
94 global $DIC;
95
96 $rbacsystem = $DIC['rbacsystem'];
97
98 $next_class = $this->ctrl->getNextClass($this);
99 $cmd = $this->ctrl->getCmd();
100
101 switch ($next_class) {
102 case "ilpropertyformgui":
103
104
105 case 'ilobjectcopygui':
106 $this->prepareOutput();
107 $this->ctrl->setReturn($this, '');
108
109 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
110 $cp = new ilObjectCopyGUI($this);
111 $this->ctrl->forwardCommand($cp);
112 break;
113
114 default:
115 $this->initUserSearchCache();
116 if (!$cmd) {
117 switch ($_SESSION['search_last_sub_section']) {
119 $cmd = "showSavedAdvMDResults";
120 break;
121
122 default:
123 $cmd = "showSavedResults";
124 break;
125 }
126 }
127 $this->prepareOutput();
128 $this->handleCommand($cmd);
129 break;
130 }
131 return true;
132 }
133 public function reset()
134 {
135 $this->initSearchType(self::TYPE_LOM);
136 $this->options = array();
137 $this->search_cache->setQuery(array());
138 $this->search_cache->save();
139 $this->showSearch();
140 }
141
142 public function searchInResults()
143 {
144 $this->initSearchType(self::TYPE_LOM);
145 $this->search_mode = 'in_results';
146 $this->search_cache->setResultPageNumber(1);
147 unset($_SESSION['adv_max_page']);
148 $this->performSearch();
149
150 return true;
151 }
152
156 protected function remoteSearch()
157 {
158 $this->search_cache->setRoot((int) $_POST['root_id']);
159 $this->search_cache->setResultPageNumber(1);
160 $this->search_cache->setQuery(array('lom_content' => ilUtil::stripSlashes($_POST['queryString'])));
161 $this->search_cache->save();
162
163 $this->options = $this->search_cache->getQuery();
164 $this->options['type'] = 'all';
165
166 $this->performSearch();
167 }
168
169
170
171 public function performSearch()
172 {
173 global $DIC;
174
175 $ilUser = $DIC['ilUser'];
176
177 $this->initSearchType(self::TYPE_LOM);
178
179 if (!isset($_GET['page_number']) and $this->search_mode != 'in_results') {
180 unset($_SESSION['adv_max_page']);
181 $this->search_cache->deleteCachedEntries();
182 }
183
184 if (isset($_POST['query'])) {
185 $this->search_cache->setQuery($_POST['query']);
186 }
187
188
189 include_once 'Services/Search/classes/class.ilSearchResult.php';
190 $res = new ilSearchResult();
191
192 if ($res_con = &$this->__performContentSearch()) {
193 $this->__storeEntries($res, $res_con);
194 }
195 if ($res_lan = &$this->__performLanguageSearch()) {
196 $this->__storeEntries($res, $res_lan);
197 }
198 if ($res_gen = &$this->__performGeneralSearch()) {
199 $this->__storeEntries($res, $res_gen);
200 }
201 if ($res_lif = &$this->__performLifecycleSearch()) {
202 $this->__storeEntries($res, $res_lif);
203 }
204 if ($res_con = &$this->__performContributeSearch()) {
205 $this->__storeEntries($res, $res_con);
206 }
207 if ($res_ent = &$this->__performEntitySearch()) {
208 $this->__storeEntries($res, $res_ent);
209 }
210 if ($res_req = &$this->__performRequirementSearch()) {
211 $this->__storeEntries($res, $res_req);
212 }
213 if ($res_for = &$this->__performFormatSearch()) {
214 $this->__storeEntries($res, $res_for);
215 }
216 if ($res_edu = &$this->__performEducationalSearch()) {
217 $this->__storeEntries($res, $res_edu);
218 }
219 if ($res_typ = &$this->__performTypicalAgeRangeSearch()) {
220 $this->__storeEntries($res, $res_typ);
221 }
222 if ($res_rig = &$this->__performRightsSearch()) {
223 $this->__storeEntries($res, $res_rig);
224 }
225 if ($res_cla = &$this->__performClassificationSearch()) {
226 $this->__storeEntries($res, $res_cla);
227 }
228 if ($res_tax = &$this->__performTaxonSearch()) {
229 $this->__storeEntries($res, $res_tax);
230 }
231 if ($res_key = &$this->__performKeywordSearch()) {
232 $this->__storeEntries($res, $res_key);
233 }
234
235 $this->searchAdvancedMD($res);
236
237 if ($this->search_mode == 'in_results') {
238 include_once 'Services/Search/classes/class.ilSearchResult.php';
239
240 $old_result_obj = new ilSearchResult($ilUser->getId());
241 $old_result_obj->read(ADVANCED_MD_SEARCH);
242
243 $res->diffEntriesFromResult($old_result_obj);
244 }
245
246 $res->filter($this->getRootNode(), (ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND));
247 $res->save();
248 $this->showSearch();
249
250 if (!count($res->getResults())) {
251 ilUtil::sendInfo($this->lng->txt('search_no_match'));
252 }
253
254 if ($res->isLimitReached()) {
255 #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
256 #ilUtil::sendInfo($message);
257 }
258
259 $this->addPager($res, 'adv_max_page');
260
261 include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
263 $presentation->setResults($res->getResultsForPresentation());
264 $presentation->setPreviousNext($this->prev_link, $this->next_link);
265
266 if ($presentation->render()) {
267 $this->tpl->setVariable('RESULTS', $presentation->getHTML(true));
268 }
269 return true;
270 }
271
277 protected function initAdvancedMetaDataForm()
278 {
279 if (is_object($this->form)) {
280 return $this->form;
281 }
282
283 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
284 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
285 $this->form = new ilPropertyFormGUI();
286 $this->form->setFormAction($this->ctrl->getFormAction($this, 'performAdvMDSearch'));
287 $this->form->setTitle($this->lng->txt('adv_md_search_title'));
288 $this->form->addCommandButton('performAdvMDSearch', $this->lng->txt('search'));
289 #$this->form->setSubformMode('right');
290
291 $content = new ilTextInputGUI($this->lng->txt('meta_title') . '/' .
292 $this->lng->txt('meta_keyword') . '/' .
293 $this->lng->txt('meta_description'), 'title');
294 $content->setValue($this->options['title']);
295 $content->setSize(30);
296 $content->setMaxLength(255);
297 // $content->setSubformMode('right');
298 $group = new ilRadioGroupInputGUI('', 'title_ao');
299 $group->setValue($this->options['title_ao']);
300 $radio_option = new ilRadioOption($this->lng->txt("search_any_word"), 0);
301 $group->addOption($radio_option);
302 $radio_option = new ilRadioOption($this->lng->txt("search_all_words"), 1);
303 $group->addOption($radio_option);
304 $content->addSubItem($group);
305 $this->form->addItem($content);
306
307 $type = new ilSelectInputGUI($this->lng->txt('type'), 'type');
308 $options['adv_all'] = $this->lng->txt('search_any');
309 foreach (ilAdvancedMDRecord::_getActivatedObjTypes() as $obj_type) {
310 $options[$obj_type] = $this->lng->txt('objs_' . $obj_type);
311 }
312 $type->setOptions($options);
313 $type->setValue($this->options['type']);
314 $this->form->addItem($type);
315
316 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
318 $record_gui->setPropertyForm($this->form);
319 $record_gui->setSearchValues($this->options);
320 $record_gui->parse();
321 }
322
328 protected function performAdvMDSearch()
329 {
330 global $DIC;
331
332 $ilUser = $DIC['ilUser'];
333
334 $this->initSearchType(self::TYPE_ADV_MD);
335 if (!isset($_GET['page_number']) and $this->search_mode != 'in_results') {
336 unset($_SESSION['adv_max_page']);
337 $this->search_cache->delete();
338 }
339
340 include_once 'Services/Search/classes/class.ilSearchResult.php';
341 $res = new ilSearchResult();
342
343 if ($res_tit = &$this->__performTitleSearch()) {
344 $this->__storeEntries($res, $res_tit);
345 }
346 $this->searchAdvancedMD($res);
347
348 if ($this->search_mode == 'in_results') {
349 include_once 'Services/Search/classes/class.ilSearchResult.php';
350
351 $old_result_obj = new ilSearchResult($ilUser->getId());
352 $old_result_obj->read(ADVANCED_MD_SEARCH);
353
354 $res->diffEntriesFromResult($old_result_obj);
355 }
356
357
358 $res->filter($this->getRootNode(), true);
359 $res->save();
360 $this->showAdvMDSearch();
361
362 if (!count($res->getResults())) {
363 ilUtil::sendInfo($this->lng->txt('search_no_match'));
364 }
365
366 if ($res->isLimitReached()) {
367 #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
368 #ilUtil::sendInfo($message);
369 }
370
371 $this->addPager($res, 'adv_max_page');
372
373 include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
375 $presentation->setResults($res->getResultsForPresentation());
376 $presentation->setPreviousNext($this->prev_link, $this->next_link);
377
378 if ($presentation->render()) {
379 $this->tpl->setVariable('RESULTS', $presentation->getHTML(true));
380 }
381 return true;
382 }
383
384
390 public function showAdvMDSearch()
391 {
392 if (isset($_SESSION['search_adv_md'])) {
393 $this->options = $_SESSION['search_adv_md'];
394 }
395 $this->setSubTabs();
396 $this->tabs_gui->setSubTabActive('search_adv_md');
397
398 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.advanced_adv_search.html', 'Services/Search');
399
401 $this->tpl->setVariable('SEARCH_FORM', $this->form->getHTML());
402 return true;
403 }
404
408 protected function initFormSearch()
409 {
410 global $DIC;
411
412 $tree = $DIC['tree'];
413
414 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
415
416 $this->form = new ilPropertyFormGUI();
417 $this->form->setFormAction($this->ctrl->getFormAction($this, 'performSearch'));
418 $this->form->setTitle($this->lng->txt('search_advanced'));
419 $this->form->addCommandButton('performSearch', $this->lng->txt('search'));
420 $this->form->addCommandButton('reset', $this->lng->txt('reset'));
421
422 foreach ($this->fields->getActiveSections() as $definition) {
423 if ($definition['name'] != 'default') {
425 $section->setTitle($definition['name']);
426 $this->form->addItem($section);
427 }
428
429 foreach ($definition['fields'] as $field_name) {
430 if (is_object($element = $this->fields->getFormElement($this->search_cache->getQuery(), $field_name, $this->form))) {
431 $this->form->addItem($element);
432 }
433 }
434 }
435 return true;
436 }
437
438
439
440 public function showSearch()
441 {
442 global $DIC;
443
444 $ilLocator = $DIC['ilLocator'];
445
446 $this->setSubTabs();
447 $this->tabs_gui->setSubTabActive('search_lom');
448
449 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.advanced_search.html', 'Services/Search');
450
451 $this->initFormSearch();
452 $this->tpl->setVariable('SEARCH_FORM', $this->form->getHTML());
453 return true;
454 }
455
456 public function prepareOutput()
457 {
458 global $DIC;
459
460 $ilTabs = $DIC['ilTabs'];
461 $ilHelp = $DIC['ilHelp'];
462
463 parent::prepareOutput();
464
465 $ilHelp->setScreenIdComponent("src");
466
467 $ilTabs->addTab(
468 "search",
469 $this->lng->txt("search"),
470 $this->ctrl->getLinkTargetByClass('ilsearchgui')
471 );
472 $ilTabs->addTab(
473 "adv_search",
474 $this->lng->txt("search_advanced"),
475 $this->ctrl->getLinkTarget($this)
476 );
477 $ilTabs->activateTab("adv_search");
478 }
479
480 // PRIVATE
487 private function showSavedAdvMDResults()
488 {
489 global $DIC;
490
491 $ilUser = $DIC['ilUser'];
492
493 // Read old result sets
494 include_once 'Services/Search/classes/class.ilSearchResult.php';
495
496 $this->initSearchType(self::TYPE_ADV_MD);
497 $result_obj = new ilSearchResult($ilUser->getId());
498 $result_obj->read(ADVANCED_MD_SEARCH);
499
500 $this->showAdvMDSearch();
501
502 // Show them
503 if (count($result_obj->getResults())) {
504 $this->addPager($result_obj, 'adv_max_page');
505
506 include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
508 $presentation->setResults($result_obj->getResultsForPresentation());
509 $presentation->setPreviousNext($this->prev_link, $this->next_link);
510
511 if ($presentation->render()) {
512 $this->tpl->setVariable('RESULTS', $presentation->getHTML(true));
513 }
514 }
515
516 return true;
517 }
518
519
520 public function showSavedResults()
521 {
522 global $DIC;
523
524 $ilUser = $DIC['ilUser'];
525
526 // Read old result sets
527 include_once 'Services/Search/classes/class.ilSearchResult.php';
528
529 $this->initSearchType(self::TYPE_LOM);
530 $result_obj = new ilSearchResult($ilUser->getId());
531 $result_obj->read(ADVANCED_SEARCH);
532
533 $this->showSearch();
534
535 // Show them
536 if (count($result_obj->getResults())) {
537 $this->addPager($result_obj, 'adv_max_page');
538
539 include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
541 $presentation->setResults($result_obj->getResultsForPresentation());
542 $presentation->setPreviousNext($this->prev_link, $this->next_link);
543
544 if ($presentation->render()) {
545 $this->tpl->setVariable('RESULTS', $presentation->getHTML(true));
546 }
547 }
548
549 return true;
550 }
551
552 public function &__performContentSearch()
553 {
554 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
555 include_once 'Services/Search/classes/class.ilQueryParser.php';
556 include_once 'Services/Search/classes/class.ilSearchResult.php';
557
558 if (!$this->options['lom_content']) {
559 return false;
560 }
561
562 $res = new ilSearchResult();
563
564 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_content']));
565 #$query_parser->setCombination($this->options['content_ao']);
566 $query_parser->setCombination(QP_COMBINATION_OR);
567 $query_parser->parse();
568
569 if ($this->options['type'] == 'all' or $this->options['type'] == 'lms') {
570 // LM content search
571 $lm_search = &ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
572 $res_cont = &$lm_search->performSearch();
573 $res->mergeEntries($res_cont);
574 }
575 if ($this->options['type'] == 'all' or $this->options['type'] == 'tst') {
576 $tst_search = &ilObjectSearchFactory::_getTestSearchInstance($query_parser);
577 $res_tes = &$tst_search->performSearch();
578 $res->mergeEntries($res_tes);
579 }
580 if ($this->options['type'] == 'all' or $this->options['type'] == 'mep') {
581 $med_search = &ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
582 $res_med = &$med_search->performSearch();
583 $res->mergeEntries($res_med);
584 }
585 if ($this->options['type'] == 'all' or $this->options['type'] == 'glo') {
587 $res_glo = &$glo_search->performSearch();
588 $res->mergeEntries($res_glo);
589 }
590 if ($this->options['type'] == 'all' or $this->options['type'] == 'webr') {
591 $web_search = &ilObjectSearchFactory::_getWebresourceSearchInstance($query_parser);
592 $res_web = &$web_search->performSearch();
593 $res->mergeEntries($res_web);
594 }
595 if ($tit_res = $this->__performTitleSearch()) {
596 $res->mergeEntries($tit_res);
597 }
598
599 return $res;
600 }
601
602
603 public function &__performTitleSearch()
604 {
605 if (!$this->options['lom_content']) {
606 return false;
607 }
608
609 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
610 include_once 'Services/Search/classes/class.ilQueryParser.php';
611
612 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_content']));
613 #$query_parser->setCombination($this->options['title_ao']);
614 $query_parser->setCombination(QP_COMBINATION_OR);
615 $query_parser->parse();
616 $meta_search = &ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
617
618 $meta_search->setFilter($this->filter);
619 $meta_search->setMode('title_description');
620 $meta_search->setOptions($this->options);
621 $res_tit = &$meta_search->performSearch();
622
623 $meta_search->setMode('keyword_all');
624 $res_key = &$meta_search->performSearch();
625
626 // merge them
627 $res_tit->mergeEntries($res_key);
628
629
630 return $res_tit;
631 }
632
633
634
635 public function &__performGeneralSearch()
636 {
637 if (!$this->options['lom_coverage'] and !$this->options['lom_structure']) {
638 return false;
639 }
640
641 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
642 include_once 'Services/Search/classes/class.ilQueryParser.php';
643
644 if ($this->options['lom_coverage']) {
645 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_coverage']));
646 #$query_parser->setCombination($this->options['coverage_ao']);
647 $query_parser->setCombination(QP_COMBINATION_OR);
648 $query_parser->parse();
649 } else {
650 $query_parser = new ilQueryParser('');
651 }
652 $meta_search = &ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
653 $meta_search->setFilter($this->filter);
654 $meta_search->setMode('general');
655 $meta_search->setOptions($this->options);
656 $res = &$meta_search->performSearch();
657
658 return $res;
659 }
660
661 public function &__performLifecycleSearch()
662 {
663 // Return if 'any'
664 if (!$this->options['lom_status'] and !$this->options['lom_version']) {
665 return false;
666 }
667 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
668 include_once 'Services/Search/classes/class.ilQueryParser.php';
669
670 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_version']));
671 #$query_parser->setCombination($this->options['version_ao']);
672 $query_parser->setCombination(QP_COMBINATION_OR);
673 $query_parser->parse();
674
675 $meta_search = &ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
676 $meta_search->setFilter($this->filter);
677 $meta_search->setMode('lifecycle');
678 $meta_search->setOptions($this->options);
679 $res = &$meta_search->performSearch();
680
681 return $res;
682 }
683 public function &__performLanguageSearch()
684 {
685 if (!$this->options['lom_language']) {
686 return false;
687 }
688 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
689 include_once 'Services/Search/classes/class.ilQueryParser.php';
690
691
693 $meta_search->setFilter($this->filter);
694 $meta_search->setMode('language');
695 $meta_search->setOptions($this->options);
696 $res = &$meta_search->performSearch();
697
698 return $res;
699 }
700 public function &__performContributeSearch()
701 {
702 if (!strlen($this->options['lom_role'])) {
703 return false;
704 }
705 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
706 include_once 'Services/Search/classes/class.ilQueryParser.php';
707
708
710 $meta_search->setFilter($this->filter);
711 $meta_search->setMode('contribute');
712 $meta_search->setOptions($this->options);
713 $res = &$meta_search->performSearch();
714
715 return $res;
716 }
717 public function &__performEntitySearch()
718 {
719 // Return if 'any'
720 if (!$this->options['lom_role_entry']) {
721 return false;
722 }
723
724 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
725 include_once 'Services/Search/classes/class.ilQueryParser.php';
726
727 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_role_entry']));
728 #$query_parser->setCombination($this->options['entity_ao']);
729 $query_parser->setCombination(QP_COMBINATION_OR);
730 $query_parser->parse();
731
732 $meta_search = &ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
733 $meta_search->setFilter($this->filter);
734 $meta_search->setMode('entity');
735 $meta_search->setOptions($this->options);
736 $res = &$meta_search->performSearch();
737
738 return $res;
739 }
740
741
742 public function &__performRequirementSearch()
743 {
744 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
745 include_once 'Services/Search/classes/class.ilQueryParser.php';
746
747
749 $meta_search->setFilter($this->filter);
750 $meta_search->setMode('requirement');
751 $meta_search->setOptions($this->options);
752 $res = &$meta_search->performSearch();
753
754 return $res;
755 }
756 public function &__performFormatSearch()
757 {
758 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
759 include_once 'Services/Search/classes/class.ilQueryParser.php';
760
761
763 $meta_search->setFilter($this->filter);
764 $meta_search->setMode('format');
765 $meta_search->setOptions($this->options);
766 $res = &$meta_search->performSearch();
767
768 return $res;
769 }
770 public function &__performEducationalSearch()
771 {
772 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
773 include_once 'Services/Search/classes/class.ilQueryParser.php';
774
775
777 $meta_search->setFilter($this->filter);
778 $meta_search->setMode('educational');
779 $meta_search->setOptions($this->options);
780 $res = &$meta_search->performSearch();
781
782 return $res;
783 }
785 {
786 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
787 include_once 'Services/Search/classes/class.ilQueryParser.php';
788
789
791 $meta_search->setFilter($this->filter);
792 $meta_search->setMode('typical_age_range');
793 $meta_search->setOptions($this->options);
794 $res = &$meta_search->performSearch();
795
796 return $res;
797 }
798 public function &__performRightsSearch()
799 {
800 if (!$this->options['lom_copyright'] and !$this->options['lom_costs']) {
801 return false;
802 }
803 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
804 include_once 'Services/Search/classes/class.ilQueryParser.php';
805
806
808 $meta_search->setFilter($this->filter);
809 $meta_search->setMode('rights');
810 $meta_search->setOptions($this->options);
811 $res = &$meta_search->performSearch();
812
813 return $res;
814 }
815
817 {
818 // Return if 'any'
819 if (!$this->options['lom_purpose']) {
820 return false;
821 }
822 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
823 include_once 'Services/Search/classes/class.ilQueryParser.php';
824
825
827 $meta_search->setFilter($this->filter);
828 $meta_search->setMode('classification');
829 $meta_search->setOptions($this->options);
830 $res = &$meta_search->performSearch();
831
832 return $res;
833 }
834
835 public function &__performTaxonSearch()
836 {
837 // Return if 'any'
838 if (!$this->options['lom_taxon']) {
839 return false;
840 }
841 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
842 include_once 'Services/Search/classes/class.ilQueryParser.php';
843
844 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_taxon']));
845 $query_parser->setCombination(QP_COMBINATION_OR);
846 $query_parser->parse();
847
848 $meta_search = &ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
849 $meta_search->setFilter($this->filter);
850 $meta_search->setMode('taxon');
851 $meta_search->setOptions($this->options);
852 $res = &$meta_search->performSearch();
853
854 return $res;
855 }
856
864 private function searchAdvancedMD($res)
865 {
866 $this->initFormSearch();
867
868 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
869 foreach (array_keys($this->options) as $key) {
870 if (substr($key, 0, 3) != 'adv') {
871 continue;
872 }
873
874 // :TODO: ?
875 if (!$key) {
876 continue;
877 }
878
879 $field_id = substr($key, 4);
881
882 $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false);
883 $field_form->setElementId("query[" . $key . "]");
884 $field_form->setForm($this->form);
885
886 // reload search values
887 $field_form->importFromPost($this->options);
888 $field_form->validate();
889
890 $parser_value = $field->getSearchQueryParserValue($field_form);
891
892 include_once 'Services/Search/classes/class.ilQueryParser.php';
893 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
894 $adv_md_search = ilObjectSearchFactory::_getAdvancedMDSearchInstance(new ilQueryParser($parser_value));
895 $adv_md_search->setFilter($this->filter);
896 $adv_md_search->setDefinition($field);
897 $adv_md_search->setSearchElement($field_form);
898 $res_field = $adv_md_search->performSearch();
899 if ($res_field instanceof ilSearchResult) {
900 $this->__storeEntries($res, $res_field);
901 }
902 }
903 }
904
905 public function &__performKeywordSearch()
906 {
907 // Return if 'any'
908 if (!$this->options['lom_keyword']) {
909 return false;
910 }
911 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
912 include_once 'Services/Search/classes/class.ilQueryParser.php';
913
914 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_keyword']));
915 #$query_parser->setCombination($this->options['keyword_ao']);
916 $query_parser->setCombination(QP_COMBINATION_OR);
917 $query_parser->parse();
918
919 $meta_search = &ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
920 $meta_search->setFilter($this->filter);
921 $meta_search->setMode('keyword');
922 $meta_search->setOptions($this->options);
923 $res = &$meta_search->performSearch();
924
925 return $res;
926 }
927
928 public function __setSearchOptions(&$post_vars)
929 {
930 if (isset($_POST['cmd']['performSearch'])) {
931 $this->options = $_SESSION['search_adv'] = $_POST['query'];
932 } elseif (isset($_POST['cmd']['performAdvMDSearch'])) {
933 $this->options = $_SESSION['search_adv_md'] = $_POST;
934 } else {
935 $this->options = $_SESSION['search_adv'];
936 }
937
938 $_POST['result'] = $_POST['id'];
939
940 $this->filter = array();
941
942 $this->options['type'] = 'all';
943 switch ($this->options['type']) {
944 case 'cat':
945 $this->filter[] = 'cat';
946 break;
947
948 case 'webr':
949 $this->filter[] = 'webr';
950 break;
951
952 case 'lms':
953 $this->filter[] = 'lm';
954 $this->filter[] = 'dbk';
955 $this->filter[] = 'pg';
956 $this->filter[] = 'st';
957 $this->filter[] = 'sahs';
958 $this->filter[] = 'htlm';
959 break;
960
961 case 'glo':
962 $this->filter[] = 'glo';
963 break;
964
965 case 'tst':
966 $this->filter[] = 'tst';
967 $this->filter[] = 'svy';
968 $this->filter[] = 'qpl';
969 $this->filter[] = 'spl';
970 break;
971
972 case 'mep':
973 $this->filter[] = 'mep';
974 break;
975
976 case 'crs':
977 $this->filter[] = 'crs';
978 break;
979
980 case 'file':
981 $this->filter[] = 'file';
982 break;
983
984 case 'adv_all':
985 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
987 break;
988
989 case 'all':
990 default:
991 $this->filter[] = 'sess';
992 $this->filter[] = 'webr';
993 $this->filter[] = 'crs';
994 $this->filter[] = 'mep';
995 $this->filter[] = 'tst';
996 $this->filter[] = 'svy';
997 $this->filter[] = 'qpl';
998 $this->filter[] = 'spl';
999 $this->filter[] = 'glo';
1000 $this->filter[] = 'lm';
1001 $this->filter[] = 'dbk';
1002 $this->filter[] = 'pg';
1003 $this->filter[] = 'st';
1004 $this->filter[] = 'sahs';
1005 $this->filter[] = 'htlm';
1006 $this->filter[] = 'file';
1007 }
1008 return true;
1009 }
1010
1011 public function __getFilterSelect()
1012 {
1013 $options = array('all' => $this->lng->txt('search_any'),
1014 'crs' => $this->lng->txt('objs_crs'),
1015 'lms' => $this->lng->txt('obj_lrss'),
1016 'glo' => $this->lng->txt('objs_glo'),
1017 'mep' => $this->lng->txt('objs_mep'),
1018 'tst' => $this->lng->txt('search_tst_svy'),
1019 'file' => $this->lng->txt('objs_file'),
1020 'webr' => $this->lng->txt('objs_webr'),
1021 'sess' => $this->lng->txt('objs_sess')
1022 );
1023
1024
1025 return ilUtil::formSelect($this->options['type'], 'search_adv[type]', $options, false, true);
1026 }
1027
1028
1029 public function __storeEntries($res, $new_res)
1030 {
1031 if ($this->stored == false) {
1032 $res->mergeEntries($new_res);
1033 $this->stored = true;
1034
1035 return true;
1036 } else {
1037 $res->intersectEntries($new_res);
1038 return true;
1039 }
1040 }
1041
1048 private function initUserSearchCache()
1049 {
1050 global $DIC;
1051
1052 $ilUser = $DIC['ilUser'];
1053
1054 include_once('Services/Search/classes/class.ilUserSearchCache.php');
1055 $this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
1056 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH);
1057 if ($_GET['page_number']) {
1058 $this->search_cache->setResultPageNumber((int) $_GET['page_number']);
1059 }
1060 if ($_POST['cmd']['performSearch']) {
1061 $this->search_cache->setQuery(ilUtil::stripSlashes($_POST['query']['lomContent']));
1062 $this->search_cache->save();
1063 }
1064 }
1065
1072 public function setSubTabs()
1073 {
1074 global $DIC;
1075
1076 $ilTabs = $DIC['ilTabs'];
1077
1078 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1080 return true;
1081 }
1082 $ilTabs->addSubTabTarget('search_lom', $this->ctrl->getLinkTarget($this, 'showSavedResults'));
1083 #$ilTabs->addSubTabTarget('search_adv_md',$this->ctrl->getLinkTarget($this,'showSavedAdvMDResults'));
1084 }
1085
1093 private function toUnixTime($date, $time = array())
1094 {
1095 return mktime($time['h'], $time['m'], 0, $date['m'], $date['d'], $date['y']);
1096 }
1097
1105 private function initSearchType($type)
1106 {
1107 if ($type == self::TYPE_LOM) {
1108 $_SESSION['search_last_sub_section'] = self::TYPE_LOM;
1109 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH);
1110 } else {
1111 $_SESSION['search_last_sub_section'] = self::TYPE_ADV_MD;
1112 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_MD_SEARCH);
1113 }
1114 }
1115}
$section
Definition: Utf8Test.php:83
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const QP_COMBINATION_OR
const ADVANCED_SEARCH
const ADVANCED_MD_SEARCH
static getInstance()
Get singleton.
static getInstance($a_field_id, $a_type=null, string $language='')
Get definition instance by type.
static getSearchableDefinitionIds()
Get searchable definition ids (performance is key)
static _getActivatedObjTypes()
get activated obj types
showSavedAdvMDResults()
show advanced meta data results
initUserSearchCache()
Init user search cache.
initSearchType($type)
init search type (LOM Search or Advanced meta data search)
searchAdvancedMD($res)
Perform advanced meta data search.
initAdvancedMetaDataForm()
@access protected
__construct()
Constructor @access public.
performAdvMDSearch()
perform advanced meta data search
executeCommand()
Control @access public.
showAdvMDSearch()
Show advanced meta data search.
initFormSearch()
Show search form.
toUnixTime($date, $time=array())
convert input array to unix time
remoteSearch()
Search from main menu.
$options
array of all options select boxes,'and' 'or' and query strings @access public
This class represents a section header in a property form.
static getInstance()
Get singleton instance.
GUI class for the workflow of copying objects.
static _getMediaPoolSearchInstance($query_parser)
get reference of ilFulltextMediapoolSearch
static _getLMContentSearchInstance($query_parser)
get reference of ilFulltextLMContentSearch
static _getWebresourceSearchInstance($query_parser)
get reference of ilFulltextWebresourceSearch
static _getTestSearchInstance($query_parser)
get reference of ilFulltextTestSearch
static _getAdvancedMDSearchInstance($query_parser)
get advanced meta data search instance
static _getGlossaryDefinitionSearchInstance($query_parser)
get reference of ilFulltextGlossaryDefinitionSearch
static _getAdvancedSearchInstance($query_parser)
get reference of ilFulltextAdvancedSearch
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
addPager($result, $a_session_key)
Add Pager.
handleCommand($a_cmd)
Handle command.
Presentation of search results using object list gui.
This class represents a selection list property in a property form.
This class represents a text property in a property form.
static _getInstance($a_usr_id)
Get singleton instance.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
const ROOT_FOLDER_ID
Definition: constants.php:30
filter()
Definition: filter.php:2
global $DIC
Definition: goto.php:24
$errors fields
Definition: imgupload.php:51
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
foreach($_POST as $key=> $value) $res