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
00045 var $options = array();
00046
00051 function ilAdvancedSearchGUI()
00052 {
00053 parent::ilSearchBaseGUI();
00054
00055 $this->lng->loadLanguageModule('meta');
00056
00057 $this->__setSearchOptions($_POST);
00058 }
00059
00060 function getRootNode()
00061 {
00062 return ROOT_FOLDER_ID;
00063 }
00064
00065
00070 function &executeCommand()
00071 {
00072 global $rbacsystem;
00073
00074 $next_class = $this->ctrl->getNextClass($this);
00075 $cmd = $this->ctrl->getCmd();
00076
00077 switch($next_class)
00078 {
00079 default:
00080 if(!$cmd)
00081 {
00082 $cmd = "showSavedResults";
00083 }
00084
00085 $this->prepareOutput();
00086 $this->$cmd();
00087 break;
00088 }
00089 return true;
00090 }
00091 function reset()
00092 {
00093 $this->options = array();
00094 $this->showSearch();
00095 }
00096
00097 function searchInResults()
00098 {
00099 $this->search_mode = 'in_results';
00100 $this->performSearch();
00101
00102 return true;
00103 }
00104
00105
00106 function performSearch()
00107 {
00108 global $ilUser;
00109
00110 include_once 'Services/Search/classes/class.ilSearchResult.php';
00111
00112 $res =& new ilSearchResult();
00113
00114 if($res_con =& $this->__performContentSearch())
00115 {
00116 $this->__storeEntries($res,$res_con);
00117 }
00118 if($res_tit =& $this->__performTitleSearch())
00119 {
00120 $this->__storeEntries($res,$res_tit);
00121 }
00122 if($res_lan =& $this->__performLanguageSearch())
00123 {
00124 $this->__storeEntries($res,$res_lan);
00125 }
00126 if($res_gen =& $this->__performGeneralSearch())
00127 {
00128 $this->__storeEntries($res,$res_gen);
00129 }
00130 if($res_lif =& $this->__performLifecycleSearch())
00131 {
00132 $this->__storeEntries($res,$res_lif);
00133 }
00134 if($res_con =& $this->__performContributeSearch())
00135 {
00136 $this->__storeEntries($res,$res_con);
00137 }
00138 if($res_ent =& $this->__performEntitySearch())
00139 {
00140 $this->__storeEntries($res,$res_ent);
00141 }
00142 if($res_req =& $this->__performRequirementSearch())
00143 {
00144 $this->__storeEntries($res,$res_req);
00145 }
00146 if($res_for =& $this->__performFormatSearch())
00147 {
00148 $this->__storeEntries($res,$res_for);
00149 }
00150 if($res_edu =& $this->__performEducationalSearch())
00151 {
00152 $this->__storeEntries($res,$res_edu);
00153 }
00154 if($res_typ =& $this->__performTypicalAgeRangeSearch())
00155 {
00156 $this->__storeEntries($res,$res_typ);
00157 }
00158 if($res_rig =& $this->__performRightsSearch())
00159 {
00160 $this->__storeEntries($res,$res_rig);
00161 }
00162 if($res_cla =& $this->__performClassificationSearch())
00163 {
00164 $this->__storeEntries($res,$res_cla);
00165 }
00166 if($res_tax =& $this->__performTaxonSearch())
00167 {
00168 $this->__storeEntries($res,$res_tax);
00169 }
00170 if($res_key =& $this->__performKeywordSearch())
00171 {
00172 $this->__storeEntries($res,$res_key);
00173 }
00174
00175 if($this->search_mode == 'in_results')
00176 {
00177 include_once 'Services/Search/classes/class.ilSearchResult.php';
00178
00179 $old_result_obj = new ilSearchResult($ilUser->getId());
00180 $old_result_obj->read(ADVANCED_SEARCH);
00181
00182 $res->diffEntriesFromResult($old_result_obj);
00183 }
00184
00185
00186 $res->filter($this->getRootNode(),true);
00187
00188 if(!count($res->getResults()))
00189 {
00190 sendInfo($this->lng->txt('search_no_match'));
00191 }
00192 else
00193 {
00194 $this->__showSearchInResults();
00195 }
00196
00197 if($res->isLimitReached())
00198 {
00199 $message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
00200 sendInfo($message);
00201 }
00202
00203 $this->showSearch();
00204
00205 include_once 'Services/Search/classes/class.ilSearchResultPresentationGUI.php';
00206
00207 $search_result_presentation = new ilSearchResultPresentationGUI($res);
00208 $this->tpl->setVariable("RESULTS",$search_result_presentation->showResults());
00209
00210 $res->setUserId($ilUser->getId());
00211 $res->save(ADVANCED_SEARCH);
00212
00213
00214 return true;
00215 }
00216
00217
00218 function showSearch()
00219 {
00220 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.advanced_search.html','Services/Search');
00221
00222
00223 $this->tpl->setVariable("SEARCH_ACTION",$this->ctrl->getFormAction($this));
00224 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('search_advanced'));
00225
00226
00227 $this->tpl->setVariable("TXT_CONTENT",$this->lng->txt('content'));
00228 $this->tpl->setVariable("TXT_OR",$this->lng->txt('search_any_word'));
00229 $this->tpl->setVariable("TXT_AND",$this->lng->txt('search_all_words'));
00230
00231 if($this->options['content_ao'] == 'and')
00232 {
00233 $this->tpl->setVariable("CONTENT_AND_CHECKED",'checked=checked');
00234 }
00235 else
00236 {
00237 $this->tpl->setVariable("CONTENT_OR_CHECKED",'checked=checked');
00238 }
00239 $this->tpl->setVariable("FRM_CONTENT",ilUtil::prepareFormOutput($this->options['content']));
00240
00241
00242 $this->tpl->setVariable("TXT_TYPE",$this->lng->txt('type'));
00243 $this->tpl->setVariable("SEL_TYPE",$this->__getFilterSelect());
00244
00245
00246 $this->tpl->setVariable("TXT_GEN",$this->lng->txt('meta_general'));
00247 $this->tpl->setVariable("TXT_LAN",$this->lng->txt('language'));
00248 $this->tpl->setVariable("SEL_LAN",ilMDUtilSelect::_getLanguageSelect($this->options['language'],
00249 'search_adv[language]'
00250 ,array(0 => $this->lng->txt('meta_please_select'))));
00251
00252 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('meta_title').'/'.
00253 $this->lng->txt('meta_keyword').'/'.
00254 $this->lng->txt('meta_description'));
00255 $this->tpl->setVariable("TXT_COV",$this->lng->txt('meta_coverage'));
00256 $this->tpl->setVariable("TXT_STRUCT",$this->lng->txt('meta_structure'));
00257 $this->tpl->setVariable("SEL_STRUCT",ilMDUtilSelect::_getStructureSelect($this->options['structure'],
00258 'search_adv[structure]',
00259 array(0 => $this->lng->txt('meta_please_select'))));
00260 $this->tpl->setVariable("FRM_TITLE",ilUtil::prepareFormOutput($this->options['title'],true));
00261 $this->tpl->setVariable("FRM_COVERAGE",ilUtil::prepareFormOutput($this->options['coverage'],true));
00262
00263 if($this->options['title_ao'] == 'and')
00264 {
00265 $this->tpl->setVariable("TITLE_AND_CHECKED",'checked=checked');
00266 }
00267 else
00268 {
00269 $this->tpl->setVariable("TITLE_OR_CHECKED",'checked=checked');
00270 }
00271 if($this->options['coverage_ao'] == 'and')
00272 {
00273 $this->tpl->setVariable("COVERAGE_AND_CHECKED",'checked=checked');
00274 }
00275 else
00276 {
00277 $this->tpl->setVariable("COVERAGE_OR_CHECKED",'checked=checked');
00278 }
00279
00280
00281
00282
00283 $this->tpl->setVariable("TXT_LIFECYCLE",$this->lng->txt('meta_lifecycle'));
00284 $this->tpl->setVariable("TXT_STATUS",$this->lng->txt('meta_status'));
00285 $this->tpl->setVariable("SEL_STATUS",
00286 ilMDUtilSelect::_getStatusSelect($this->options['status'],
00287 'search_adv[status]',
00288 array(0 => $this->lng->txt('meta_please_select'))));
00289 $this->tpl->setVariable("TXT_VERSION",$this->lng->txt('meta_version'));
00290 $this->tpl->setVariable("FRM_VERSION",ilUtil::prepareFormOutput($this->options['version'],true));
00291
00292 $this->tpl->setVariable("TXT_CONTRIBUTOR",$this->lng->txt('meta_contribute'));
00293 $this->tpl->setVariable("SEL_CONTRIBUTOR",
00294 ilMDUtilSelect::_getRoleSelect($this->options['role'],
00295 'search_adv[role]',
00296 array(0 => $this->lng->txt('meta_please_select'))));
00297 $this->tpl->setVariable("FRM_ENTITY",ilUtil::prepareFormOutput($this->options['entity'],true));
00298
00299 if($this->options['entity_ao'] == 'and')
00300 {
00301 $this->tpl->setVariable("ENTITY_AND_CHECKED",'checked=checked');
00302 }
00303 else
00304 {
00305 $this->tpl->setVariable("ENTITY_OR_CHECKED",'checked=checked');
00306 }
00307 if($this->options['version_ao'] == 'and')
00308 {
00309 $this->tpl->setVariable("VERSION_AND_CHECKED",'checked=checked');
00310 }
00311 else
00312 {
00313 $this->tpl->setVariable("VERSION_OR_CHECKED",'checked=checked');
00314 }
00315
00316
00317 $this->tpl->setVariable("TXT_TECHNICAL",$this->lng->txt('meta_technical'));
00318 $this->tpl->setVariable("TXT_FORMAT",$this->lng->txt('meta_format'));
00319 $this->tpl->setVariable("TXT_OS",$this->lng->txt('meta_operating_system'));
00320 $this->tpl->setVariable("TXT_BROWSER",$this->lng->txt('meta_browser'));
00321 $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('meta_duration'));
00322 $this->tpl->setVariable("FROM",$this->lng->txt('from'));
00323 $this->tpl->setVariable("TIL",$this->lng->txt('until'));
00324
00325 $this->tpl->setVariable("SEL_FORMAT",
00326 ilMDUtilSelect::_getFormatSelect($this->options['format'],
00327 'search_adv[format]',
00328 array(0 => $this->lng->txt('meta_please_select'))));
00329 $this->tpl->setVariable("SEL_OS",
00330 ilMDUtilSelect::_getOperatingSystemSelect($this->options['os'],
00331 'search_adv[os]',
00332 array(0 => $this->lng->txt('meta_please_select'))));
00333 $this->tpl->setVariable("SEL_BROWSER",
00334 ilMDUtilSelect::_getBrowserSelect($this->options['browser'],
00335 'search_adv[browser]',
00336 array(0 => $this->lng->txt('meta_please_select'))));
00337 $this->tpl->setVariable("SEL_DURATION_1",
00338 ilMDUtilSelect::_getDurationSelect('','md_lan',array(0 => $this->lng->txt('meta_please_select'))));
00339 $this->tpl->setVariable("SEL_DURATION_2",
00340 ilMDUtilSelect::_getDurationSelect('','md_lan',array(0 => $this->lng->txt('meta_please_select'))));
00341
00342
00343 $this->tpl->setVariable("TXT_EDUCATIONAL",$this->lng->txt('meta_education'));
00344 $this->tpl->setVariable("TXT_INTERACTIVITY",$this->lng->txt('meta_interactivity_type'));
00345 $this->tpl->setVariable("TXT_RESOURCE",$this->lng->txt('meta_learning_resource_type'));
00346 $this->tpl->setVariable("TXT_LEVEL",$this->lng->txt('meta_interactivity_level'));
00347 $this->tpl->setVariable("TXT_DENSITY",$this->lng->txt('meta_semantic_density'));
00348 $this->tpl->setVariable("TXT_END_USER",$this->lng->txt('meta_intended_end_user_role'));
00349 $this->tpl->setVariable("TXT_CONTEXT",$this->lng->txt('meta_context'));
00350 $this->tpl->setVariable("TXT_DIFFICULTY",$this->lng->txt('meta_difficulty'));
00351 $this->tpl->setVariable("TXT_AGE_RANGE",$this->lng->txt('meta_typical_age_range'));
00352 $this->tpl->setVariable("TXT_LEARNING_TIME",$this->lng->txt('meta_typical_learning_time'));
00353
00354
00355 $this->tpl->setVariable("SEL_INTERACTIVITY",
00356 ilMDUtilSelect::_getInteractivityTypeSelect($this->options['int_type'],
00357 'search_adv[int_type]',
00358 array(0 => $this->lng->txt('meta_please_select'))));
00359 $this->tpl->setVariable("SEL_RESOURCE",
00360 ilMDUtilSelect::_getLearningResourceTypeSelect($this->options['lea_type'],
00361 'search_adv[lea_type]',
00362 array(0 => $this->lng->txt('meta_please_select'))));
00363 $this->tpl->setVariable("SEL_LEVEL_1",
00364 ilMDUtilSelect::_getInteractivityLevelSelect($this->options['int_level_1'],
00365 'search_adv[int_level_1]',
00366 array(0 => $this->lng->txt('meta_please_select'))));
00367 $this->tpl->setVariable("SEL_LEVEL_2",
00368 ilMDUtilSelect::_getInteractivityLevelSelect($this->options['int_level_2'],
00369 'search_adv[int_level_2]',
00370 array(0 => $this->lng->txt('meta_please_select'))));
00371 $this->tpl->setVariable("SEL_DENSITY_1",
00372 ilMDUtilSelect::_getSemanticDensitySelect($this->options['sem_1'],
00373 'search_adv[sem_1]',
00374 array(0 => $this->lng->txt('meta_please_select'))));
00375 $this->tpl->setVariable("SEL_DENSITY_2",
00376 ilMDUtilSelect::_getSemanticDensitySelect($this->options['sem_2'],
00377 'search_adv[sem_2]',
00378 array(0 => $this->lng->txt('meta_please_select'))));
00379 $this->tpl->setVariable("SEL_END_USER",
00380 ilMDUtilSelect::_getIntendedEndUserRoleSelect($this->options['int_role'],
00381 'search_adv[int_role]',
00382 array(0 => $this->lng->txt('meta_please_select'))));
00383 $this->tpl->setVariable("SEL_CONTEXT",
00384 ilMDUtilSelect::_getContextSelect($this->options['con'],
00385 'search_adv[con]',
00386 array(0 => $this->lng->txt('meta_please_select'))));
00387 $this->tpl->setVariable("SEL_DIFFICULTY_1",
00388 ilMDUtilSelect::_getDifficultySelect($this->options['dif_1'],
00389 'search_adv[dif_1]',
00390 array(0 => $this->lng->txt('meta_please_select'))));
00391 $this->tpl->setVariable("SEL_DIFFICULTY_2",
00392 ilMDUtilSelect::_getDifficultySelect($this->options['dif_2'],
00393 'search_adv[dif_2]',
00394 array(0 => $this->lng->txt('meta_please_select'))));
00395 $this->tpl->setVariable("SEL_AGE_RANGE_1",
00396 ilMDUtilSelect::_getTypicalAgeRangeSelect($this->options['typ_age_1'],
00397 'search_adv[typ_age_1]',
00398 array(0 => $this->lng->txt('meta_please_select'))));
00399 $this->tpl->setVariable("SEL_AGE_RANGE_2",
00400 ilMDUtilSelect::_getTypicalAgeRangeSelect($this->options['typ_age_2'],
00401 'search_adv[typ_age_2]',
00402 array(0 => $this->lng->txt('meta_please_select'))));
00403 $this->tpl->setVariable("SEL_LEARNING_TIME_1",
00404 ilMDUtilSelect::_getTypicalLearningTimeSelect($this->options['typ_lea_1'],
00405 'search_adv[typ_lea_1]',
00406 array(0 => $this->lng->txt('meta_please_select'))));
00407 $this->tpl->setVariable("SEL_LEARNING_TIME_2",
00408 ilMDUtilSelect::_getTypicalLearningTimeSelect($this->options['typ_lea_2'],
00409 'search_adv[typ_lea_2]',
00410 array(0 => $this->lng->txt('meta_please_select'))));
00411
00412
00413 $this->tpl->setVariable("TXT_RIGHTS",$this->lng->txt('meta_rights'));
00414 $this->tpl->setVariable("TXT_COSTS",$this->lng->txt('meta_cost'));
00415 $this->tpl->setVariable("TXT_COPYRIGHT",$this->lng->txt('meta_copyright_and_other_restrictions'));
00416
00417 $this->tpl->setVariable("SEL_COSTS",
00418 ilMDUtilSelect::_getCostsSelect($this->options['costs'],
00419 'search_adv[costs]',array(0 => $this->lng->txt('meta_please_select'))));
00420 $this->tpl->setVariable("SEL_COPYRIGHT",
00421 ilMDUtilSelect::_getCopyrightAndOtherRestrictionsSelect($this->options['copyright'],
00422 'search_adv[copyright]',
00423 array(0 => $this->lng->txt('meta_please_select'))));
00424
00425
00426 $this->tpl->setVariable("TXT_CLASSIFICATION",$this->lng->txt('meta_classification'));
00427 $this->tpl->setVariable("TXT_PURPOSE",$this->lng->txt('meta_purpose'));
00428 $this->tpl->setVariable("TXT_TAXON",$this->lng->txt('meta_taxon'));
00429 $this->tpl->setVariable("TXT_KEYWORD",$this->lng->txt('meta_keyword'));
00430
00431 $this->tpl->setVariable("SEL_PURPOSE",
00432 ilMDUtilSelect::_getPurposeSelect($this->options['purpose'],
00433 'search_adv[purpose]',
00434 array(0 => $this->lng->txt('meta_please_select'))));
00435
00436 if($this->options['taxon_ao'] == 'and')
00437 {
00438 $this->tpl->setVariable("TAXON_AND_CHECKED",'checked=checked');
00439 }
00440 else
00441 {
00442 $this->tpl->setVariable("TAXON_OR_CHECKED",'checked=checked');
00443 }
00444 $this->tpl->setVariable("FRM_TAXON",ilUtil::prepareFormOutput($this->options['taxon'],true));
00445
00446 if($this->options['keyword_ao'] == 'and')
00447 {
00448 $this->tpl->setVariable("KEYWORD_AND_CHECKED",'checked=checked');
00449 }
00450 else
00451 {
00452 $this->tpl->setVariable("KEYWORD_OR_CHECKED",'checked=checked');
00453 }
00454 $this->tpl->setVariable("FRM_KEYWORD",ilUtil::prepareFormOutput($this->options['keyword'],true));
00455
00456 $this->tpl->setVariable("BTN_SEARCH",$this->lng->txt('search'));
00457 $this->tpl->setVariable("BTN_RESET",$this->lng->txt('reset'));
00458
00459 return true;
00460 }
00461
00462 function prepareOutput()
00463 {
00464 parent::prepareOutput();
00465
00466 $this->tpl->setCurrentBlock("header_image");
00467 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_src_b.gif"));
00468 $this->tpl->parseCurrentBlock();
00469
00470 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt('search'));
00471
00472 $this->tpl->addBlockFile("TABS","tabs","tpl.tabs.html");
00473
00474 $this->tpl->setCurrentBlock("tab");
00475 $this->tpl->setVariable("TAB_TYPE","tabinactive");
00476 $this->tpl->setVariable("TAB_LINK",$this->ctrl->getLinkTargetByClass('ilsearchgui'));
00477 $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("search"));
00478 $this->tpl->parseCurrentBlock();
00479
00480 $this->tpl->setCurrentBlock("tab");
00481 $this->tpl->setVariable("TAB_TYPE","tabactive");
00482 $this->tpl->setVariable("TAB_LINK",$this->ctrl->getLinkTarget($this));
00483 $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("search_advanced"));
00484 $this->tpl->parseCurrentBlock();
00485
00486 $this->tpl->setCurrentBlock("tab");
00487 $this->tpl->setVariable("TAB_TYPE","tabinactive");
00488 $this->tpl->setVariable("TAB_LINK",$this->ctrl->getLinkTargetByClass('ilsearchresultgui'));
00489 $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("search_search_results"));
00490 $this->tpl->parseCurrentBlock();
00491
00492 }
00493 function saveResult()
00494 {
00495 include_once 'Services/Search/classes/class.ilUserResult.php';
00496 include_once 'Services/Search/classes/class.ilSearchFolder.php';
00497
00498 global $ilUser;
00499
00500 if(!$_POST['folder'])
00501 {
00502 sendInfo($this->lng->txt('search_select_one'));
00503 $this->showSavedResults();
00504
00505 return false;
00506 }
00507 if(!count($_POST['result']))
00508 {
00509 sendInfo($this->lng->txt('search_select_one_result'));
00510 $this->showSavedResults();
00511
00512 return false;
00513 }
00514
00515 $folder_obj =& new ilSearchFolder($ilUser->getId(),(int) $_POST['folder']);
00516
00517 foreach($_POST['result'] as $ref_id)
00518 {
00519
00520 $title = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
00521 $target = addslashes(serialize(array('type' => ilObject::_lookupType(ilObject::_lookupObjId($ref_id)),
00522 'id' => $ref_id)));
00523
00524 $search_res_obj =& new ilUserResult($ilUser->getId());
00525 $search_res_obj->setTitle($title);
00526 $search_res_obj->setTarget($target);
00527
00528 $folder_obj->assignResult($search_res_obj);
00529 unset($search_res_obj);
00530 }
00531 sendInfo($this->lng->txt('search_results_saved'));
00532 $this->showSavedResults();
00533
00534 }
00535
00536
00537
00538 function showSavedResults()
00539 {
00540 global $ilUser;
00541
00542
00543 include_once 'Services/Search/classes/class.ilSearchResult.php';
00544
00545 $result_obj = new ilSearchResult($ilUser->getId());
00546 $result_obj->read(ADVANCED_SEARCH);
00547
00548 $this->showSearch();
00549
00550
00551 if(count($result_obj->getResults()))
00552 {
00553 $this->__showSearchInResults();
00554
00555 include_once 'Services/Search/classes/class.ilSearchResultPresentationGUI.php';
00556
00557 $search_result_presentation = new ilSearchResultPresentationGUI($result_obj);
00558 $this->tpl->setVariable("RESULTS",$search_result_presentation->showResults());
00559 }
00560
00561 return true;
00562 }
00563
00564 function &__performContentSearch()
00565 {
00566 if(!$this->options['content'])
00567 {
00568 return false;
00569 }
00570 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00571 include_once 'Services/Search/classes/class.ilQueryParser.php';
00572 include_once 'Services/Search/classes/class.ilSearchResult.php';
00573
00574 $res =& new ilSearchResult();
00575
00576
00577 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['content']));
00578 $query_parser->setCombination($this->options['content_ao']);
00579 $query_parser->parse();
00580
00581 if($this->options['type'] == 'all' or $this->options['type'] == 'lms')
00582 {
00583
00584 $lm_search =& ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
00585 $res_cont =& $lm_search->performSearch();
00586 $res->mergeEntries($res_cont);
00587
00588 if($this->settings->enabledLucene())
00589 {
00590
00591
00592 $htlm_search =& ilObjectSearchFactory::_getHTLMSearchInstance($query_parser);
00593 $res_htlm =& $htlm_search->performSearch();
00594 $res->mergeEntries($res_htlm);
00595 }
00596 }
00597 if($this->options['type'] == 'all' or $this->options['type'] == 'tst')
00598 {
00599 $tst_search =& ilObjectSearchFactory::_getTestSearchInstance($query_parser);
00600 $res_tes =& $tst_search->performSearch();
00601 $res->mergeEntries($res_tes);
00602 }
00603 if($this->options['type'] == 'all' or $this->options['type'] == 'mep')
00604 {
00605 $med_search =& ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
00606 $res_med =& $med_search->performSearch();
00607 $res->mergeEntries($res_med);
00608 }
00609 if($this->options['type'] == 'all' or $this->options['type'] == 'glo')
00610 {
00611 $glo_search =& ilObjectSearchFactory::_getGlossaryDefinitionSearchInstance($query_parser);
00612 $res_glo =& $glo_search->performSearch();
00613 $res->mergeEntries($res_glo);
00614 }
00615 if($this->options['type'] == 'all' or $this->options['type'] == 'webr')
00616 {
00617 $web_search =& ilObjectSearchFactory::_getWebresourceSearchInstance($query_parser);
00618 $res_web =& $web_search->performSearch();
00619 $res->mergeEntries($res_web);
00620 }
00621
00622 return $res;
00623 }
00624
00625
00626 function &__performTitleSearch()
00627 {
00628 if(!$this->options['title'])
00629 {
00630 return false;
00631 }
00632
00633 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00634 include_once 'Services/Search/classes/class.ilQueryParser.php';
00635
00636 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['title']));
00637 $query_parser->setCombination($this->options['title_ao']);
00638 $query_parser->parse();
00639
00640 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00641 $meta_search->setFilter($this->filter);
00642 $meta_search->setMode('title_description');
00643 $meta_search->setOptions($this->options);
00644 $res_tit =& $meta_search->performSearch();
00645
00646 $meta_search->setMode('keyword_all');
00647 $res_key =& $meta_search->performSearch();
00648
00649
00650 $res_tit->mergeEntries($res_key);
00651
00652 return $res_tit;
00653 }
00654
00655
00656
00657 function &__performGeneralSearch()
00658 {
00659 if(!$this->options['coverage'] and !$this->options['structure'])
00660 {
00661 return false;
00662 }
00663
00664 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00665 include_once 'Services/Search/classes/class.ilQueryParser.php';
00666
00667 if($this->options['coverage'])
00668 {
00669 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['coverage']));
00670 $query_parser->setCombination($this->options['coverage_ao']);
00671 $query_parser->parse();
00672 }
00673 else
00674 {
00675 $query_parser = new ilQueryParser('');
00676 }
00677
00678 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00679 $meta_search->setFilter($this->filter);
00680 $meta_search->setMode('general');
00681 $meta_search->setOptions($this->options);
00682 $res =& $meta_search->performSearch();
00683
00684 return $res;
00685 }
00686
00687 function &__performLifecycleSearch()
00688 {
00689
00690 if(!$this->options['status'] and !$this->options['version'])
00691 {
00692 return false;
00693 }
00694 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00695 include_once 'Services/Search/classes/class.ilQueryParser.php';
00696
00697 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['version']));
00698 $query_parser->setCombination($this->options['version_ao']);
00699 $query_parser->parse();
00700
00701 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00702 $meta_search->setFilter($this->filter);
00703 $meta_search->setMode('lifecycle');
00704 $meta_search->setOptions($this->options);
00705 $res =& $meta_search->performSearch();
00706
00707 return $res;
00708 }
00709 function &__performLanguageSearch()
00710 {
00711 if(!$this->options['language'])
00712 {
00713 return false;
00714 }
00715 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00716 include_once 'Services/Search/classes/class.ilQueryParser.php';
00717
00718
00719 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00720 $meta_search->setFilter($this->filter);
00721 $meta_search->setMode('language');
00722 $meta_search->setOptions($this->options);
00723 $res =& $meta_search->performSearch();
00724
00725 return $res;
00726 }
00727 function &__performContributeSearch()
00728 {
00729 if(!strlen($this->options['role']))
00730 {
00731 return false;
00732 }
00733 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00734 include_once 'Services/Search/classes/class.ilQueryParser.php';
00735
00736
00737 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00738 $meta_search->setFilter($this->filter);
00739 $meta_search->setMode('contribute');
00740 $meta_search->setOptions($this->options);
00741 $res =& $meta_search->performSearch();
00742
00743 return $res;
00744 }
00745 function &__performEntitySearch()
00746 {
00747
00748 if(!$this->options['entity'])
00749 {
00750 return false;
00751 }
00752 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00753 include_once 'Services/Search/classes/class.ilQueryParser.php';
00754
00755 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['entity']));
00756 $query_parser->setCombination($this->options['entity_ao']);
00757 $query_parser->parse();
00758
00759 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00760 $meta_search->setFilter($this->filter);
00761 $meta_search->setMode('entity');
00762 $meta_search->setOptions($this->options);
00763 $res =& $meta_search->performSearch();
00764
00765 return $res;
00766 }
00767
00768
00769 function &__performRequirementSearch()
00770 {
00771 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00772 include_once 'Services/Search/classes/class.ilQueryParser.php';
00773
00774
00775 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00776 $meta_search->setFilter($this->filter);
00777 $meta_search->setMode('requirement');
00778 $meta_search->setOptions($this->options);
00779 $res =& $meta_search->performSearch();
00780
00781 return $res;
00782 }
00783 function &__performFormatSearch()
00784 {
00785 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00786 include_once 'Services/Search/classes/class.ilQueryParser.php';
00787
00788
00789 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00790 $meta_search->setFilter($this->filter);
00791 $meta_search->setMode('format');
00792 $meta_search->setOptions($this->options);
00793 $res =& $meta_search->performSearch();
00794
00795 return $res;
00796 }
00797 function &__performEducationalSearch()
00798 {
00799 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00800 include_once 'Services/Search/classes/class.ilQueryParser.php';
00801
00802
00803 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00804 $meta_search->setFilter($this->filter);
00805 $meta_search->setMode('educational');
00806 $meta_search->setOptions($this->options);
00807 $res =& $meta_search->performSearch();
00808
00809 return $res;
00810 }
00811 function &__performTypicalAgeRangeSearch()
00812 {
00813 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00814 include_once 'Services/Search/classes/class.ilQueryParser.php';
00815
00816
00817 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00818 $meta_search->setFilter($this->filter);
00819 $meta_search->setMode('typical_age_range');
00820 $meta_search->setOptions($this->options);
00821 $res =& $meta_search->performSearch();
00822
00823 return $res;
00824 }
00825 function &__performRightsSearch()
00826 {
00827 if(!$this->options['copyright'] and !$this->options['costs'])
00828 {
00829 return false;
00830 }
00831 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00832 include_once 'Services/Search/classes/class.ilQueryParser.php';
00833
00834
00835 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00836 $meta_search->setFilter($this->filter);
00837 $meta_search->setMode('rights');
00838 $meta_search->setOptions($this->options);
00839 $res =& $meta_search->performSearch();
00840
00841 return $res;
00842 }
00843
00844 function &__performClassificationSearch()
00845 {
00846
00847 if(!$this->options['purpose'])
00848 {
00849 return false;
00850 }
00851 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00852 include_once 'Services/Search/classes/class.ilQueryParser.php';
00853
00854
00855 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00856 $meta_search->setFilter($this->filter);
00857 $meta_search->setMode('classification');
00858 $meta_search->setOptions($this->options);
00859 $res =& $meta_search->performSearch();
00860
00861 return $res;
00862 }
00863
00864 function &__performTaxonSearch()
00865 {
00866
00867 if(!$this->options['taxon'])
00868 {
00869 return false;
00870 }
00871 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00872 include_once 'Services/Search/classes/class.ilQueryParser.php';
00873
00874 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['taxon']));
00875 $query_parser->setCombination($this->options['taxon_ao']);
00876 $query_parser->parse();
00877
00878 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00879 $meta_search->setFilter($this->filter);
00880 $meta_search->setMode('taxon');
00881 $meta_search->setOptions($this->options);
00882 $res =& $meta_search->performSearch();
00883
00884 return $res;
00885 }
00886
00887 function &__performKeywordSearch()
00888 {
00889
00890 if(!$this->options['keyword'])
00891 {
00892 return false;
00893 }
00894 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00895 include_once 'Services/Search/classes/class.ilQueryParser.php';
00896
00897 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['keyword']));
00898 $query_parser->setCombination($this->options['keyword_ao']);
00899 $query_parser->parse();
00900
00901 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00902 $meta_search->setFilter($this->filter);
00903 $meta_search->setMode('keyword');
00904 $meta_search->setOptions($this->options);
00905 $res =& $meta_search->performSearch();
00906
00907 return $res;
00908 }
00909
00910 function __setSearchOptions(&$post_vars)
00911 {
00912 if(isset($_POST['cmd']['performSearch']))
00913 {
00914 $this->options = $_SESSION['search_adv'] = $_POST['search_adv'];
00915 }
00916 else
00917 {
00918 $this->options = $_SESSION['search_adv'];
00919 }
00920
00921 $_POST['result'] = $_POST['id'];
00922
00923 $this->filter = array();
00924
00925 switch($this->options['type'])
00926 {
00927 case 'webr':
00928 $this->filter[] = 'webr';
00929 break;
00930
00931 case 'lms':
00932 $this->filter[] = 'lm';
00933 $this->filter[] = 'dbk';
00934 $this->filter[] = 'pg';
00935 $this->filter[] = 'st';
00936 $this->filter[] = 'sahs';
00937 $this->filter[] = 'htlm';
00938 break;
00939
00940 case 'glo':
00941 $this->filter[] = 'glo';
00942 break;
00943
00944 case 'tst':
00945 $this->filter[] = 'tst';
00946 $this->filter[] = 'svy';
00947 $this->filter[] = 'qpl';
00948 $this->filter[] = 'spl';
00949 break;
00950
00951 case 'mep':
00952 $this->filter[] = 'mep';
00953 break;
00954
00955 case 'crs':
00956 $this->filter[] = 'crs';
00957 break;
00958
00959 case 'all':
00960 default:
00961 $this->filter[] = 'webr';
00962 $this->filter[] = 'crs';
00963 $this->filter[] = 'mep';
00964 $this->filter[] = 'tst';
00965 $this->filter[] = 'svy';
00966 $this->filter[] = 'qpl';
00967 $this->filter[] = 'spl';
00968 $this->filter[] = 'glo';
00969 $this->filter[] = 'lm';
00970 $this->filter[] = 'dbk';
00971 $this->filter[] = 'pg';
00972 $this->filter[] = 'st';
00973 $this->filter[] = 'sahs';
00974 $this->filter[] = 'htlm';
00975 }
00976 return true;
00977 }
00978
00979 function __getFilterSelect()
00980 {
00981 $options = array('all' => $this->lng->txt('search_any'),
00982 'lms' => $this->lng->txt('learning_resources'),
00983 'crs' => $this->lng->txt('objs_crs'),
00984 'tst' => $this->lng->txt('search_tst_svy'),
00985 'mep' => $this->lng->txt('objs_mep'),
00986 'glo' => $this->lng->txt('objs_glo'),
00987 'webr' => $this->lng->txt('objs_webr'));
00988
00989
00990 return ilUtil::formSelect($this->options['type'],'search_adv[type]',$options,false,true);
00991 }
00992
00993
00994 function __storeEntries(&$res,&$new_res)
00995 {
00996
00997 if($this->stored == false)
00998 {
00999
01000
01001 $res->mergeEntries($new_res);
01002 $this->stored = true;
01003
01004 return true;
01005 }
01006 else
01007 {
01008 $res->intersectEntries($new_res);
01009
01010 return true;
01011 }
01012 }
01018 function __showSearchInResults()
01019 {
01020 $this->tpl->setCurrentBlock("search_results");
01021 $this->tpl->setVariable("BTN_SEARCHRESULTS",$this->lng->txt('search_in_result'));
01022 $this->tpl->parseCurrentBlock();
01023
01024 $this->tpl->setCurrentBlock("save_result");
01025 $this->tpl->setVariable("DOWNRIGHT",ilUtil::getImagePath('arrow_downright.gif'));
01026 $this->tpl->setVariable("BTN_SAVE_RESULT",$this->lng->txt('save'));
01027 $this->tpl->setVariable("SELECT_FOLDER",$this->__getFolderSelect());
01028 $this->tpl->parseCurrentBlock();
01029
01030 return true;
01031 }
01032 function __getFolderSelect()
01033 {
01034 global $ilUser;
01035
01036 include_once 'Services/Search/classes/class.ilSearchFolder.php';
01037
01038
01039 $folder_obj =& new ilSearchFolder($ilUser->getId());
01040
01041
01042 $subtree = $folder_obj->getSubtree();
01043
01044 $options[0] = $this->lng->txt("search_select_one_folder_select");
01045 $options[$folder_obj->getRootId()] = $this->lng->txt("search_save_as_select")." ".$this->lng->txt("search_search_results");
01046
01047 foreach($subtree as $node)
01048 {
01049 if($node["obj_id"] == $folder_obj->getRootId())
01050 {
01051 continue;
01052 }
01053
01054 $prefix = $this->lng->txt("search_save_as_select");
01055 for($i = 1; $i < $node["depth"];++$i)
01056 {
01057 $prefix .= " ";
01058 }
01059 $options[$node["obj_id"]] = $prefix.$node["title"];
01060 }
01061 return ilUtil::formSelect(0,'folder',$options,false,true);
01062 }
01063
01064
01065 }
01066 ?>