00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00035 include_once 'Services/Search/classes/class.ilSearchBaseGUI.php';
00036 include_once 'Services/MetaData/classes/class.ilMDUtilSelect.php';
00037
00038 class ilAdvancedSearchGUI extends ilSearchBaseGUI
00039 {
00040 const TYPE_LOM = 1;
00041 const TYPE_ADV_MD = 2;
00042
00043 protected $last_section = 'adv_search';
00044
00045
00046
00051 private $options = array();
00052
00053 protected $tabs_gui;
00054
00059 function ilAdvancedSearchGUI()
00060 {
00061 global $ilTabs;
00062
00063 $this->tabs_gui = $ilTabs;
00064
00065 parent::ilSearchBaseGUI();
00066
00067 $this->lng->loadLanguageModule('meta');
00068
00069 $this->__setSearchOptions($_POST);
00070 }
00071
00072 function getRootNode()
00073 {
00074 return ROOT_FOLDER_ID;
00075 }
00076
00077
00082 function &executeCommand()
00083 {
00084 global $rbacsystem;
00085
00086 $next_class = $this->ctrl->getNextClass($this);
00087 $cmd = $this->ctrl->getCmd();
00088
00089 switch($next_class)
00090 {
00091 default:
00092 $this->initUserSearchCache();
00093 if(!$cmd)
00094 {
00095 switch($_SESSION['search_last_sub_section'])
00096 {
00097 case self::TYPE_ADV_MD:
00098 $cmd = "showSavedAdvMDResults";
00099 break;
00100
00101 default:
00102 $cmd = "showSavedResults";
00103 break;
00104 }
00105 }
00106
00107 $this->prepareOutput();
00108 $this->$cmd();
00109 break;
00110 }
00111 return true;
00112 }
00113 function reset()
00114 {
00115 $this->initSearchType(self::TYPE_LOM);
00116 $this->options = array();
00117 $this->showSearch();
00118 }
00119
00120 function searchInResults()
00121 {
00122 $this->initSearchType(self::TYPE_LOM);
00123 $this->search_mode = 'in_results';
00124 $this->search_cache->setResultPageNumber(1);
00125 unset($_SESSION['adv_max_page']);
00126 $this->performSearch();
00127
00128 return true;
00129 }
00130
00131
00132 function performSearch()
00133 {
00134 global $ilUser;
00135
00136 $this->initSearchType(self::TYPE_LOM);
00137
00138 if(!isset($_GET['page_number']) and $this->search_mode != 'in_results' )
00139 {
00140 unset($_SESSION['adv_max_page']);
00141 $this->search_cache->delete();
00142 }
00143
00144 include_once 'Services/Search/classes/class.ilSearchResult.php';
00145 $res =& new ilSearchResult();
00146
00147 if($res_con =& $this->__performContentSearch())
00148 {
00149 $this->__storeEntries($res,$res_con);
00150 }
00151 if($res_tit =& $this->__performTitleSearch())
00152 {
00153 $this->__storeEntries($res,$res_tit);
00154 }
00155 if($res_lan =& $this->__performLanguageSearch())
00156 {
00157 $this->__storeEntries($res,$res_lan);
00158 }
00159 if($res_gen =& $this->__performGeneralSearch())
00160 {
00161 $this->__storeEntries($res,$res_gen);
00162 }
00163 if($res_lif =& $this->__performLifecycleSearch())
00164 {
00165 $this->__storeEntries($res,$res_lif);
00166 }
00167 if($res_con =& $this->__performContributeSearch())
00168 {
00169 $this->__storeEntries($res,$res_con);
00170 }
00171 if($res_ent =& $this->__performEntitySearch())
00172 {
00173 $this->__storeEntries($res,$res_ent);
00174 }
00175 if($res_req =& $this->__performRequirementSearch())
00176 {
00177 $this->__storeEntries($res,$res_req);
00178 }
00179 if($res_for =& $this->__performFormatSearch())
00180 {
00181 $this->__storeEntries($res,$res_for);
00182 }
00183 if($res_edu =& $this->__performEducationalSearch())
00184 {
00185 $this->__storeEntries($res,$res_edu);
00186 }
00187 if($res_typ =& $this->__performTypicalAgeRangeSearch())
00188 {
00189 $this->__storeEntries($res,$res_typ);
00190 }
00191 if($res_rig =& $this->__performRightsSearch())
00192 {
00193 $this->__storeEntries($res,$res_rig);
00194 }
00195 if($res_cla =& $this->__performClassificationSearch())
00196 {
00197 $this->__storeEntries($res,$res_cla);
00198 }
00199 if($res_tax =& $this->__performTaxonSearch())
00200 {
00201 $this->__storeEntries($res,$res_tax);
00202 }
00203 if($res_key =& $this->__performKeywordSearch())
00204 {
00205 $this->__storeEntries($res,$res_key);
00206 }
00207
00208 if($this->search_mode == 'in_results')
00209 {
00210 include_once 'Services/Search/classes/class.ilSearchResult.php';
00211
00212 $old_result_obj = new ilSearchResult($ilUser->getId());
00213 $old_result_obj->read(ADVANCED_MD_SEARCH);
00214
00215 $res->diffEntriesFromResult($old_result_obj);
00216 }
00217
00218
00219 $res->filter($this->getRootNode(),true);
00220 $res->save();
00221 $this->showSearch();
00222
00223 if(!count($res->getResults()))
00224 {
00225 ilUtil::sendInfo($this->lng->txt('search_no_match'));
00226 }
00227 else
00228 {
00229 $this->__showSearchInResults();
00230 }
00231
00232 if($res->isLimitReached())
00233 {
00234 $message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
00235 ilUtil::sendInfo($message);
00236 }
00237
00238 $this->addPager($res,'adv_max_page');
00239
00240 include_once 'Services/Search/classes/class.ilSearchResultPresentationGUI.php';
00241 $search_result_presentation = new ilSearchResultPresentationGUI($res);
00242 $this->tpl->setVariable("RESULTS",$search_result_presentation->showResults());
00243
00244 return true;
00245 }
00246
00252 protected function initAdvancedMetaDataForm()
00253 {
00254 if(is_object($this->form))
00255 {
00256 return $this->form;
00257 }
00258
00259 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
00260 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
00261 $this->form = new ilPropertyFormGUI();
00262 $this->form->setFormAction($this->ctrl->getFormAction($this));
00263 $this->form->setTitle($this->lng->txt('adv_md_search_title'));
00264 $this->form->addCommandButton('performAdvMDSearch',$this->lng->txt('search'));
00265 #$this->form->setSubformMode('right');
00266
00267 $content = new ilTextInputGUI($this->lng->txt('meta_title').'/'.
00268 $this->lng->txt('meta_keyword').'/'.
00269 $this->lng->txt('meta_description'),'title');
00270 $content->setValue($this->options['title']);
00271 $content->setSize(30);
00272 $content->setMaxLength(255);
00273 $content->setSubformMode('right');
00274 $group = new ilRadioGroupInputGUI('','title_ao');
00275 $group->setValue($this->options['title_ao']);
00276 $radio_option = new ilRadioOption($this->lng->txt("search_any_word"),0);
00277 $group->addOption($radio_option);
00278 $radio_option = new ilRadioOption($this->lng->txt("search_all_words"),1);
00279 $group->addOption($radio_option);
00280 $content->addSubItem($group);
00281 $this->form->addItem($content);
00282
00283 $type = new ilSelectInputGUI($this->lng->txt('type'),'type');
00284 $options['adv_all'] = $this->lng->txt('search_any');
00285 foreach(ilAdvancedMDRecord::_getActivatedObjTypes() as $obj_type)
00286 {
00287 $options[$obj_type] = $this->lng->txt('objs_'.$obj_type);
00288 }
00289 $type->setOptions($options);
00290 $type->setValue($this->options['type']);
00291 $this->form->addItem($type);
00292
00293 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
00294 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_SEARCH);
00295 $record_gui->setPropertyForm($this->form);
00296 $record_gui->setSearchValues($this->options);
00297 $record_gui->parse();
00298 }
00299
00305 protected function performAdvMDSearch()
00306 {
00307 global $ilUser;
00308
00309 $this->initSearchType(self::TYPE_ADV_MD);
00310 if(!isset($_GET['page_number']) and $this->search_mode != 'in_results' )
00311 {
00312 unset($_SESSION['adv_max_page']);
00313 $this->search_cache->delete();
00314 }
00315
00316 include_once 'Services/Search/classes/class.ilSearchResult.php';
00317 $res =& new ilSearchResult();
00318
00319 if($res_tit =& $this->__performTitleSearch())
00320 {
00321 $this->__storeEntries($res,$res_tit);
00322 }
00323 $this->searchAdvancedMD($res);
00324
00325 if($this->search_mode == 'in_results')
00326 {
00327 include_once 'Services/Search/classes/class.ilSearchResult.php';
00328
00329 $old_result_obj = new ilSearchResult($ilUser->getId());
00330 $old_result_obj->read(ADVANCED_MD_SEARCH);
00331
00332 $res->diffEntriesFromResult($old_result_obj);
00333 }
00334
00335
00336 $res->filter($this->getRootNode(),true);
00337 $res->save();
00338 $this->showAdvMDSearch();
00339
00340 if(!count($res->getResults()))
00341 {
00342 ilUtil::sendInfo($this->lng->txt('search_no_match'));
00343 }
00344 else
00345 {
00346 $this->__showSearchInResults();
00347 }
00348
00349 if($res->isLimitReached())
00350 {
00351 $message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
00352 ilUtil::sendInfo($message);
00353 }
00354
00355 $this->addPager($res,'adv_max_page');
00356
00357 include_once 'Services/Search/classes/class.ilSearchResultPresentationGUI.php';
00358 $search_result_presentation = new ilSearchResultPresentationGUI($res);
00359 $this->tpl->setVariable("RESULTS",$search_result_presentation->showResults());
00360
00361 return true;
00362
00363 }
00364
00365
00371 public function showAdvMDSearch()
00372 {
00373 if(isset($_SESSION['search_adv_md']))
00374 {
00375 $this->options = $_SESSION['search_adv_md'];
00376 }
00377 $this->setSubTabs();
00378 $this->tabs_gui->setSubTabActive('search_adv_md');
00379
00380 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.advanced_adv_search.html','Services/Search');
00381
00382 $this->initAdvancedMetaDataForm();
00383 $this->tpl->setVariable('SEARCH_FORM',$this->form->getHTML());
00384 return true;
00385 }
00386
00387
00388 function showSearch()
00389 {
00390 global $ilLocator;
00391
00392 $this->setSubTabs();
00393 $this->tabs_gui->setSubTabActive('search_lom');
00394
00395 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.advanced_search.html','Services/Search');
00396
00397
00398 $this->tpl->setVariable("SEARCH_ACTION",$this->ctrl->getFormAction($this));
00399 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('search_advanced'));
00400
00401
00402 $this->tpl->setVariable("TXT_CONTENT",$this->lng->txt('content'));
00403 $this->tpl->setVariable("TXT_OR",$this->lng->txt('search_any_word'));
00404 $this->tpl->setVariable("TXT_AND",$this->lng->txt('search_all_words'));
00405
00406 if($this->options['content_ao'] == 'and')
00407 {
00408 $this->tpl->setVariable("CONTENT_AND_CHECKED",'checked=checked');
00409 }
00410 else
00411 {
00412 $this->tpl->setVariable("CONTENT_OR_CHECKED",'checked=checked');
00413 }
00414 $this->tpl->setVariable("FRM_CONTENT",ilUtil::prepareFormOutput($this->options['content']));
00415
00416
00417 $this->tpl->setVariable("TXT_TYPE",$this->lng->txt('type'));
00418 $this->tpl->setVariable("SEL_TYPE",$this->__getFilterSelect());
00419
00420
00421 $this->tpl->setVariable("TXT_GEN",$this->lng->txt('meta_general'));
00422 $this->tpl->setVariable("TXT_LAN",$this->lng->txt('language'));
00423 $this->tpl->setVariable("SEL_LAN",ilMDUtilSelect::_getLanguageSelect($this->options['language'],
00424 'search_adv[language]'
00425 ,array(0 => $this->lng->txt('meta_please_select'))));
00426
00427 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('meta_title').'/'.
00428 $this->lng->txt('meta_keyword').'/'.
00429 $this->lng->txt('meta_description'));
00430 $this->tpl->setVariable("TXT_COV",$this->lng->txt('meta_coverage'));
00431 $this->tpl->setVariable("TXT_STRUCT",$this->lng->txt('meta_structure'));
00432 $this->tpl->setVariable("SEL_STRUCT",ilMDUtilSelect::_getStructureSelect($this->options['structure'],
00433 'search_adv[structure]',
00434 array(0 => $this->lng->txt('meta_please_select'))));
00435 $this->tpl->setVariable("FRM_TITLE",ilUtil::prepareFormOutput($this->options['title'],true));
00436 $this->tpl->setVariable("FRM_COVERAGE",ilUtil::prepareFormOutput($this->options['coverage'],true));
00437
00438 if($this->options['title_ao'] == 'and')
00439 {
00440 $this->tpl->setVariable("TITLE_AND_CHECKED",'checked=checked');
00441 }
00442 else
00443 {
00444 $this->tpl->setVariable("TITLE_OR_CHECKED",'checked=checked');
00445 }
00446 if($this->options['coverage_ao'] == 'and')
00447 {
00448 $this->tpl->setVariable("COVERAGE_AND_CHECKED",'checked=checked');
00449 }
00450 else
00451 {
00452 $this->tpl->setVariable("COVERAGE_OR_CHECKED",'checked=checked');
00453 }
00454
00455
00456
00457
00458 $this->tpl->setVariable("TXT_LIFECYCLE",$this->lng->txt('meta_lifecycle'));
00459 $this->tpl->setVariable("TXT_STATUS",$this->lng->txt('meta_status'));
00460 $this->tpl->setVariable("SEL_STATUS",
00461 ilMDUtilSelect::_getStatusSelect($this->options['status'],
00462 'search_adv[status]',
00463 array(0 => $this->lng->txt('meta_please_select'))));
00464 $this->tpl->setVariable("TXT_VERSION",$this->lng->txt('meta_version'));
00465 $this->tpl->setVariable("FRM_VERSION",ilUtil::prepareFormOutput($this->options['version'],true));
00466
00467 $this->tpl->setVariable("TXT_CONTRIBUTOR",$this->lng->txt('meta_contribute'));
00468 $this->tpl->setVariable("SEL_CONTRIBUTOR",
00469 ilMDUtilSelect::_getRoleSelect($this->options['role'],
00470 'search_adv[role]',
00471 array(0 => $this->lng->txt('meta_please_select'))));
00472 $this->tpl->setVariable("FRM_ENTITY",ilUtil::prepareFormOutput($this->options['entity'],true));
00473
00474 if($this->options['entity_ao'] == 'and')
00475 {
00476 $this->tpl->setVariable("ENTITY_AND_CHECKED",'checked=checked');
00477 }
00478 else
00479 {
00480 $this->tpl->setVariable("ENTITY_OR_CHECKED",'checked=checked');
00481 }
00482 if($this->options['version_ao'] == 'and')
00483 {
00484 $this->tpl->setVariable("VERSION_AND_CHECKED",'checked=checked');
00485 }
00486 else
00487 {
00488 $this->tpl->setVariable("VERSION_OR_CHECKED",'checked=checked');
00489 }
00490
00491
00492 $this->tpl->setVariable("TXT_TECHNICAL",$this->lng->txt('meta_technical'));
00493 $this->tpl->setVariable("TXT_FORMAT",$this->lng->txt('meta_format'));
00494 $this->tpl->setVariable("TXT_OS",$this->lng->txt('meta_operating_system'));
00495 $this->tpl->setVariable("TXT_BROWSER",$this->lng->txt('meta_browser'));
00496 $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('meta_duration'));
00497 $this->tpl->setVariable("FROM",$this->lng->txt('from'));
00498 $this->tpl->setVariable("TIL",$this->lng->txt('until'));
00499
00500 $this->tpl->setVariable("SEL_FORMAT",
00501 ilMDUtilSelect::_getFormatSelect($this->options['format'],
00502 'search_adv[format]',
00503 array(0 => $this->lng->txt('meta_please_select'))));
00504 $this->tpl->setVariable("SEL_OS",
00505 ilMDUtilSelect::_getOperatingSystemSelect($this->options['os'],
00506 'search_adv[os]',
00507 array(0 => $this->lng->txt('meta_please_select'))));
00508 $this->tpl->setVariable("SEL_BROWSER",
00509 ilMDUtilSelect::_getBrowserSelect($this->options['browser'],
00510 'search_adv[browser]',
00511 array(0 => $this->lng->txt('meta_please_select'))));
00512 $this->tpl->setVariable("SEL_DURATION_1",
00513 ilMDUtilSelect::_getDurationSelect('','md_lan',array(0 => $this->lng->txt('meta_please_select'))));
00514 $this->tpl->setVariable("SEL_DURATION_2",
00515 ilMDUtilSelect::_getDurationSelect('','md_lan',array(0 => $this->lng->txt('meta_please_select'))));
00516
00517
00518 $this->tpl->setVariable("TXT_EDUCATIONAL",$this->lng->txt('meta_education'));
00519 $this->tpl->setVariable("TXT_INTERACTIVITY",$this->lng->txt('meta_interactivity_type'));
00520 $this->tpl->setVariable("TXT_RESOURCE",$this->lng->txt('meta_learning_resource_type'));
00521 $this->tpl->setVariable("TXT_LEVEL",$this->lng->txt('meta_interactivity_level'));
00522 $this->tpl->setVariable("TXT_DENSITY",$this->lng->txt('meta_semantic_density'));
00523 $this->tpl->setVariable("TXT_END_USER",$this->lng->txt('meta_intended_end_user_role'));
00524 $this->tpl->setVariable("TXT_CONTEXT",$this->lng->txt('meta_context'));
00525 $this->tpl->setVariable("TXT_DIFFICULTY",$this->lng->txt('meta_difficulty'));
00526 $this->tpl->setVariable("TXT_AGE_RANGE",$this->lng->txt('meta_typical_age_range'));
00527 $this->tpl->setVariable("TXT_LEARNING_TIME",$this->lng->txt('meta_typical_learning_time'));
00528
00529
00530 $this->tpl->setVariable("SEL_INTERACTIVITY",
00531 ilMDUtilSelect::_getInteractivityTypeSelect($this->options['int_type'],
00532 'search_adv[int_type]',
00533 array(0 => $this->lng->txt('meta_please_select'))));
00534 $this->tpl->setVariable("SEL_RESOURCE",
00535 ilMDUtilSelect::_getLearningResourceTypeSelect($this->options['lea_type'],
00536 'search_adv[lea_type]',
00537 array(0 => $this->lng->txt('meta_please_select'))));
00538 $this->tpl->setVariable("SEL_LEVEL_1",
00539 ilMDUtilSelect::_getInteractivityLevelSelect($this->options['int_level_1'],
00540 'search_adv[int_level_1]',
00541 array(0 => $this->lng->txt('meta_please_select'))));
00542 $this->tpl->setVariable("SEL_LEVEL_2",
00543 ilMDUtilSelect::_getInteractivityLevelSelect($this->options['int_level_2'],
00544 'search_adv[int_level_2]',
00545 array(0 => $this->lng->txt('meta_please_select'))));
00546 $this->tpl->setVariable("SEL_DENSITY_1",
00547 ilMDUtilSelect::_getSemanticDensitySelect($this->options['sem_1'],
00548 'search_adv[sem_1]',
00549 array(0 => $this->lng->txt('meta_please_select'))));
00550 $this->tpl->setVariable("SEL_DENSITY_2",
00551 ilMDUtilSelect::_getSemanticDensitySelect($this->options['sem_2'],
00552 'search_adv[sem_2]',
00553 array(0 => $this->lng->txt('meta_please_select'))));
00554 $this->tpl->setVariable("SEL_END_USER",
00555 ilMDUtilSelect::_getIntendedEndUserRoleSelect($this->options['int_role'],
00556 'search_adv[int_role]',
00557 array(0 => $this->lng->txt('meta_please_select'))));
00558 $this->tpl->setVariable("SEL_CONTEXT",
00559 ilMDUtilSelect::_getContextSelect($this->options['con'],
00560 'search_adv[con]',
00561 array(0 => $this->lng->txt('meta_please_select'))));
00562 $this->tpl->setVariable("SEL_DIFFICULTY_1",
00563 ilMDUtilSelect::_getDifficultySelect($this->options['dif_1'],
00564 'search_adv[dif_1]',
00565 array(0 => $this->lng->txt('meta_please_select'))));
00566 $this->tpl->setVariable("SEL_DIFFICULTY_2",
00567 ilMDUtilSelect::_getDifficultySelect($this->options['dif_2'],
00568 'search_adv[dif_2]',
00569 array(0 => $this->lng->txt('meta_please_select'))));
00570 $this->tpl->setVariable("SEL_AGE_RANGE_1",
00571 ilMDUtilSelect::_getTypicalAgeRangeSelect($this->options['typ_age_1'],
00572 'search_adv[typ_age_1]',
00573 array(0 => $this->lng->txt('meta_please_select'))));
00574 $this->tpl->setVariable("SEL_AGE_RANGE_2",
00575 ilMDUtilSelect::_getTypicalAgeRangeSelect($this->options['typ_age_2'],
00576 'search_adv[typ_age_2]',
00577 array(0 => $this->lng->txt('meta_please_select'))));
00578 $this->tpl->setVariable("SEL_LEARNING_TIME_1",
00579 ilMDUtilSelect::_getTypicalLearningTimeSelect($this->options['typ_lea_1'],
00580 'search_adv[typ_lea_1]',
00581 array(0 => $this->lng->txt('meta_please_select'))));
00582 $this->tpl->setVariable("SEL_LEARNING_TIME_2",
00583 ilMDUtilSelect::_getTypicalLearningTimeSelect($this->options['typ_lea_2'],
00584 'search_adv[typ_lea_2]',
00585 array(0 => $this->lng->txt('meta_please_select'))));
00586
00587
00588 $this->tpl->setVariable("TXT_RIGHTS",$this->lng->txt('meta_rights'));
00589 $this->tpl->setVariable("TXT_COSTS",$this->lng->txt('meta_cost'));
00590 $this->tpl->setVariable("TXT_COPYRIGHT",$this->lng->txt('meta_copyright_and_other_restrictions'));
00591
00592 $this->tpl->setVariable("SEL_COSTS",
00593 ilMDUtilSelect::_getCostsSelect($this->options['costs'],
00594 'search_adv[costs]',array(0 => $this->lng->txt('meta_please_select'))));
00595 $this->tpl->setVariable("SEL_COPYRIGHT",
00596 ilMDUtilSelect::_getCopyrightAndOtherRestrictionsSelect($this->options['copyright'],
00597 'search_adv[copyright]',
00598 array(0 => $this->lng->txt('meta_please_select'))));
00599
00600
00601 $this->tpl->setVariable("TXT_CLASSIFICATION",$this->lng->txt('meta_classification'));
00602 $this->tpl->setVariable("TXT_PURPOSE",$this->lng->txt('meta_purpose'));
00603 $this->tpl->setVariable("TXT_TAXON",$this->lng->txt('meta_taxon'));
00604 $this->tpl->setVariable("TXT_KEYWORD",$this->lng->txt('meta_keyword'));
00605
00606 $this->tpl->setVariable("SEL_PURPOSE",
00607 ilMDUtilSelect::_getPurposeSelect($this->options['purpose'],
00608 'search_adv[purpose]',
00609 array(0 => $this->lng->txt('meta_please_select'))));
00610
00611 if($this->options['taxon_ao'] == 'and')
00612 {
00613 $this->tpl->setVariable("TAXON_AND_CHECKED",'checked=checked');
00614 }
00615 else
00616 {
00617 $this->tpl->setVariable("TAXON_OR_CHECKED",'checked=checked');
00618 }
00619 $this->tpl->setVariable("FRM_TAXON",ilUtil::prepareFormOutput($this->options['taxon'],true));
00620
00621 if($this->options['keyword_ao'] == 'and')
00622 {
00623 $this->tpl->setVariable("KEYWORD_AND_CHECKED",'checked=checked');
00624 }
00625 else
00626 {
00627 $this->tpl->setVariable("KEYWORD_OR_CHECKED",'checked=checked');
00628 }
00629 $this->tpl->setVariable("FRM_KEYWORD",ilUtil::prepareFormOutput($this->options['keyword'],true));
00630
00631 $this->tpl->setVariable("BTN_SEARCH",$this->lng->txt('search'));
00632 $this->tpl->setVariable("BTN_RESET",$this->lng->txt('reset'));
00633
00634 return true;
00635 }
00636
00637 function prepareOutput()
00638 {
00639 parent::prepareOutput();
00640
00641 $this->tpl->setCurrentBlock("header_image");
00642 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_src_b.gif"));
00643 $this->tpl->parseCurrentBlock();
00644
00645 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt('search'));
00646
00647 $this->tpl->addBlockFile("TABS","tabs","tpl.tabs.html");
00648
00649 $this->tpl->setCurrentBlock("tab");
00650 $this->tpl->setVariable("TAB_TYPE","tabinactive");
00651 $this->tpl->setVariable("TAB_LINK",$this->ctrl->getLinkTargetByClass('ilsearchgui'));
00652 $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("search"));
00653 $this->tpl->parseCurrentBlock();
00654
00655 $this->tpl->setCurrentBlock("tab");
00656 $this->tpl->setVariable("TAB_TYPE","tabactive");
00657 $this->tpl->setVariable("TAB_LINK",$this->ctrl->getLinkTarget($this));
00658 $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("search_advanced"));
00659 $this->tpl->parseCurrentBlock();
00660
00661 $this->tpl->setCurrentBlock("tab");
00662 $this->tpl->setVariable("TAB_TYPE","tabinactive");
00663 $this->tpl->setVariable("TAB_LINK",$this->ctrl->getLinkTargetByClass('ilsearchresultgui'));
00664 $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("search_search_results"));
00665 $this->tpl->parseCurrentBlock();
00666
00667 }
00668 function saveResult()
00669 {
00670 include_once 'Services/Search/classes/class.ilUserResult.php';
00671 include_once 'Services/Search/classes/class.ilSearchFolder.php';
00672
00673 global $ilUser;
00674
00675 $this->initSearchType(self::TYPE_LOM);
00676 if(!$_POST['folder'])
00677 {
00678 ilUtil::sendInfo($this->lng->txt('search_select_one'));
00679 $this->showSavedResults();
00680
00681 return false;
00682 }
00683 if(!count($_POST['result']))
00684 {
00685 ilUtil::sendInfo($this->lng->txt('search_select_one_result'));
00686 $this->showSavedResults();
00687
00688 return false;
00689 }
00690
00691 $folder_obj =& new ilSearchFolder($ilUser->getId(),(int) $_POST['folder']);
00692
00693 foreach($_POST['result'] as $ref_id)
00694 {
00695
00696 $title = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
00697 $target = addslashes(serialize(array('type' => ilObject::_lookupType(ilObject::_lookupObjId($ref_id)),
00698 'id' => $ref_id)));
00699
00700 $search_res_obj =& new ilUserResult($ilUser->getId());
00701 $search_res_obj->setTitle($title);
00702 $search_res_obj->setTarget($target);
00703
00704 $folder_obj->assignResult($search_res_obj);
00705 unset($search_res_obj);
00706 }
00707 ilUtil::sendInfo($this->lng->txt('search_results_saved'));
00708 $this->showSavedResults();
00709
00710 }
00711
00712
00713
00720 private function showSavedAdvMDResults()
00721 {
00722 global $ilUser;
00723
00724
00725 include_once 'Services/Search/classes/class.ilSearchResult.php';
00726
00727 $this->initSearchType(self::TYPE_ADV_MD);
00728 $result_obj = new ilSearchResult($ilUser->getId());
00729 $result_obj->read(ADVANCED_MD_SEARCH);
00730
00731 $this->showAdvMDSearch();
00732
00733
00734 if(count($result_obj->getResults()))
00735 {
00736 $this->__showSearchInResults();
00737 $this->addPager($result_obj,'adv_max_page');
00738
00739 include_once 'Services/Search/classes/class.ilSearchResultPresentationGUI.php';
00740 $search_result_presentation = new ilSearchResultPresentationGUI($result_obj);
00741 $this->tpl->setVariable("RESULTS",$search_result_presentation->showResults());
00742 }
00743
00744 return true;
00745 }
00746
00747
00748 function showSavedResults()
00749 {
00750 global $ilUser;
00751
00752
00753 include_once 'Services/Search/classes/class.ilSearchResult.php';
00754
00755 $this->initSearchType(self::TYPE_LOM);
00756 $result_obj = new ilSearchResult($ilUser->getId());
00757 $result_obj->read(ADVANCED_SEARCH);
00758
00759 $this->showSearch();
00760
00761
00762 if(count($result_obj->getResults()))
00763 {
00764 $this->__showSearchInResults();
00765 $this->addPager($result_obj,'adv_max_page');
00766
00767 include_once 'Services/Search/classes/class.ilSearchResultPresentationGUI.php';
00768 $search_result_presentation = new ilSearchResultPresentationGUI($result_obj);
00769 $this->tpl->setVariable("RESULTS",$search_result_presentation->showResults());
00770 }
00771
00772 return true;
00773 }
00774
00775 function &__performContentSearch()
00776 {
00777 if(!$this->options['content'])
00778 {
00779 return false;
00780 }
00781 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00782 include_once 'Services/Search/classes/class.ilQueryParser.php';
00783 include_once 'Services/Search/classes/class.ilSearchResult.php';
00784
00785 $res =& new ilSearchResult();
00786
00787
00788 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['content']));
00789 $query_parser->setCombination($this->options['content_ao']);
00790 $query_parser->parse();
00791
00792 if($this->options['type'] == 'all' or $this->options['type'] == 'lms')
00793 {
00794
00795 $lm_search =& ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
00796 $res_cont =& $lm_search->performSearch();
00797 $res->mergeEntries($res_cont);
00798
00799 if($this->settings->enabledLucene())
00800 {
00801
00802
00803 $htlm_search =& ilObjectSearchFactory::_getHTLMSearchInstance($query_parser);
00804 $res_htlm =& $htlm_search->performSearch();
00805 $res->mergeEntries($res_htlm);
00806 }
00807 }
00808 if($this->options['type'] == 'all' or $this->options['type'] == 'tst')
00809 {
00810 $tst_search =& ilObjectSearchFactory::_getTestSearchInstance($query_parser);
00811 $res_tes =& $tst_search->performSearch();
00812 $res->mergeEntries($res_tes);
00813 }
00814 if($this->options['type'] == 'all' or $this->options['type'] == 'mep')
00815 {
00816 $med_search =& ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
00817 $res_med =& $med_search->performSearch();
00818 $res->mergeEntries($res_med);
00819 }
00820 if($this->options['type'] == 'all' or $this->options['type'] == 'glo')
00821 {
00822 $glo_search =& ilObjectSearchFactory::_getGlossaryDefinitionSearchInstance($query_parser);
00823 $res_glo =& $glo_search->performSearch();
00824 $res->mergeEntries($res_glo);
00825 }
00826 if($this->options['type'] == 'all' or $this->options['type'] == 'webr')
00827 {
00828 $web_search =& ilObjectSearchFactory::_getWebresourceSearchInstance($query_parser);
00829 $res_web =& $web_search->performSearch();
00830 $res->mergeEntries($res_web);
00831 }
00832
00833 return $res;
00834 }
00835
00836
00837 function &__performTitleSearch()
00838 {
00839 if(!$this->options['title'])
00840 {
00841 return false;
00842 }
00843 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00844 include_once 'Services/Search/classes/class.ilQueryParser.php';
00845
00846 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['title']));
00847 $query_parser->setCombination($this->options['title_ao']);
00848 $query_parser->parse();
00849 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00850 $meta_search->setFilter($this->filter);
00851 $meta_search->setMode('title_description');
00852 $meta_search->setOptions($this->options);
00853 $res_tit =& $meta_search->performSearch();
00854
00855 $meta_search->setMode('keyword_all');
00856 $res_key =& $meta_search->performSearch();
00857
00858
00859 $res_tit->mergeEntries($res_key);
00860
00861 return $res_tit;
00862 }
00863
00864
00865
00866 function &__performGeneralSearch()
00867 {
00868 if(!$this->options['coverage'] and !$this->options['structure'])
00869 {
00870 return false;
00871 }
00872
00873 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00874 include_once 'Services/Search/classes/class.ilQueryParser.php';
00875
00876 if($this->options['coverage'])
00877 {
00878 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['coverage']));
00879 $query_parser->setCombination($this->options['coverage_ao']);
00880 $query_parser->parse();
00881 }
00882 else
00883 {
00884 $query_parser = new ilQueryParser('');
00885 }
00886 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00887 $meta_search->setFilter($this->filter);
00888 $meta_search->setMode('general');
00889 $meta_search->setOptions($this->options);
00890 $res =& $meta_search->performSearch();
00891
00892 return $res;
00893 }
00894
00895 function &__performLifecycleSearch()
00896 {
00897
00898 if(!$this->options['status'] and !$this->options['version'])
00899 {
00900 return false;
00901 }
00902 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00903 include_once 'Services/Search/classes/class.ilQueryParser.php';
00904
00905 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['version']));
00906 $query_parser->setCombination($this->options['version_ao']);
00907 $query_parser->parse();
00908
00909 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00910 $meta_search->setFilter($this->filter);
00911 $meta_search->setMode('lifecycle');
00912 $meta_search->setOptions($this->options);
00913 $res =& $meta_search->performSearch();
00914
00915 return $res;
00916 }
00917 function &__performLanguageSearch()
00918 {
00919 if(!$this->options['language'])
00920 {
00921 return false;
00922 }
00923 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00924 include_once 'Services/Search/classes/class.ilQueryParser.php';
00925
00926
00927 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00928 $meta_search->setFilter($this->filter);
00929 $meta_search->setMode('language');
00930 $meta_search->setOptions($this->options);
00931 $res =& $meta_search->performSearch();
00932
00933 return $res;
00934 }
00935 function &__performContributeSearch()
00936 {
00937 if(!strlen($this->options['role']))
00938 {
00939 return false;
00940 }
00941 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00942 include_once 'Services/Search/classes/class.ilQueryParser.php';
00943
00944
00945 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00946 $meta_search->setFilter($this->filter);
00947 $meta_search->setMode('contribute');
00948 $meta_search->setOptions($this->options);
00949 $res =& $meta_search->performSearch();
00950
00951 return $res;
00952 }
00953 function &__performEntitySearch()
00954 {
00955
00956 if(!$this->options['entity'])
00957 {
00958 return false;
00959 }
00960 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00961 include_once 'Services/Search/classes/class.ilQueryParser.php';
00962
00963 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['entity']));
00964 $query_parser->setCombination($this->options['entity_ao']);
00965 $query_parser->parse();
00966
00967 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00968 $meta_search->setFilter($this->filter);
00969 $meta_search->setMode('entity');
00970 $meta_search->setOptions($this->options);
00971 $res =& $meta_search->performSearch();
00972
00973 return $res;
00974 }
00975
00976
00977 function &__performRequirementSearch()
00978 {
00979 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00980 include_once 'Services/Search/classes/class.ilQueryParser.php';
00981
00982
00983 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00984 $meta_search->setFilter($this->filter);
00985 $meta_search->setMode('requirement');
00986 $meta_search->setOptions($this->options);
00987 $res =& $meta_search->performSearch();
00988
00989 return $res;
00990 }
00991 function &__performFormatSearch()
00992 {
00993 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00994 include_once 'Services/Search/classes/class.ilQueryParser.php';
00995
00996
00997 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00998 $meta_search->setFilter($this->filter);
00999 $meta_search->setMode('format');
01000 $meta_search->setOptions($this->options);
01001 $res =& $meta_search->performSearch();
01002
01003 return $res;
01004 }
01005 function &__performEducationalSearch()
01006 {
01007 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
01008 include_once 'Services/Search/classes/class.ilQueryParser.php';
01009
01010
01011 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
01012 $meta_search->setFilter($this->filter);
01013 $meta_search->setMode('educational');
01014 $meta_search->setOptions($this->options);
01015 $res =& $meta_search->performSearch();
01016
01017 return $res;
01018 }
01019 function &__performTypicalAgeRangeSearch()
01020 {
01021 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
01022 include_once 'Services/Search/classes/class.ilQueryParser.php';
01023
01024
01025 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
01026 $meta_search->setFilter($this->filter);
01027 $meta_search->setMode('typical_age_range');
01028 $meta_search->setOptions($this->options);
01029 $res =& $meta_search->performSearch();
01030
01031 return $res;
01032 }
01033 function &__performRightsSearch()
01034 {
01035 if(!$this->options['copyright'] and !$this->options['costs'])
01036 {
01037 return false;
01038 }
01039 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
01040 include_once 'Services/Search/classes/class.ilQueryParser.php';
01041
01042
01043 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
01044 $meta_search->setFilter($this->filter);
01045 $meta_search->setMode('rights');
01046 $meta_search->setOptions($this->options);
01047 $res =& $meta_search->performSearch();
01048
01049 return $res;
01050 }
01051
01052 function &__performClassificationSearch()
01053 {
01054
01055 if(!$this->options['purpose'])
01056 {
01057 return false;
01058 }
01059 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
01060 include_once 'Services/Search/classes/class.ilQueryParser.php';
01061
01062
01063 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
01064 $meta_search->setFilter($this->filter);
01065 $meta_search->setMode('classification');
01066 $meta_search->setOptions($this->options);
01067 $res =& $meta_search->performSearch();
01068
01069 return $res;
01070 }
01071
01072 function &__performTaxonSearch()
01073 {
01074
01075 if(!$this->options['taxon'])
01076 {
01077 return false;
01078 }
01079 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
01080 include_once 'Services/Search/classes/class.ilQueryParser.php';
01081
01082 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['taxon']));
01083 $query_parser->setCombination($this->options['taxon_ao']);
01084 $query_parser->parse();
01085
01086 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
01087 $meta_search->setFilter($this->filter);
01088 $meta_search->setMode('taxon');
01089 $meta_search->setOptions($this->options);
01090 $res =& $meta_search->performSearch();
01091
01092 return $res;
01093 }
01094
01102 private function searchAdvancedMD($res)
01103 {
01104 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
01105 foreach($_POST as $key => $value)
01106 {
01107 if(!is_numeric($key))
01108 {
01109 continue;
01110 }
01111 if(!$value)
01112 {
01113 continue;
01114 }
01115
01116 $def = ilAdvancedMDFieldDefinition::_getInstanceByFieldId($key);
01117 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
01118 include_once 'Services/Search/classes/class.ilQueryParser.php';
01119
01120 if($def->getFieldType() == ilAdvancedMDFieldDefinition::TYPE_SELECT)
01121 {
01122 $value = (int) $value;
01123 $options = $def->getFieldValues();
01124 if(!isset($options[$value - 1]))
01125 {
01126 continue;
01127 }
01128 $value = $options[$value - 1];
01129 }
01130 if($def->getFieldType() == ilAdvancedMDFieldDefinition::TYPE_DATE)
01131 {
01132 $start = $this->toUnixTime($_POST['date_start'][$key]['date']);
01133 $end = $this->toUnixTime($_POST['date_end'][$key]['date']);
01134
01135 }
01136
01137 $query_parser = new ilQueryParser(ilUtil::stripSlashes($value));
01138 if($_POST['boolean'][$key] == 1)
01139 {
01140 $query_parser->setCombination('and');
01141 }
01142 else
01143 {
01144 $query_parser->setCombination('or');
01145 }
01146 $query_parser->parse();
01147
01148 $adv_md_search = ilObjectSearchFactory::_getAdvancedMDSearchInstance($query_parser);
01149 $adv_md_search->setDefinition($def);
01150 $adv_md_search->setTimeRange($start,$end);
01151 $adv_md_search->setFilter($this->filter);
01152 $res_field = $adv_md_search->performSearch();
01153 $this->__storeEntries($res,$res_field);
01154
01155 }
01156 return $res;
01157 }
01158
01159 function &__performKeywordSearch()
01160 {
01161
01162 if(!$this->options['keyword'])
01163 {
01164 return false;
01165 }
01166 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
01167 include_once 'Services/Search/classes/class.ilQueryParser.php';
01168
01169 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['keyword']));
01170 $query_parser->setCombination($this->options['keyword_ao']);
01171 $query_parser->parse();
01172
01173 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
01174 $meta_search->setFilter($this->filter);
01175 $meta_search->setMode('keyword');
01176 $meta_search->setOptions($this->options);
01177 $res =& $meta_search->performSearch();
01178
01179 return $res;
01180 }
01181
01182 function __setSearchOptions(&$post_vars)
01183 {
01184 if(isset($_POST['cmd']['performSearch']))
01185 {
01186 $this->options = $_SESSION['search_adv'] = $_POST['search_adv'];
01187 }
01188 elseif(isset($_POST['cmd']['performAdvMDSearch']))
01189 {
01190 $this->options = $_SESSION['search_adv_md'] = $_POST;
01191 }
01192 else
01193 {
01194 $this->options = $_SESSION['search_adv'];
01195 }
01196
01197 $_POST['result'] = $_POST['id'];
01198
01199 $this->filter = array();
01200
01201 switch($this->options['type'])
01202 {
01203 case 'cat':
01204 $this->filter[] = 'cat';
01205 break;
01206
01207 case 'webr':
01208 $this->filter[] = 'webr';
01209 break;
01210
01211 case 'lms':
01212 $this->filter[] = 'lm';
01213 $this->filter[] = 'dbk';
01214 $this->filter[] = 'pg';
01215 $this->filter[] = 'st';
01216 $this->filter[] = 'sahs';
01217 $this->filter[] = 'htlm';
01218 break;
01219
01220 case 'glo':
01221 $this->filter[] = 'glo';
01222 break;
01223
01224 case 'tst':
01225 $this->filter[] = 'tst';
01226 $this->filter[] = 'svy';
01227 $this->filter[] = 'qpl';
01228 $this->filter[] = 'spl';
01229 break;
01230
01231 case 'mep':
01232 $this->filter[] = 'mep';
01233 break;
01234
01235 case 'crs':
01236 $this->filter[] = 'crs';
01237 break;
01238
01239 case 'file':
01240 $this->filter[] = 'file';
01241 break;
01242
01243 case 'adv_all':
01244 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
01245 $this->filter = ilAdvancedMDRecord::_getActivatedObjTypes();
01246 break;
01247
01248 case 'all':
01249 default:
01250 $this->filter[] = 'webr';
01251 $this->filter[] = 'crs';
01252 $this->filter[] = 'mep';
01253 $this->filter[] = 'tst';
01254 $this->filter[] = 'svy';
01255 $this->filter[] = 'qpl';
01256 $this->filter[] = 'spl';
01257 $this->filter[] = 'glo';
01258 $this->filter[] = 'lm';
01259 $this->filter[] = 'dbk';
01260 $this->filter[] = 'pg';
01261 $this->filter[] = 'st';
01262 $this->filter[] = 'sahs';
01263 $this->filter[] = 'htlm';
01264 $this->filter[] = 'file';
01265 }
01266 return true;
01267 }
01268
01269 function __getFilterSelect()
01270 {
01271 $options = array('all' => $this->lng->txt('search_any'),
01272 'crs' => $this->lng->txt('objs_crs'),
01273 'lms' => $this->lng->txt('learning_resources'),
01274 'glo' => $this->lng->txt('objs_glo'),
01275 'mep' => $this->lng->txt('objs_mep'),
01276 'tst' => $this->lng->txt('search_tst_svy'),
01277 'file'=> $this->lng->txt('objs_file'),
01278 'webr' => $this->lng->txt('objs_webr'));
01279
01280
01281 return ilUtil::formSelect($this->options['type'],'search_adv[type]',$options,false,true);
01282 }
01283
01284
01285 function __storeEntries(&$res,&$new_res)
01286 {
01287
01288 if($this->stored == false)
01289 {
01290
01291
01292 $res->mergeEntries($new_res);
01293 $this->stored = true;
01294
01295 return true;
01296 }
01297 else
01298 {
01299 $res->intersectEntries($new_res);
01300
01301 return true;
01302 }
01303 }
01309 function __showSearchInResults()
01310 {
01311 $this->tpl->setCurrentBlock("search_results");
01312 $this->tpl->setVariable("BTN_SEARCHRESULTS",$this->lng->txt('search_in_result'));
01313 $this->tpl->parseCurrentBlock();
01314
01315 $this->tpl->setCurrentBlock("save_result");
01316 $this->tpl->setVariable("DOWNRIGHT",ilUtil::getImagePath('arrow_downright.gif'));
01317 $this->tpl->setVariable("BTN_SAVE_RESULT",$this->lng->txt('save'));
01318 $this->tpl->setVariable("SELECT_FOLDER",$this->__getFolderSelect());
01319 $this->tpl->parseCurrentBlock();
01320
01321 return true;
01322 }
01323 function __getFolderSelect()
01324 {
01325 global $ilUser;
01326
01327 include_once 'Services/Search/classes/class.ilSearchFolder.php';
01328
01329
01330 $folder_obj =& new ilSearchFolder($ilUser->getId());
01331
01332
01333 $subtree = $folder_obj->getSubtree();
01334
01335 $options[0] = $this->lng->txt("search_select_one_folder_select");
01336 $options[$folder_obj->getRootId()] = $this->lng->txt("search_save_as_select")." ".$this->lng->txt("search_search_results");
01337
01338 foreach($subtree as $node)
01339 {
01340 if($node["obj_id"] == $folder_obj->getRootId())
01341 {
01342 continue;
01343 }
01344
01345 $prefix = $this->lng->txt("search_save_as_select");
01346 for($i = 1; $i < $node["depth"];++$i)
01347 {
01348 $prefix .= " ";
01349 }
01350 $options[$node["obj_id"]] = $prefix.$node["title"];
01351 }
01352 return ilUtil::formSelect(0,'folder',$options,false,true);
01353 }
01354
01361 private function initUserSearchCache()
01362 {
01363 global $ilUser;
01364
01365 include_once('Services/Search/classes/class.ilUserSearchCache.php');
01366 $this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
01367 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH);
01368 if($_GET['page_number'])
01369 {
01370 $this->search_cache->setResultPageNumber((int) $_GET['page_number']);
01371 }
01372 }
01373
01380 public function setSubTabs()
01381 {
01382 global $ilTabs;
01383
01384 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
01385 if(!count(ilAdvancedMDFieldDefinition::_getSearchableDefinitionIds()))
01386 {
01387 return true;
01388 }
01389 $ilTabs->addSubTabTarget('search_lom',$this->ctrl->getLinkTarget($this,'showSavedResults'));
01390 $ilTabs->addSubTabTarget('search_adv_md',$this->ctrl->getLinkTarget($this,'showSavedAdvMDResults'));
01391
01392 }
01393
01401 private function toUnixTime($date)
01402 {
01403 return mktime(0,0,0,$date['m'],$date['d'],$date['y']);
01404 }
01405
01413 private function initSearchType($type)
01414 {
01415 if($type == self::TYPE_LOM)
01416 {
01417 $_SESSION['search_last_sub_section'] = self::TYPE_LOM;
01418 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH);
01419 }
01420 else
01421 {
01422 $_SESSION['search_last_sub_section'] = self::TYPE_ADV_MD;
01423 $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_MD_SEARCH);
01424 }
01425 }
01426 }
01427 ?>