ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $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  public function getRootNode()
81  {
82  return ROOT_FOLDER_ID;
83  }
84 
85 
90  public 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  case "ilpropertyformgui":
99 
100 
101  case 'ilobjectcopygui':
102  $this->prepareOutput();
103  $this->ctrl->setReturn($this, '');
104 
105  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
106  $cp = new ilObjectCopyGUI($this);
107  $this->ctrl->forwardCommand($cp);
108  break;
109 
110  default:
111  $this->initUserSearchCache();
112  if (!$cmd) {
113  switch ($_SESSION['search_last_sub_section']) {
114  case self::TYPE_ADV_MD:
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  public 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 
139  public function searchInResults()
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  public 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  unset($_SESSION['adv_max_page']);
176  $this->search_cache->deleteCachedEntries();
177  }
178 
179  if (isset($_POST['query'])) {
180  $this->search_cache->setQuery($_POST['query']);
181  }
182 
183 
184  include_once 'Services/Search/classes/class.ilSearchResult.php';
185  $res = new ilSearchResult();
186 
187  if ($res_con =&$this->__performContentSearch()) {
188  $this->__storeEntries($res, $res_con);
189  }
190  if ($res_lan =&$this->__performLanguageSearch()) {
191  $this->__storeEntries($res, $res_lan);
192  }
193  if ($res_gen =&$this->__performGeneralSearch()) {
194  $this->__storeEntries($res, $res_gen);
195  }
196  if ($res_lif =&$this->__performLifecycleSearch()) {
197  $this->__storeEntries($res, $res_lif);
198  }
199  if ($res_con =&$this->__performContributeSearch()) {
200  $this->__storeEntries($res, $res_con);
201  }
202  if ($res_ent =&$this->__performEntitySearch()) {
203  $this->__storeEntries($res, $res_ent);
204  }
205  if ($res_req =&$this->__performRequirementSearch()) {
206  $this->__storeEntries($res, $res_req);
207  }
208  if ($res_for =&$this->__performFormatSearch()) {
209  $this->__storeEntries($res, $res_for);
210  }
211  if ($res_edu =&$this->__performEducationalSearch()) {
212  $this->__storeEntries($res, $res_edu);
213  }
214  if ($res_typ =&$this->__performTypicalAgeRangeSearch()) {
215  $this->__storeEntries($res, $res_typ);
216  }
217  if ($res_rig =&$this->__performRightsSearch()) {
218  $this->__storeEntries($res, $res_rig);
219  }
220  if ($res_cla =&$this->__performClassificationSearch()) {
221  $this->__storeEntries($res, $res_cla);
222  }
223  if ($res_tax =&$this->__performTaxonSearch()) {
224  $this->__storeEntries($res, $res_tax);
225  }
226  if ($res_key =&$this->__performKeywordSearch()) {
227  $this->__storeEntries($res, $res_key);
228  }
229 
230  $this->searchAdvancedMD($res);
231 
232  if ($this->search_mode == 'in_results') {
233  include_once 'Services/Search/classes/class.ilSearchResult.php';
234 
235  $old_result_obj = new ilSearchResult($ilUser->getId());
236  $old_result_obj->read(ADVANCED_MD_SEARCH);
237 
238  $res->diffEntriesFromResult($old_result_obj);
239  }
240 
241  $res->filter($this->getRootNode(), (ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND));
242  $res->save();
243  $this->showSearch();
244 
245  if (!count($res->getResults())) {
246  ilUtil::sendInfo($this->lng->txt('search_no_match'));
247  }
248 
249  if ($res->isLimitReached()) {
250  #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
251  #ilUtil::sendInfo($message);
252  }
253 
254  $this->addPager($res, 'adv_max_page');
255 
256  include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
258  $presentation->setResults($res->getResultsForPresentation());
259  $presentation->setPreviousNext($this->prev_link, $this->next_link);
260 
261  if ($presentation->render()) {
262  $this->tpl->setVariable('RESULTS', $presentation->getHTML(true));
263  }
264  return true;
265  }
266 
272  protected function initAdvancedMetaDataForm()
273  {
274  if (is_object($this->form)) {
275  return $this->form;
276  }
277 
278  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
279  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
280  $this->form = new ilPropertyFormGUI();
281  $this->form->setFormAction($this->ctrl->getFormAction($this, 'performAdvMDSearch'));
282  $this->form->setTitle($this->lng->txt('adv_md_search_title'));
283  $this->form->addCommandButton('performAdvMDSearch', $this->lng->txt('search'));
284  #$this->form->setSubformMode('right');
285 
286  $content = new ilTextInputGUI($this->lng->txt('meta_title') . '/' .
287  $this->lng->txt('meta_keyword') . '/' .
288  $this->lng->txt('meta_description'), 'title');
289  $content->setValue($this->options['title']);
290  $content->setSize(30);
291  $content->setMaxLength(255);
292  // $content->setSubformMode('right');
293  $group = new ilRadioGroupInputGUI('', 'title_ao');
294  $group->setValue($this->options['title_ao']);
295  $radio_option = new ilRadioOption($this->lng->txt("search_any_word"), 0);
296  $group->addOption($radio_option);
297  $radio_option = new ilRadioOption($this->lng->txt("search_all_words"), 1);
298  $group->addOption($radio_option);
299  $content->addSubItem($group);
300  $this->form->addItem($content);
301 
302  $type = new ilSelectInputGUI($this->lng->txt('type'), 'type');
303  $options['adv_all'] = $this->lng->txt('search_any');
304  foreach (ilAdvancedMDRecord::_getActivatedObjTypes() as $obj_type) {
305  $options[$obj_type] = $this->lng->txt('objs_' . $obj_type);
306  }
307  $type->setOptions($options);
308  $type->setValue($this->options['type']);
309  $this->form->addItem($type);
310 
311  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
313  $record_gui->setPropertyForm($this->form);
314  $record_gui->setSearchValues($this->options);
315  $record_gui->parse();
316  }
317 
323  protected function performAdvMDSearch()
324  {
325  global $ilUser;
326 
327  $this->initSearchType(self::TYPE_ADV_MD);
328  if (!isset($_GET['page_number']) and $this->search_mode != 'in_results') {
329  unset($_SESSION['adv_max_page']);
330  $this->search_cache->delete();
331  }
332 
333  include_once 'Services/Search/classes/class.ilSearchResult.php';
334  $res = new ilSearchResult();
335 
336  if ($res_tit =&$this->__performTitleSearch()) {
337  $this->__storeEntries($res, $res_tit);
338  }
339  $this->searchAdvancedMD($res);
340 
341  if ($this->search_mode == 'in_results') {
342  include_once 'Services/Search/classes/class.ilSearchResult.php';
343 
344  $old_result_obj = new ilSearchResult($ilUser->getId());
345  $old_result_obj->read(ADVANCED_MD_SEARCH);
346 
347  $res->diffEntriesFromResult($old_result_obj);
348  }
349 
350 
351  $res->filter($this->getRootNode(), true);
352  $res->save();
353  $this->showAdvMDSearch();
354 
355  if (!count($res->getResults())) {
356  ilUtil::sendInfo($this->lng->txt('search_no_match'));
357  }
358 
359  if ($res->isLimitReached()) {
360  #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
361  #ilUtil::sendInfo($message);
362  }
363 
364  $this->addPager($res, 'adv_max_page');
365 
366  include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
368  $presentation->setResults($res->getResultsForPresentation());
369  $presentation->setPreviousNext($this->prev_link, $this->next_link);
370 
371  if ($presentation->render()) {
372  $this->tpl->setVariable('RESULTS', $presentation->getHTML(true));
373  }
374  return true;
375  }
376 
377 
383  public function showAdvMDSearch()
384  {
385  if (isset($_SESSION['search_adv_md'])) {
386  $this->options = $_SESSION['search_adv_md'];
387  }
388  $this->setSubTabs();
389  $this->tabs_gui->setSubTabActive('search_adv_md');
390 
391  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.advanced_adv_search.html', 'Services/Search');
392 
393  $this->initAdvancedMetaDataForm();
394  $this->tpl->setVariable('SEARCH_FORM', $this->form->getHTML());
395  return true;
396  }
397 
401  protected function initFormSearch()
402  {
403  global $tree;
404 
405  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
406 
407  $this->form = new ilPropertyFormGUI();
408  $this->form->setFormAction($this->ctrl->getFormAction($this, 'performSearch'));
409  $this->form->setTitle($this->lng->txt('search_advanced'));
410  $this->form->addCommandButton('performSearch', $this->lng->txt('search'));
411  $this->form->addCommandButton('reset', $this->lng->txt('reset'));
412 
413  foreach ($this->fields->getActiveSections() as $definition) {
414  if ($definition['name'] != 'default') {
416  $section->setTitle($definition['name']);
417  $this->form->addItem($section);
418  }
419 
420  foreach ($definition['fields'] as $field_name) {
421  if (is_object($element = $this->fields->getFormElement($this->search_cache->getQuery(), $field_name, $this->form))) {
422  $this->form->addItem($element);
423  }
424  }
425  }
426  return true;
427  }
428 
429 
430 
431  public function showSearch()
432  {
433  global $ilLocator;
434 
435  $this->setSubTabs();
436  $this->tabs_gui->setSubTabActive('search_lom');
437 
438  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.advanced_search.html', 'Services/Search');
439 
440  $this->initFormSearch();
441  $this->tpl->setVariable('SEARCH_FORM', $this->form->getHTML());
442  return true;
443  }
444 
445  public function prepareOutput()
446  {
447  global $ilTabs, $ilHelp;
448 
449  parent::prepareOutput();
450 
451  $ilHelp->setScreenIdComponent("src");
452 
453  $ilTabs->addTab(
454  "search",
455  $this->lng->txt("search"),
456  $this->ctrl->getLinkTargetByClass('ilsearchgui')
457  );
458  $ilTabs->addTab(
459  "adv_search",
460  $this->lng->txt("search_advanced"),
461  $this->ctrl->getLinkTarget($this)
462  );
463  $ilTabs->activateTab("adv_search");
464  }
465 
466  // PRIVATE
473  private function showSavedAdvMDResults()
474  {
475  global $ilUser;
476 
477  // Read old result sets
478  include_once 'Services/Search/classes/class.ilSearchResult.php';
479 
480  $this->initSearchType(self::TYPE_ADV_MD);
481  $result_obj = new ilSearchResult($ilUser->getId());
482  $result_obj->read(ADVANCED_MD_SEARCH);
483 
484  $this->showAdvMDSearch();
485 
486  // Show them
487  if (count($result_obj->getResults())) {
488  $this->addPager($result_obj, 'adv_max_page');
489 
490  include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
492  $presentation->setResults($result_obj->getResultsForPresentation());
493  $presentation->setPreviousNext($this->prev_link, $this->next_link);
494 
495  if ($presentation->render()) {
496  $this->tpl->setVariable('RESULTS', $presentation->getHTML(true));
497  }
498  }
499 
500  return true;
501  }
502 
503 
504  public function showSavedResults()
505  {
506  global $ilUser;
507 
508  // Read old result sets
509  include_once 'Services/Search/classes/class.ilSearchResult.php';
510 
511  $this->initSearchType(self::TYPE_LOM);
512  $result_obj = new ilSearchResult($ilUser->getId());
513  $result_obj->read(ADVANCED_SEARCH);
514 
515  $this->showSearch();
516 
517  // Show them
518  if (count($result_obj->getResults())) {
519  $this->addPager($result_obj, 'adv_max_page');
520 
521  include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
523  $presentation->setResults($result_obj->getResultsForPresentation());
524  $presentation->setPreviousNext($this->prev_link, $this->next_link);
525 
526  if ($presentation->render()) {
527  $this->tpl->setVariable('RESULTS', $presentation->getHTML(true));
528  }
529  }
530 
531  return true;
532  }
533 
534  public function &__performContentSearch()
535  {
536  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
537  include_once 'Services/Search/classes/class.ilQueryParser.php';
538  include_once 'Services/Search/classes/class.ilSearchResult.php';
539 
540  if (!$this->options['lom_content']) {
541  return false;
542  }
543 
544  $res = new ilSearchResult();
545 
546  $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_content']));
547  #$query_parser->setCombination($this->options['content_ao']);
548  $query_parser->setCombination(QP_COMBINATION_OR);
549  $query_parser->parse();
550 
551  if ($this->options['type'] == 'all' or $this->options['type'] == 'lms') {
552  // LM content search
553  $lm_search =&ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
554  $res_cont =&$lm_search->performSearch();
555  $res->mergeEntries($res_cont);
556  }
557  if ($this->options['type'] == 'all' or $this->options['type'] == 'tst') {
558  $tst_search =&ilObjectSearchFactory::_getTestSearchInstance($query_parser);
559  $res_tes =&$tst_search->performSearch();
560  $res->mergeEntries($res_tes);
561  }
562  if ($this->options['type'] == 'all' or $this->options['type'] == 'mep') {
563  $med_search =&ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
564  $res_med =&$med_search->performSearch();
565  $res->mergeEntries($res_med);
566  }
567  if ($this->options['type'] == 'all' or $this->options['type'] == 'glo') {
569  $res_glo =&$glo_search->performSearch();
570  $res->mergeEntries($res_glo);
571  }
572  if ($this->options['type'] == 'all' or $this->options['type'] == 'webr') {
573  $web_search =&ilObjectSearchFactory::_getWebresourceSearchInstance($query_parser);
574  $res_web =&$web_search->performSearch();
575  $res->mergeEntries($res_web);
576  }
577  if ($tit_res = $this->__performTitleSearch()) {
578  $res->mergeEntries($tit_res);
579  }
580 
581  return $res;
582  }
583 
584 
585  public function &__performTitleSearch()
586  {
587  if (!$this->options['lom_content']) {
588  return false;
589  }
590 
591  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
592  include_once 'Services/Search/classes/class.ilQueryParser.php';
593 
594  $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_content']));
595  #$query_parser->setCombination($this->options['title_ao']);
596  $query_parser->setCombination(QP_COMBINATION_OR);
597  $query_parser->parse();
598  $meta_search =&ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
599 
600  $meta_search->setFilter($this->filter);
601  $meta_search->setMode('title_description');
602  $meta_search->setOptions($this->options);
603  $res_tit =&$meta_search->performSearch();
604 
605  $meta_search->setMode('keyword_all');
606  $res_key =&$meta_search->performSearch();
607 
608  // merge them
609  $res_tit->mergeEntries($res_key);
610 
611 
612  return $res_tit;
613  }
614 
615 
616 
617  public function &__performGeneralSearch()
618  {
619  if (!$this->options['lom_coverage'] and !$this->options['lom_structure']) {
620  return false;
621  }
622 
623  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
624  include_once 'Services/Search/classes/class.ilQueryParser.php';
625 
626  if ($this->options['lom_coverage']) {
627  $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_coverage']));
628  #$query_parser->setCombination($this->options['coverage_ao']);
629  $query_parser->setCombination(QP_COMBINATION_OR);
630  $query_parser->parse();
631  } else {
632  $query_parser = new ilQueryParser('');
633  }
634  $meta_search =&ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
635  $meta_search->setFilter($this->filter);
636  $meta_search->setMode('general');
637  $meta_search->setOptions($this->options);
638  $res =&$meta_search->performSearch();
639 
640  return $res;
641  }
642 
643  public function &__performLifecycleSearch()
644  {
645  // Return if 'any'
646  if (!$this->options['lom_status'] and !$this->options['lom_version']) {
647  return false;
648  }
649  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
650  include_once 'Services/Search/classes/class.ilQueryParser.php';
651 
652  $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_version']));
653  #$query_parser->setCombination($this->options['version_ao']);
654  $query_parser->setCombination(QP_COMBINATION_OR);
655  $query_parser->parse();
656 
657  $meta_search =&ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
658  $meta_search->setFilter($this->filter);
659  $meta_search->setMode('lifecycle');
660  $meta_search->setOptions($this->options);
661  $res =&$meta_search->performSearch();
662 
663  return $res;
664  }
665  public function &__performLanguageSearch()
666  {
667  if (!$this->options['lom_language']) {
668  return false;
669  }
670  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
671  include_once 'Services/Search/classes/class.ilQueryParser.php';
672 
673 
675  $meta_search->setFilter($this->filter);
676  $meta_search->setMode('language');
677  $meta_search->setOptions($this->options);
678  $res =&$meta_search->performSearch();
679 
680  return $res;
681  }
682  public function &__performContributeSearch()
683  {
684  if (!strlen($this->options['lom_role'])) {
685  return false;
686  }
687  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
688  include_once 'Services/Search/classes/class.ilQueryParser.php';
689 
690 
692  $meta_search->setFilter($this->filter);
693  $meta_search->setMode('contribute');
694  $meta_search->setOptions($this->options);
695  $res =&$meta_search->performSearch();
696 
697  return $res;
698  }
699  public function &__performEntitySearch()
700  {
701  // Return if 'any'
702  if (!$this->options['lom_role_entry']) {
703  return false;
704  }
705 
706  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
707  include_once 'Services/Search/classes/class.ilQueryParser.php';
708 
709  $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_role_entry']));
710  #$query_parser->setCombination($this->options['entity_ao']);
711  $query_parser->setCombination(QP_COMBINATION_OR);
712  $query_parser->parse();
713 
714  $meta_search =&ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
715  $meta_search->setFilter($this->filter);
716  $meta_search->setMode('entity');
717  $meta_search->setOptions($this->options);
718  $res =&$meta_search->performSearch();
719 
720  return $res;
721  }
722 
723 
724  public function &__performRequirementSearch()
725  {
726  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
727  include_once 'Services/Search/classes/class.ilQueryParser.php';
728 
729 
731  $meta_search->setFilter($this->filter);
732  $meta_search->setMode('requirement');
733  $meta_search->setOptions($this->options);
734  $res =&$meta_search->performSearch();
735 
736  return $res;
737  }
738  public function &__performFormatSearch()
739  {
740  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
741  include_once 'Services/Search/classes/class.ilQueryParser.php';
742 
743 
745  $meta_search->setFilter($this->filter);
746  $meta_search->setMode('format');
747  $meta_search->setOptions($this->options);
748  $res =&$meta_search->performSearch();
749 
750  return $res;
751  }
752  public function &__performEducationalSearch()
753  {
754  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
755  include_once 'Services/Search/classes/class.ilQueryParser.php';
756 
757 
759  $meta_search->setFilter($this->filter);
760  $meta_search->setMode('educational');
761  $meta_search->setOptions($this->options);
762  $res =&$meta_search->performSearch();
763 
764  return $res;
765  }
767  {
768  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
769  include_once 'Services/Search/classes/class.ilQueryParser.php';
770 
771 
773  $meta_search->setFilter($this->filter);
774  $meta_search->setMode('typical_age_range');
775  $meta_search->setOptions($this->options);
776  $res =&$meta_search->performSearch();
777 
778  return $res;
779  }
780  public function &__performRightsSearch()
781  {
782  if (!$this->options['lom_copyright'] and !$this->options['lom_costs']) {
783  return false;
784  }
785  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
786  include_once 'Services/Search/classes/class.ilQueryParser.php';
787 
788 
790  $meta_search->setFilter($this->filter);
791  $meta_search->setMode('rights');
792  $meta_search->setOptions($this->options);
793  $res =&$meta_search->performSearch();
794 
795  return $res;
796  }
797 
798  public function &__performClassificationSearch()
799  {
800  // Return if 'any'
801  if (!$this->options['lom_purpose']) {
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('classification');
811  $meta_search->setOptions($this->options);
812  $res =&$meta_search->performSearch();
813 
814  return $res;
815  }
816 
817  public function &__performTaxonSearch()
818  {
819  // Return if 'any'
820  if (!$this->options['lom_taxon']) {
821  return false;
822  }
823  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
824  include_once 'Services/Search/classes/class.ilQueryParser.php';
825 
826  $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_taxon']));
827  $query_parser->setCombination(QP_COMBINATION_OR);
828  $query_parser->parse();
829 
830  $meta_search =&ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
831  $meta_search->setFilter($this->filter);
832  $meta_search->setMode('taxon');
833  $meta_search->setOptions($this->options);
834  $res =&$meta_search->performSearch();
835 
836  return $res;
837  }
838 
846  private function searchAdvancedMD($res)
847  {
848  $this->initFormSearch();
849 
850  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
851  foreach (array_keys($this->options) as $key) {
852  if (substr($key, 0, 3) != 'adv') {
853  continue;
854  }
855 
856  // :TODO: ?
857  if (!$key) {
858  continue;
859  }
860 
861  $field_id = substr($key, 4);
862  $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
863 
864  $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false);
865  $field_form->setElementId("query[" . $key . "]");
866  $field_form->setForm($this->form);
867 
868  // reload search values
869  $field_form->importFromPost($this->options);
870  $field_form->validate();
871 
872  $parser_value = $field->getSearchQueryParserValue($field_form);
873 
874  include_once 'Services/Search/classes/class.ilQueryParser.php';
875  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
876  $adv_md_search = ilObjectSearchFactory::_getAdvancedMDSearchInstance(new ilQueryParser($parser_value));
877  $adv_md_search->setFilter($this->filter);
878  $adv_md_search->setDefinition($field);
879  $adv_md_search->setSearchElement($field_form);
880  $res_field = $adv_md_search->performSearch();
881  if ($res_field instanceof ilSearchResult) {
882  $this->__storeEntries($res, $res_field);
883  }
884  }
885  }
886 
887  public function &__performKeywordSearch()
888  {
889  // Return if 'any'
890  if (!$this->options['lom_keyword']) {
891  return false;
892  }
893  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
894  include_once 'Services/Search/classes/class.ilQueryParser.php';
895 
896  $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_keyword']));
897  #$query_parser->setCombination($this->options['keyword_ao']);
898  $query_parser->setCombination(QP_COMBINATION_OR);
899  $query_parser->parse();
900 
901  $meta_search =&ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
902  $meta_search->setFilter($this->filter);
903  $meta_search->setMode('keyword');
904  $meta_search->setOptions($this->options);
905  $res =&$meta_search->performSearch();
906 
907  return $res;
908  }
909 
910  public function __setSearchOptions(&$post_vars)
911  {
912  if (isset($_POST['cmd']['performSearch'])) {
913  $this->options = $_SESSION['search_adv'] = $_POST['query'];
914  } elseif (isset($_POST['cmd']['performAdvMDSearch'])) {
915  $this->options = $_SESSION['search_adv_md'] = $_POST;
916  } else {
917  $this->options = $_SESSION['search_adv'];
918  }
919 
920  $_POST['result'] = $_POST['id'];
921 
922  $this->filter = array();
923 
924  $this->options['type'] = 'all';
925  switch ($this->options['type']) {
926  case 'cat':
927  $this->filter[] = 'cat';
928  break;
929 
930  case 'webr':
931  $this->filter[] = 'webr';
932  break;
933 
934  case 'lms':
935  $this->filter[] = 'lm';
936  $this->filter[] = 'dbk';
937  $this->filter[] = 'pg';
938  $this->filter[] = 'st';
939  $this->filter[] = 'sahs';
940  $this->filter[] = 'htlm';
941  break;
942 
943  case 'glo':
944  $this->filter[] = 'glo';
945  break;
946 
947  case 'tst':
948  $this->filter[] = 'tst';
949  $this->filter[] = 'svy';
950  $this->filter[] = 'qpl';
951  $this->filter[] = 'spl';
952  break;
953 
954  case 'mep':
955  $this->filter[] = 'mep';
956  break;
957 
958  case 'crs':
959  $this->filter[] = 'crs';
960  break;
961 
962  case 'file':
963  $this->filter[] = 'file';
964  break;
965 
966  case 'adv_all':
967  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
969  break;
970 
971  case 'all':
972  default:
973  $this->filter[] = 'sess';
974  $this->filter[] = 'webr';
975  $this->filter[] = 'crs';
976  $this->filter[] = 'mep';
977  $this->filter[] = 'tst';
978  $this->filter[] = 'svy';
979  $this->filter[] = 'qpl';
980  $this->filter[] = 'spl';
981  $this->filter[] = 'glo';
982  $this->filter[] = 'lm';
983  $this->filter[] = 'dbk';
984  $this->filter[] = 'pg';
985  $this->filter[] = 'st';
986  $this->filter[] = 'sahs';
987  $this->filter[] = 'htlm';
988  $this->filter[] = 'file';
989  }
990  return true;
991  }
992 
993  public function __getFilterSelect()
994  {
995  $options = array('all' => $this->lng->txt('search_any'),
996  'crs' => $this->lng->txt('objs_crs'),
997  'lms' => $this->lng->txt('learning_resources'),
998  'glo' => $this->lng->txt('objs_glo'),
999  'mep' => $this->lng->txt('objs_mep'),
1000  'tst' => $this->lng->txt('search_tst_svy'),
1001  'file'=> $this->lng->txt('objs_file'),
1002  'webr' => $this->lng->txt('objs_webr'),
1003  'sess' => $this->lng->txt('objs_sess')
1004  );
1005 
1006 
1007  return ilUtil::formSelect($this->options['type'], 'search_adv[type]', $options, false, true);
1008  }
1009 
1010 
1011  public function __storeEntries($res, $new_res)
1012  {
1013  if ($this->stored == false) {
1014  $res->mergeEntries($new_res);
1015  $this->stored = true;
1016 
1017  return true;
1018  } else {
1019  $res->intersectEntries($new_res);
1020  return true;
1021  }
1022  }
1023 
1030  private function initUserSearchCache()
1031  {
1032  global $ilUser;
1033 
1034  include_once('Services/Search/classes/class.ilUserSearchCache.php');
1035  $this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
1036  $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH);
1037  if ($_GET['page_number']) {
1038  $this->search_cache->setResultPageNumber((int) $_GET['page_number']);
1039  }
1040  if ($_POST['cmd']['performSearch']) {
1041  $this->search_cache->setQuery(ilUtil::stripSlashes($_POST['query']['lomContent']));
1042  $this->search_cache->save();
1043  }
1044  }
1045 
1052  public function setSubTabs()
1053  {
1054  global $ilTabs;
1055 
1056  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1058  return true;
1059  }
1060  $ilTabs->addSubTabTarget('search_lom', $this->ctrl->getLinkTarget($this, 'showSavedResults'));
1061  #$ilTabs->addSubTabTarget('search_adv_md',$this->ctrl->getLinkTarget($this,'showSavedAdvMDResults'));
1062  }
1063 
1071  private function toUnixTime($date, $time = array())
1072  {
1073  return mktime($time['h'], $time['m'], 0, $date['m'], $date['d'], $date['y']);
1074  }
1075 
1083  private function initSearchType($type)
1084  {
1085  if ($type == self::TYPE_LOM) {
1086  $_SESSION['search_last_sub_section'] = self::TYPE_LOM;
1087  $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH);
1088  } else {
1089  $_SESSION['search_last_sub_section'] = self::TYPE_ADV_MD;
1090  $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_MD_SEARCH);
1091  }
1092  }
1093 }
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.
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
Create styles array
The data for the language used.
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