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