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