ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
67 {
68 global $ilTabs;
69
70 $this->tabs_gui = $ilTabs;
71
72 parent::ilSearchBaseGUI();
73
74 $this->lng->loadLanguageModule('meta');
76
78 }
79
80 function getRootNode()
81 {
82 return ROOT_FOLDER_ID;
83 }
84
85
90 function &executeCommand()
91 {
92 global $rbacsystem;
93
94 $next_class = $this->ctrl->getNextClass($this);
95 $cmd = $this->ctrl->getCmd();
96
97 switch($next_class)
98 {
99
100 case 'ilobjectcopygui':
101 $this->prepareOutput();
102
103 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
104 $cp = new ilObjectCopyGUI($this);
105 $this->ctrl->forwardCommand($cp);
106 break;
107
108 default:
109 $this->initUserSearchCache();
110 if(!$cmd)
111 {
112 switch($_SESSION['search_last_sub_section'])
113 {
115 $cmd = "showSavedAdvMDResults";
116 break;
117
118 default:
119 $cmd = "showSavedResults";
120 break;
121 }
122 }
123
124 $this->prepareOutput();
125 $this->handleCommand($cmd);
126 break;
127 }
128 return true;
129 }
130 function reset()
131 {
132 $this->initSearchType(self::TYPE_LOM);
133 $this->options = array();
134 $this->search_cache->setQuery(array());
135 $this->search_cache->save();
136 $this->showSearch();
137 }
138
140 {
141 $this->initSearchType(self::TYPE_LOM);
142 $this->search_mode = 'in_results';
143 $this->search_cache->setResultPageNumber(1);
144 unset($_SESSION['adv_max_page']);
145 $this->performSearch();
146
147 return true;
148 }
149
153 protected function remoteSearch()
154 {
155 $this->search_cache->setRoot((int) $_POST['root_id']);
156 $this->search_cache->setResultPageNumber(1);
157 $this->search_cache->setQuery(array('lom_content' => ilUtil::stripSlashes($_POST['queryString'])));
158 $this->search_cache->save();
159
160 $this->options = $this->search_cache->getQuery();
161 $this->options['type'] = 'all';
162
163 $this->performSearch();
164 }
165
166
167
168 function performSearch()
169 {
170 global $ilUser;
171
172 $this->initSearchType(self::TYPE_LOM);
173
174 if(!isset($_GET['page_number']) and $this->search_mode != 'in_results' )
175 {
176 unset($_SESSION['adv_max_page']);
177 $this->search_cache->deleteCachedEntries();
178 }
179
180 if(isset($_POST['query']))
181 {
182 $this->search_cache->setQuery($_POST['query']);
183 }
184
185
186 include_once 'Services/Search/classes/class.ilSearchResult.php';
187 $res =& new ilSearchResult();
188
189 if($res_con =& $this->__performContentSearch())
190 {
191 $this->__storeEntries($res,$res_con);
192 }
193 if($res_lan =& $this->__performLanguageSearch())
194 {
195 $this->__storeEntries($res,$res_lan);
196 }
197 if($res_gen =& $this->__performGeneralSearch())
198 {
199 $this->__storeEntries($res,$res_gen);
200 }
201 if($res_lif =& $this->__performLifecycleSearch())
202 {
203 $this->__storeEntries($res,$res_lif);
204 }
205 if($res_con =& $this->__performContributeSearch())
206 {
207 $this->__storeEntries($res,$res_con);
208 }
209 if($res_ent =& $this->__performEntitySearch())
210 {
211 $this->__storeEntries($res,$res_ent);
212 }
213 if($res_req =& $this->__performRequirementSearch())
214 {
215 $this->__storeEntries($res,$res_req);
216 }
217 if($res_for =& $this->__performFormatSearch())
218 {
219 $this->__storeEntries($res,$res_for);
220 }
221 if($res_edu =& $this->__performEducationalSearch())
222 {
223 $this->__storeEntries($res,$res_edu);
224 }
225 if($res_typ =& $this->__performTypicalAgeRangeSearch())
226 {
227 $this->__storeEntries($res,$res_typ);
228 }
229 if($res_rig =& $this->__performRightsSearch())
230 {
231 $this->__storeEntries($res,$res_rig);
232 }
233 if($res_cla =& $this->__performClassificationSearch())
234 {
235 $this->__storeEntries($res,$res_cla);
236 }
237 if($res_tax =& $this->__performTaxonSearch())
238 {
239 $this->__storeEntries($res,$res_tax);
240 }
241 if($res_key =& $this->__performKeywordSearch())
242 {
243 $this->__storeEntries($res,$res_key);
244 }
245
246 $this->searchAdvancedMD($res);
247
248 if($this->search_mode == 'in_results')
249 {
250 include_once 'Services/Search/classes/class.ilSearchResult.php';
251
252 $old_result_obj = new ilSearchResult($ilUser->getId());
253 $old_result_obj->read(ADVANCED_MD_SEARCH);
254
255 $res->diffEntriesFromResult($old_result_obj);
256 }
257
258 $res->filter($this->getRootNode(), (ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND));
259 $res->save();
260 $this->showSearch();
261
262 if(!count($res->getResults()))
263 {
264 ilUtil::sendInfo($this->lng->txt('search_no_match'));
265 }
266
267 if($res->isLimitReached())
268 {
269 #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
270 #ilUtil::sendInfo($message);
271 }
272
273 $this->addPager($res,'adv_max_page');
274
275 include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
277 $presentation->setResults($res->getResultsForPresentation());
278 $presentation->setPreviousNext($this->prev_link, $this->next_link);
279
280 if($presentation->render())
281 {
282 $this->tpl->setVariable('RESULTS',$presentation->getHTML(true));
283 }
284 return true;
285 }
286
292 protected function initAdvancedMetaDataForm()
293 {
294 if(is_object($this->form))
295 {
296 return $this->form;
297 }
298
299 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
300 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
301 $this->form = new ilPropertyFormGUI();
302 $this->form->setFormAction($this->ctrl->getFormAction($this,'performAdvMDSearch'));
303 $this->form->setTitle($this->lng->txt('adv_md_search_title'));
304 $this->form->addCommandButton('performAdvMDSearch',$this->lng->txt('search'));
305 #$this->form->setSubformMode('right');
306
307 $content = new ilTextInputGUI($this->lng->txt('meta_title').'/'.
308 $this->lng->txt('meta_keyword').'/'.
309 $this->lng->txt('meta_description'),'title');
310 $content->setValue($this->options['title']);
311 $content->setSize(30);
312 $content->setMaxLength(255);
313// $content->setSubformMode('right');
314 $group = new ilRadioGroupInputGUI('','title_ao');
315 $group->setValue($this->options['title_ao']);
316 $radio_option = new ilRadioOption($this->lng->txt("search_any_word"),0);
317 $group->addOption($radio_option);
318 $radio_option = new ilRadioOption($this->lng->txt("search_all_words"),1);
319 $group->addOption($radio_option);
320 $content->addSubItem($group);
321 $this->form->addItem($content);
322
323 $type = new ilSelectInputGUI($this->lng->txt('type'),'type');
324 $options['adv_all'] = $this->lng->txt('search_any');
325 foreach(ilAdvancedMDRecord::_getActivatedObjTypes() as $obj_type)
326 {
327 $options[$obj_type] = $this->lng->txt('objs_'.$obj_type);
328 }
329 $type->setOptions($options);
330 $type->setValue($this->options['type']);
331 $this->form->addItem($type);
332
333 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
335 $record_gui->setPropertyForm($this->form);
336 $record_gui->setSearchValues($this->options);
337 $record_gui->parse();
338 }
339
345 protected function performAdvMDSearch()
346 {
347 global $ilUser;
348
349 $this->initSearchType(self::TYPE_ADV_MD);
350 if(!isset($_GET['page_number']) and $this->search_mode != 'in_results' )
351 {
352 unset($_SESSION['adv_max_page']);
353 $this->search_cache->delete();
354 }
355
356 include_once 'Services/Search/classes/class.ilSearchResult.php';
357 $res =& new ilSearchResult();
358
359 if($res_tit =& $this->__performTitleSearch())
360 {
361 $this->__storeEntries($res,$res_tit);
362 }
363 $this->searchAdvancedMD($res);
364
365 if($this->search_mode == 'in_results')
366 {
367 include_once 'Services/Search/classes/class.ilSearchResult.php';
368
369 $old_result_obj = new ilSearchResult($ilUser->getId());
370 $old_result_obj->read(ADVANCED_MD_SEARCH);
371
372 $res->diffEntriesFromResult($old_result_obj);
373 }
374
375
376 $res->filter($this->getRootNode(),true);
377 $res->save();
378 $this->showAdvMDSearch();
379
380 if(!count($res->getResults()))
381 {
382 ilUtil::sendInfo($this->lng->txt('search_no_match'));
383 }
384
385 if($res->isLimitReached())
386 {
387 #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
388 #ilUtil::sendInfo($message);
389 }
390
391 $this->addPager($res,'adv_max_page');
392
393 include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
395 $presentation->setResults($res->getResultsForPresentation());
396 $presentation->setPreviousNext($this->prev_link, $this->next_link);
397
398 if($presentation->render())
399 {
400 $this->tpl->setVariable('RESULTS',$presentation->getHTML(true));
401 }
402 return true;
403
404 }
405
406
412 public function showAdvMDSearch()
413 {
414 if(isset($_SESSION['search_adv_md']))
415 {
416 $this->options = $_SESSION['search_adv_md'];
417 }
418 $this->setSubTabs();
419 $this->tabs_gui->setSubTabActive('search_adv_md');
420
421 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.advanced_adv_search.html','Services/Search');
422
424 $this->tpl->setVariable('SEARCH_FORM',$this->form->getHTML());
425 return true;
426 }
427
431 protected function initFormSearch()
432 {
433 global $tree;
434
435 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
436
437 $this->form = new ilPropertyFormGUI();
438 $this->form->setFormAction($this->ctrl->getFormAction($this,'performSearch'));
439 $this->form->setTitle($this->lng->txt('search_advanced'));
440 $this->form->addCommandButton('performSearch',$this->lng->txt('search'));
441 $this->form->addCommandButton('reset',$this->lng->txt('reset'));
442
443 foreach($this->fields->getActiveSections() as $definition)
444 {
445 if($definition['name'] != 'default')
446 {
448 $section->setTitle($definition['name']);
449 $this->form->addItem($section);
450 }
451
452 foreach($definition['fields'] as $field_name)
453 {
454 if(is_object($element = $this->fields->getFormElement($this->search_cache->getQuery(),$field_name,$this->form)))
455 {
456 $this->form->addItem($element);
457 }
458 }
459 }
460 return true;
461 }
462
463
464
465 function showSearch()
466 {
467 global $ilLocator;
468
469 $this->setSubTabs();
470 $this->tabs_gui->setSubTabActive('search_lom');
471
472 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.advanced_search.html','Services/Search');
473
474 $this->initFormSearch();
475 $this->tpl->setVariable('SEARCH_FORM',$this->form->getHTML());
476 return true;
477 }
478
479 function prepareOutput()
480 {
481 global $ilTabs, $ilHelp;
482
483 parent::prepareOutput();
484
485 $ilHelp->setScreenIdComponent("src");
486
487 $ilTabs->addTab("search", $this->lng->txt("search"),
488 $this->ctrl->getLinkTargetByClass('ilsearchgui'));
489 $ilTabs->addTab("adv_search", $this->lng->txt("search_advanced"),
490 $this->ctrl->getLinkTarget($this));
491 $ilTabs->activateTab("adv_search");
492 }
493
494 // PRIVATE
501 private function showSavedAdvMDResults()
502 {
503 global $ilUser;
504
505 // Read old result sets
506 include_once 'Services/Search/classes/class.ilSearchResult.php';
507
508 $this->initSearchType(self::TYPE_ADV_MD);
509 $result_obj = new ilSearchResult($ilUser->getId());
510 $result_obj->read(ADVANCED_MD_SEARCH);
511
512 $this->showAdvMDSearch();
513
514 // Show them
515 if(count($result_obj->getResults()))
516 {
517 $this->addPager($result_obj,'adv_max_page');
518
519 include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
521 $presentation->setResults($result_obj->getResultsForPresentation());
522 $presentation->setPreviousNext($this->prev_link, $this->next_link);
523
524 if($presentation->render())
525 {
526 $this->tpl->setVariable('RESULTS',$presentation->getHTML(true));
527 }
528 }
529
530 return true;
531 }
532
533
535 {
536 global $ilUser;
537
538 // Read old result sets
539 include_once 'Services/Search/classes/class.ilSearchResult.php';
540
541 $this->initSearchType(self::TYPE_LOM);
542 $result_obj = new ilSearchResult($ilUser->getId());
543 $result_obj->read(ADVANCED_SEARCH);
544
545 $this->showSearch();
546
547 // Show them
548 if(count($result_obj->getResults()))
549 {
550 $this->addPager($result_obj,'adv_max_page');
551
552 include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
554 $presentation->setResults($result_obj->getResultsForPresentation());
555 $presentation->setPreviousNext($this->prev_link, $this->next_link);
556
557 if($presentation->render())
558 {
559 $this->tpl->setVariable('RESULTS',$presentation->getHTML(true));
560 }
561 }
562
563 return true;
564 }
565
567 {
568 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
569 include_once 'Services/Search/classes/class.ilQueryParser.php';
570 include_once 'Services/Search/classes/class.ilSearchResult.php';
571
572 if(!$this->options['lom_content'])
573 {
574 return false;
575 }
576
577 $res =& new ilSearchResult();
578
579 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_content']));
580 #$query_parser->setCombination($this->options['content_ao']);
581 $query_parser->setCombination(QP_COMBINATION_OR);
582 $query_parser->parse();
583
584 if($this->options['type'] == 'all' or $this->options['type'] == 'lms')
585 {
586 // LM content search
587 $lm_search =& ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
588 $res_cont =& $lm_search->performSearch();
589 $res->mergeEntries($res_cont);
590 }
591 if($this->options['type'] == 'all' or $this->options['type'] == 'tst')
592 {
593 $tst_search =& ilObjectSearchFactory::_getTestSearchInstance($query_parser);
594 $res_tes =& $tst_search->performSearch();
595 $res->mergeEntries($res_tes);
596 }
597 if($this->options['type'] == 'all' or $this->options['type'] == 'mep')
598 {
599 $med_search =& ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
600 $res_med =& $med_search->performSearch();
601 $res->mergeEntries($res_med);
602 }
603 if($this->options['type'] == 'all' or $this->options['type'] == 'glo')
604 {
606 $res_glo =& $glo_search->performSearch();
607 $res->mergeEntries($res_glo);
608 }
609 if($this->options['type'] == 'all' or $this->options['type'] == 'webr')
610 {
611 $web_search =& ilObjectSearchFactory::_getWebresourceSearchInstance($query_parser);
612 $res_web =& $web_search->performSearch();
613 $res->mergeEntries($res_web);
614 }
615 if($tit_res = $this->__performTitleSearch())
616 {
617 $res->mergeEntries($tit_res);
618 }
619
620 return $res;
621 }
622
623
625 {
626 if(!$this->options['lom_content'])
627 {
628 return false;
629 }
630
631 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
632 include_once 'Services/Search/classes/class.ilQueryParser.php';
633
634 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_content']));
635 #$query_parser->setCombination($this->options['title_ao']);
636 $query_parser->setCombination(QP_COMBINATION_OR);
637 $query_parser->parse();
638 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
639
640 $meta_search->setFilter($this->filter);
641 $meta_search->setMode('title_description');
642 $meta_search->setOptions($this->options);
643 $res_tit =& $meta_search->performSearch();
644
645 $meta_search->setMode('keyword_all');
646 $res_key =& $meta_search->performSearch();
647
648 // merge them
649 $res_tit->mergeEntries($res_key);
650
651
652 return $res_tit;
653 }
654
655
656
658 {
659 if(!$this->options['lom_coverage'] and !$this->options['lom_structure'])
660 {
661 return false;
662 }
663
664 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
665 include_once 'Services/Search/classes/class.ilQueryParser.php';
666
667 if($this->options['lom_coverage'])
668 {
669 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_coverage']));
670 #$query_parser->setCombination($this->options['coverage_ao']);
671 $query_parser->setCombination(QP_COMBINATION_OR);
672 $query_parser->parse();
673 }
674 else
675 {
676 $query_parser = new ilQueryParser('');
677 }
678 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
679 $meta_search->setFilter($this->filter);
680 $meta_search->setMode('general');
681 $meta_search->setOptions($this->options);
682 $res =& $meta_search->performSearch();
683
684 return $res;
685 }
686
688 {
689 // Return if 'any'
690 if(!$this->options['lom_status'] and !$this->options['lom_version'])
691 {
692 return false;
693 }
694 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
695 include_once 'Services/Search/classes/class.ilQueryParser.php';
696
697 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_version']));
698 #$query_parser->setCombination($this->options['version_ao']);
699 $query_parser->setCombination(QP_COMBINATION_OR);
700 $query_parser->parse();
701
702 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
703 $meta_search->setFilter($this->filter);
704 $meta_search->setMode('lifecycle');
705 $meta_search->setOptions($this->options);
706 $res =& $meta_search->performSearch();
707
708 return $res;
709 }
711 {
712 if(!$this->options['lom_language'])
713 {
714 return false;
715 }
716 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
717 include_once 'Services/Search/classes/class.ilQueryParser.php';
718
719
721 $meta_search->setFilter($this->filter);
722 $meta_search->setMode('language');
723 $meta_search->setOptions($this->options);
724 $res =& $meta_search->performSearch();
725
726 return $res;
727 }
729 {
730 if(!strlen($this->options['lom_role']))
731 {
732 return false;
733 }
734 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
735 include_once 'Services/Search/classes/class.ilQueryParser.php';
736
737
739 $meta_search->setFilter($this->filter);
740 $meta_search->setMode('contribute');
741 $meta_search->setOptions($this->options);
742 $res =& $meta_search->performSearch();
743
744 return $res;
745 }
747 {
748 // Return if 'any'
749 if(!$this->options['lom_role_entry'])
750 {
751 return false;
752 }
753
754 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
755 include_once 'Services/Search/classes/class.ilQueryParser.php';
756
757 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_role_entry']));
758 #$query_parser->setCombination($this->options['entity_ao']);
759 $query_parser->setCombination(QP_COMBINATION_OR);
760 $query_parser->parse();
761
762 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
763 $meta_search->setFilter($this->filter);
764 $meta_search->setMode('entity');
765 $meta_search->setOptions($this->options);
766 $res =& $meta_search->performSearch();
767
768 return $res;
769 }
770
771
773 {
774 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
775 include_once 'Services/Search/classes/class.ilQueryParser.php';
776
777
779 $meta_search->setFilter($this->filter);
780 $meta_search->setMode('requirement');
781 $meta_search->setOptions($this->options);
782 $res =& $meta_search->performSearch();
783
784 return $res;
785 }
787 {
788 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
789 include_once 'Services/Search/classes/class.ilQueryParser.php';
790
791
793 $meta_search->setFilter($this->filter);
794 $meta_search->setMode('format');
795 $meta_search->setOptions($this->options);
796 $res =& $meta_search->performSearch();
797
798 return $res;
799 }
801 {
802 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
803 include_once 'Services/Search/classes/class.ilQueryParser.php';
804
805
807 $meta_search->setFilter($this->filter);
808 $meta_search->setMode('educational');
809 $meta_search->setOptions($this->options);
810 $res =& $meta_search->performSearch();
811
812 return $res;
813 }
815 {
816 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
817 include_once 'Services/Search/classes/class.ilQueryParser.php';
818
819
821 $meta_search->setFilter($this->filter);
822 $meta_search->setMode('typical_age_range');
823 $meta_search->setOptions($this->options);
824 $res =& $meta_search->performSearch();
825
826 return $res;
827 }
829 {
830 if(!$this->options['lom_copyright'] and !$this->options['lom_costs'])
831 {
832 return false;
833 }
834 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
835 include_once 'Services/Search/classes/class.ilQueryParser.php';
836
837
839 $meta_search->setFilter($this->filter);
840 $meta_search->setMode('rights');
841 $meta_search->setOptions($this->options);
842 $res =& $meta_search->performSearch();
843
844 return $res;
845 }
846
848 {
849 // Return if 'any'
850 if(!$this->options['lom_purpose'])
851 {
852 return false;
853 }
854 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
855 include_once 'Services/Search/classes/class.ilQueryParser.php';
856
857
859 $meta_search->setFilter($this->filter);
860 $meta_search->setMode('classification');
861 $meta_search->setOptions($this->options);
862 $res =& $meta_search->performSearch();
863
864 return $res;
865 }
866
868 {
869 // Return if 'any'
870 if(!$this->options['lom_taxon'])
871 {
872 return false;
873 }
874 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
875 include_once 'Services/Search/classes/class.ilQueryParser.php';
876
877 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_taxon']));
878 $query_parser->setCombination(QP_COMBINATION_OR);
879 $query_parser->parse();
880
881 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
882 $meta_search->setFilter($this->filter);
883 $meta_search->setMode('taxon');
884 $meta_search->setOptions($this->options);
885 $res =& $meta_search->performSearch();
886
887 return $res;
888 }
889
897 private function searchAdvancedMD($res)
898 {
899 $this->initFormSearch();
900
901 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
902 foreach(array_keys($this->options) as $key)
903 {
904 if(substr($key,0,3) != 'adv')
905 {
906 continue;
907 }
908
909 // :TODO: ?
910 if(!$key)
911 {
912 continue;
913 }
914
915 $field_id = substr($key,4);
917
918 $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false);
919 $field_form->setElementId("query[".$key."]");
920 $field_form->setForm($this->form);
921
922 // reload search values
923 $field_form->importFromPost($this->options);
924 $field_form->validate();
925
926 $parser_value = $field->getSearchQueryParserValue($field_form);
927
928 include_once 'Services/Search/classes/class.ilQueryParser.php';
929 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
930 $adv_md_search = ilObjectSearchFactory::_getAdvancedMDSearchInstance(new ilQueryParser($parser_value));
931 $adv_md_search->setFilter($this->filter);
932 $adv_md_search->setDefinition($field);
933 $adv_md_search->setSearchElement($field_form);
934 $res_field = $adv_md_search->performSearch();
935 if($res_field instanceof ilSearchResult)
936 {
937 $this->__storeEntries($res,$res_field);
938 }
939 }
940 }
941
943 {
944 // Return if 'any'
945 if(!$this->options['lom_keyword'])
946 {
947 return false;
948 }
949 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
950 include_once 'Services/Search/classes/class.ilQueryParser.php';
951
952 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_keyword']));
953 #$query_parser->setCombination($this->options['keyword_ao']);
954 $query_parser->setCombination(QP_COMBINATION_OR);
955 $query_parser->parse();
956
957 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
958 $meta_search->setFilter($this->filter);
959 $meta_search->setMode('keyword');
960 $meta_search->setOptions($this->options);
961 $res =& $meta_search->performSearch();
962
963 return $res;
964 }
965
966 function __setSearchOptions(&$post_vars)
967 {
968 if(isset($_POST['cmd']['performSearch']))
969 {
970 $this->options = $_SESSION['search_adv'] = $_POST['query'];
971 }
972 elseif(isset($_POST['cmd']['performAdvMDSearch']))
973 {
974 $this->options = $_SESSION['search_adv_md'] = $_POST;
975 }
976 else
977 {
978 $this->options = $_SESSION['search_adv'];
979 }
980
981 $_POST['result'] = $_POST['id'];
982
983 $this->filter = array();
984
985 $this->options['type'] = 'all';
986 switch($this->options['type'])
987 {
988 case 'cat':
989 $this->filter[] = 'cat';
990 break;
991
992 case 'webr':
993 $this->filter[] = 'webr';
994 break;
995
996 case 'lms':
997 $this->filter[] = 'lm';
998 $this->filter[] = 'dbk';
999 $this->filter[] = 'pg';
1000 $this->filter[] = 'st';
1001 $this->filter[] = 'sahs';
1002 $this->filter[] = 'htlm';
1003 break;
1004
1005 case 'glo':
1006 $this->filter[] = 'glo';
1007 break;
1008
1009 case 'tst':
1010 $this->filter[] = 'tst';
1011 $this->filter[] = 'svy';
1012 $this->filter[] = 'qpl';
1013 $this->filter[] = 'spl';
1014 break;
1015
1016 case 'mep':
1017 $this->filter[] = 'mep';
1018 break;
1019
1020 case 'crs':
1021 $this->filter[] = 'crs';
1022 break;
1023
1024 case 'file':
1025 $this->filter[] = 'file';
1026 break;
1027
1028 case 'adv_all':
1029 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
1031 break;
1032
1033 case 'all':
1034 default:
1035 $this->filter[] = 'webr';
1036 $this->filter[] = 'crs';
1037 $this->filter[] = 'mep';
1038 $this->filter[] = 'tst';
1039 $this->filter[] = 'svy';
1040 $this->filter[] = 'qpl';
1041 $this->filter[] = 'spl';
1042 $this->filter[] = 'glo';
1043 $this->filter[] = 'lm';
1044 $this->filter[] = 'dbk';
1045 $this->filter[] = 'pg';
1046 $this->filter[] = 'st';
1047 $this->filter[] = 'sahs';
1048 $this->filter[] = 'htlm';
1049 $this->filter[] = 'file';
1050 }
1051 return true;
1052 }
1053
1055 {
1056 $options = array('all' => $this->lng->txt('search_any'),
1057 'crs' => $this->lng->txt('objs_crs'),
1058 'lms' => $this->lng->txt('learning_resources'),
1059 'glo' => $this->lng->txt('objs_glo'),
1060 'mep' => $this->lng->txt('objs_mep'),
1061 'tst' => $this->lng->txt('search_tst_svy'),
1062 'file'=> $this->lng->txt('objs_file'),
1063 'webr' => $this->lng->txt('objs_webr'));
1064
1065
1066 return ilUtil::formSelect($this->options['type'],'search_adv[type]',$options,false,true);
1067 }
1068
1069
1070 function __storeEntries($res,$new_res)
1071 {
1072 if($this->stored == false)
1073 {
1074 $res->mergeEntries($new_res);
1075 $this->stored = true;
1076
1077 return true;
1078 }
1079 else
1080 {
1081 $res->intersectEntries($new_res);
1082 return true;
1083 }
1084 }
1085
1092 private function initUserSearchCache()
1093 {
1094 global $ilUser;
1095
1096 include_once('Services/Search/classes/class.ilUserSearchCache.php');
1097 $this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
1098 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH);
1099 if($_GET['page_number'])
1100 {
1101 $this->search_cache->setResultPageNumber((int) $_GET['page_number']);
1102 }
1103 if($_POST['cmd']['performSearch'])
1104 {
1105 $this->search_cache->setQuery(ilUtil::stripSlashes($_POST['query']['lomContent']));
1106 $this->search_cache->save();
1107 }
1108 }
1109
1116 public function setSubTabs()
1117 {
1118 global $ilTabs;
1119
1120 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1122 {
1123 return true;
1124 }
1125 $ilTabs->addSubTabTarget('search_lom',$this->ctrl->getLinkTarget($this,'showSavedResults'));
1126 #$ilTabs->addSubTabTarget('search_adv_md',$this->ctrl->getLinkTarget($this,'showSavedAdvMDResults'));
1127
1128 }
1129
1137 private function toUnixTime($date,$time = array())
1138 {
1139 return mktime($time['h'],$time['m'],0,$date['m'],$date['d'],$date['y']);
1140 }
1141
1149 private function initSearchType($type)
1150 {
1151 if($type == self::TYPE_LOM)
1152 {
1153 $_SESSION['search_last_sub_section'] = self::TYPE_LOM;
1154 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH);
1155 }
1156 else
1157 {
1158 $_SESSION['search_last_sub_section'] = self::TYPE_ADV_MD;
1159 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_MD_SEARCH);
1160 }
1161 }
1162}
1163?>
$section
Definition: Utf8Test.php:84
$_GET["client_id"]
const QP_COMBINATION_OR
const ADVANCED_SEARCH
const ADVANCED_MD_SEARCH
static getInstance()
Get singleton.
static getInstance($a_field_id, $a_type=null)
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.
& executeCommand()
Control @access public.
initAdvancedMetaDataForm()
@access protected
performAdvMDSearch()
perform advanced meta data search
showAdvMDSearch()
Show advanced meta data search.
ilAdvancedSearchGUI()
Constructor @access public.
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.
_getWebresourceSearchInstance($query_parser)
get reference of ilFulltextWebresourceSearch
static _getMediaPoolSearchInstance($query_parser)
get reference of ilFulltextMediapoolSearch
static _getLMContentSearchInstance($query_parser)
get reference of ilFulltextLMContentSearch
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 sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
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.
$_POST['username']
Definition: cron.php:12
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
$cmd
Definition: sahs_server.php:35
$errors fields
Definition: imgupload.php:48
global $ilUser
Definition: imgupload.php:15