4 include_once
'Services/Search/classes/class.ilSearchBaseGUI.php';
6 define(
'SEARCH_FAST',1);
7 define(
'SEARCH_DETAILS',2);
8 define(
'SEARCH_AND',
'and');
9 define(
'SEARCH_OR',
'or');
44 $lng->loadLanguageModule(
"search");
46 $this->obj_types = array (
47 "lms" => $lng->txt(
"learning_resources"),
48 "glo" => $lng->txt(
"objs_glo"),
49 "mcst" => $lng->txt(
"objs_mcst"),
50 "fil" => $lng->txt(
"objs_file"),
51 "exc" => $lng->txt(
"objs_exc"),
52 "tst" => $lng->txt(
"search_tst_svy"),
53 "mep" => $lng->txt(
"objs_mep")
58 $this->form->checkInput();
59 reset($this->obj_types);
61 $new_search = isset(
$_POST[
'cmd'][
'performSearch']) ?
true :
false;
63 foreach($this->obj_types as $k =>
$t)
72 $this->root_node =
$_SESSION[
'search_root'] ?
$_SESSION[
'search_root'] : ROOT_FOLDER_ID;
75 $this->
setString(
$_POST[
'search'][
'string'] ?
$_POST[
'search'][
'string'] : $_SESSION[
'search'][
'string']);
76 #$this->setDetails($_POST['search']['details'] ? $_POST['search']['details'] : $_SESSION['search']['details']);
77 $this->
setDetails($new_search ?
$_POST[
'search'][
'details'] : $_SESSION[
'search'][
'details']);
89 $_SESSION[
'search'][
'type'] = $this->type = $a_type;
101 $_SESSION[
'search'][
'combination'] = $this->combination = $a_combination;
105 return $this->combination ? $this->combination :
SEARCH_OR;
113 $_SESSION[
'search'][
'string'] = $this->
string = $a_str;
125 $_SESSION[
'search'][
'details'] = $this->details = $a_details;
129 return $this->details ? $this->details : array();
135 return $this->root_node ? $this->root_node : ROOT_FOLDER_ID;
139 $_SESSION[
'search_root'] = $this->root_node = $a_node_id;
151 $next_class = $this->ctrl->getNextClass($this);
152 $cmd = $this->ctrl->getCmd();
156 case "ilpropertyformgui":
159 $ilCtrl->setReturn($this,
"");
160 return $ilCtrl->forwardCommand($this->form);
163 case 'ilobjectcopygui':
165 include_once
'./Services/Object/classes/class.ilObjectCopyGUI.php';
167 $this->ctrl->forwardCommand($cp);
174 $cmd =
"showSavedResults";
197 include_once(
"./Services/Search/classes/class.ilSearchAutoComplete.php");
209 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.search.html',
'Services/Search');
212 $this->tpl->setVariable(
"FORM", $this->form->getHTML());
221 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.search_root_selector.html',
'Services/Search');
223 include_once
'Services/Search/classes/class.ilSearchRootSelector.php';
228 $exp->
setExpand(
$_GET[
"search_root_expand"] ?
$_GET[
"search_root_expand"] : $tree->readRootId());
229 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'showSelectRoot'));
234 $this->tpl->setVariable(
"EXPLORER",$exp->getOutput());
252 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
256 $ti =
new ilTextInputGUI($lng->txt(
"search_search_term"),
"term");
260 $dsSchema = array(
"resultsList" =>
'response.results',
261 "fields" => array(
'term'));
262 $ti->setDataSource($ilCtrl->getLinkTarget($this,
"autoComplete",
"",
false,
false));
263 $ti->setDataSourceSchema($dsSchema);
264 $ti->setDataSourceResultFormat($dsFormatCallback);
265 $ti->setDataSourceDelimiter($dsDelimiter);
266 $this->form->addItem($ti);
272 $op1 =
new ilRadioOption($lng->txt(
"search_any_word"),
"or");
273 $radg->addOption($op1);
274 $op2 =
new ilRadioOption($lng->txt(
"search_all_words"),
"and");
275 $radg->addOption($op2);
276 $this->form->addItem($radg);
279 include_once(
"./Services/Form/classes/class.ilRepositorySelectorInputGUI.php");
282 $this->form->addItem($ti);
283 $ti->readFromSession();
289 $radg->addOption($op1);
294 reset($this->obj_types);
295 foreach ($this->obj_types as $k =>
$t)
298 $cb->setChecked($details[$k]);
299 $op2->addSubItem($cb);
302 $radg->addOption($op2);
303 $this->form->addItem($radg);
307 $this->form->addCommandButton(
"performSearch", $lng->txt(
"search"));
309 $this->form->setTitle($lng->txt(
"search"));
310 $this->form->setFormAction($ilCtrl->getFormAction($this,
'performSearch'));
319 include_once
'Services/Search/classes/class.ilSearchResult.php';
328 if(count($result_obj->getResults()))
330 $this->
addPager($result_obj,
'max_page');
332 include_once
'./Services/Search/classes/class.ilSearchResultPresentation.php';
334 $presentation->setResults($result_obj->getResultsForPresentation());
335 $presentation->setSubitemIds($result_obj->getSubitemIds());
336 $presentation->setPreviousNext($this->prev_link, $this->next_link);
337 #$presentation->setSearcher($searcher);
339 if($presentation->render())
342 $this->tpl->setVariable(
'RESULTS_TABLE',$presentation->getHTML(
true));
351 $this->search_mode =
'in_results';
352 $this->search_cache->setResultPageNumber(1);
367 if(!isset(
$_GET[
'page_number']) and $this->search_mode !=
'in_results' )
370 $this->search_cache->deleteCachedEntries();
393 $result_meta =& $this->
__searchMeta($query_parser,
'keyword');
394 $result->mergeEntries($result_meta);
396 $result_meta =& $this->
__searchMeta($query_parser,
'contribute');
397 $result->mergeEntries($result_meta);
399 $result_meta =& $this->
__searchMeta($query_parser,
'title');
400 $result->mergeEntries($result_meta);
402 $result_meta =& $this->
__searchMeta($query_parser,
'description');
403 $result->mergeEntries($result_meta);
411 if($this->search_mode ==
'in_results')
413 include_once
'Services/Search/classes/class.ilSearchResult.php';
416 $old_result_obj->
read();
418 $result->diffEntriesFromResult($old_result_obj);
423 $result->filter($this->
getRootNode(),$query_parser->getCombination() ==
'and');
427 if(!count($result->getResults()))
432 if($result->isLimitReached())
434 #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
435 #ilUtil::sendInfo($message);
439 $this->
addPager($result,
'max_page');
441 include_once
'./Services/Search/classes/class.ilSearchResultPresentation.php';
443 $presentation->setResults($result->getResultsForPresentation());
444 $presentation->setSubitemIds($result->getSubitemIds());
445 $presentation->setPreviousNext($this->prev_link, $this->next_link);
447 if($presentation->render())
450 $this->tpl->setVariable(
'RESULTS_TABLE',$presentation->getHTML(
true));
466 $ilTabs->addTab(
"search", $this->lng->txt(
"search"),
467 $this->ctrl->getLinkTarget($this));
475 if (!$this->settings->getHideAdvancedSearch())
482 $ilTabs->addTab(
"adv_search", $this->lng->txt(
"search_advanced"),
483 $this->ctrl->getLinkTargetByClass(
'iladvancedsearchgui'));
486 $ilTabs->activateTab(
"search");
504 $result->mergeEntries($content_search->performSearch());
510 $gdf_search->setFilter(array(
'gdf'));
511 $result->mergeEntries($gdf_search->performSearch());
514 $result->mergeEntries($gdf_term_search->performSearch());
520 $result->mergeEntries($exc_search->performSearch());
524 $mcst_search =& ilObjectSearchFactory::_getMediaCastSearchInstance($query_parser);
525 $result->mergeEntries($mcst_search->performSearch());
531 $result->mergeEntries($tst_search->performSearch());
537 $result->mergeEntries($mep_search->performSearch());
542 $result->mergeEntries($mob_search->performKeywordSearch());
558 include_once
'Services/Search/classes/class.ilQueryParser.php';
562 $query_parser->parse();
564 if(!$query_parser->validate())
566 return $query_parser->getMessage();
568 return $query_parser;
577 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
584 return $obj_search->performSearch();
595 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
605 $meta_search->setMode(
'keyword');
609 $meta_search->setMode(
'contribute');
613 $meta_search->setMode(
'title');
617 $meta_search->setMode(
'description');
620 return $meta_search->performSearch();
634 foreach($this->
getDetails() as $key => $detail_type)
682 return $filter ? $filter : array();
695 include_once(
'Services/Search/classes/class.ilUserSearchCache.php');
698 if(
$_GET[
'page_number'])
700 $this->search_cache->setResultPageNumber((
int)
$_GET[
'page_number']);
702 if(isset(
$_POST[
'cmd'][
'performSearch']))
705 $this->search_cache->save();