19 declare(strict_types=1);
50 $this->tabs_gui = $DIC->tabs();
51 $this->help_gui = $DIC->help();
52 $this->
lng->loadLanguageModule(
"search");
54 $this->ui_factory = $DIC->ui()->factory();
55 $this->ui_renderer = $DIC->ui()->renderer();
60 $requested_search = (array) ($this->
http->request()->getParsedBody()[
'search'] ?? []);
62 if ($this->
http->wrapper()->post()->has(
'cmd')) {
64 } elseif ($this->
http->wrapper()->query()->has(
'cmd')) {
65 $requested_cmd = (array) $this->
http->wrapper()->query()->retrieve(
67 $this->
refinery->kindlyTo()->string()
69 $requested_cmd = [$requested_cmd[0] =>
"Search"];
73 $new_search = (bool) ($requested_cmd[
"performSearch"] ??
false);
74 $new_filter = (bool) ($requested_cmd[
"performSearchFilter"] ??
false);
75 $new_search_or_filter = $new_search || $new_filter;
77 $requested_filter_type = (array) ($this->search_filter_data[
"search_type"] ?? []);
78 $requested_filter_type = array_flip($requested_filter_type);
79 $requested_filter_type = array_fill_keys(array_keys($requested_filter_type),
"1");
81 foreach ($enabled_types as $type => $pval) {
82 if (isset($requested_filter_type[$type])) {
83 $requested_search[
"details"][
$type] = $requested_filter_type[
$type];
88 $post_term = $this->
http->wrapper()->post()->retrieve(
91 $this->refinery->kindlyTo()->string(),
95 $filter_type_active = (is_null($this->search_filter_data[
"search_type"] ??
null))
97 : self::SEARCH_DETAILS;
98 $filter_scope = $this->search_filter_data[
"search_scope"] ??
ROOT_FOLDER_ID;
104 $requested_search[
"string"] = $post_term;
105 $requested_search[
"type"] = $filter_type_active;
110 $this->
setType((
int) ($requested_search[
'type'] ?? ($session_search[
'type'] ?? self::SEARCH_FAST)));
117 $this->
setString((
string) ($requested_search[
'string'] ?? ($session_search[
'string'] ??
'')));
119 $new_search_or_filter ?
120 ($requested_search[
'details'] ?? []) :
121 ($session_search[
'details'] ?? [])
124 if ($new_search_or_filter) {
126 $requested_search[
'string'] ?? ($session_search[
'string'] ??
'')
135 $next_class = $this->
ctrl->getNextClass($this);
136 $cmd = $this->
ctrl->getCmd();
138 switch ($next_class) {
139 case 'ilobjectcopygui':
141 $this->
ctrl->setReturn($this,
'');
143 $this->
ctrl->forwardCommand($cp);
148 $cmd =
"showSavedResults";
162 $session_search[
'type'] = $this->type = $a_type;
168 return $this->type ?? self::SEARCH_FAST;
177 $session_search[
'combination'] = $this->combination = $a_combination;
182 return $this->combination ?: self::SEARCH_OR;
188 $session_search[
'string'] = $this->
string = $a_str;
203 $session_search[
'details'] = $this->details = $a_details;
209 return $this->details ?? [];
225 if ($this->
http->wrapper()->post()->has(
'root_id')) {
226 $root_id = $this->
http->wrapper()->post()->retrieve(
232 if ($this->
http->wrapper()->post()->has(
'queryString')) {
233 $queryString = $this->
http->wrapper()->post()->retrieve(
235 $this->
refinery->kindlyTo()->string()
249 if ($this->
http->wrapper()->post()->has(
'term')) {
250 $query = $this->
http->wrapper()->post()->retrieve(
252 $this->
refinery->kindlyTo()->string()
254 } elseif ($this->
http->wrapper()->query()->has(
'term')) {
255 $query = $this->
http->wrapper()->query()->retrieve(
257 $this->
refinery->kindlyTo()->string()
261 if ($this->
http->wrapper()->post()->has(
'search_type')) {
262 $search_type = $this->
http->wrapper()->post()->retrieve(
266 } elseif ($this->
http->wrapper()->query()->has(
'search_type')) {
267 $search_type = $this->
http->wrapper()->query()->retrieve(
272 if ((
int) $search_type === -1) {
273 $a_fields = array(
'login',
'firstname',
'lastname',
'email');
274 $result_field =
'login';
280 $auto->setMoreLinkAvailable(
true);
281 $auto->setSearchFields($a_fields);
282 $auto->setResultField($result_field);
283 $auto->enableFieldSearchableCheck(
true);
284 $auto->setUserLimitations(
true);
286 $res = $auto->getList($query);
287 $res_obj = json_decode(
$res);
288 if (is_array($res_obj->items)) {
289 echo json_encode($res_obj->items);
301 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.search.html',
'components/ILIAS/Search');
316 if (count($result_obj->getResults())) {
317 $this->
addPager($result_obj,
'max_page');
320 $presentation->setResults($result_obj->getResultsForPresentation());
321 $presentation->setSubitemIds($result_obj->getSubitemIds());
322 $presentation->setPreviousNext($this->prev_link, $this->next_link);
323 #$presentation->setSearcher($searcher); 325 if ($presentation->render()) {
326 $this->tpl->setVariable(
'SEARCH_RESULTS', $presentation->getHTML());
339 if (!$page_number and $this->search_mode !=
'in_results') {
341 $this->search_cache->deleteCachedEntries();
343 $this->search_cache->setResultPageNumber($page_number);
345 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'search_choose_object_type'));
352 $this->tpl->setOnScreenMessage(
'info', $query_parser);
361 $result_meta = $this->
__searchMeta($query_parser,
'keyword');
362 $result->mergeEntries($result_meta);
364 $result_meta = $this->
__searchMeta($query_parser,
'contribute');
365 $result->mergeEntries($result_meta);
367 $result_meta = $this->
__searchMeta($query_parser,
'title');
368 $result->mergeEntries($result_meta);
370 $result_meta = $this->
__searchMeta($query_parser,
'description');
371 $result->mergeEntries($result_meta);
374 if ($this->
getType() == self::SEARCH_DETAILS) {
378 if ($this->search_mode ==
'in_results') {
380 $old_result_obj->
read();
382 $result->diffEntriesFromResult();
396 if (!count($result->getResults())) {
397 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'search_no_match'));
400 if ($result->isLimitReached()) {
401 #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits()); 402 #ilUtil::sendInfo($message); 406 $this->
addPager($result,
'max_page');
409 $presentation->setResults($result->getResultsForPresentation());
410 $presentation->setSubitemIds($result->getSubitemIds());
411 $presentation->setPreviousNext($this->prev_link, $this->next_link);
413 if ($presentation->render()) {
414 $this->tpl->setVariable(
'SEARCH_RESULTS', $presentation->getHTML());
420 parent::prepareOutput();
422 $this->help_gui->setScreenIdComponent(
"src");
424 $this->tabs_gui->addTab(
426 $this->
lng->txt(
"search"),
427 $this->
ctrl->getLinkTarget($this)
430 $this->tabs_gui->activateTab(
"search");
435 foreach ($this->
getDetails() as $type => $enabled) {
443 $crs_search->setFilter(array(
'crs'));
449 $grp_search->setFilter(array(
'grp'));
456 $result->
mergeEntries($content_search->performSearch());
468 $gdf_search->setFilter(array(
'term'));
472 $result->
mergeEntries($gdf_term_search->performSearch());
500 $result->
mergeEntries($mob_search->performKeywordSearch());
526 $query_parser->parse();
528 if (!$query_parser->validate()) {
529 return $query_parser->getMessage();
531 return $query_parser;
540 if ($this->
getType() == self::SEARCH_DETAILS) {
544 return $obj_search->performSearch();
552 if (is_null($date_start) && is_null($date_end)) {
564 if (!($options[
'date_start'] ??
false)) {
573 if (!($options[
'date_end'] ??
false)) {
585 if ($this->
getType() == self::SEARCH_DETAILS) {
590 $meta_search->setMode(
'keyword');
594 $meta_search->setMode(
'contribute');
598 $meta_search->setMode(
'title');
602 $meta_search->setMode(
'description');
605 return $meta_search->performSearch();
614 if ($this->
getType() != self::SEARCH_DETAILS) {
619 foreach ($this->
getDetails() as $key => $detail_type) {
static get(string $a_var)
parseEndDateFromCreationFilter()
setCreationDateFilterStartDate(?ilDate $day)
read(int $a_type=ilUserSearchCache::DEFAULT_SEARCH)
__searchMeta(ilQueryParser $query_parser, string $a_type)
Search in object meta data (keyword)
static _getLMContentSearchInstance(ilQueryParser $query_parser)
static _getMediaPoolSearchInstance(ilQueryParser $query_parser)
setCombination(string $a_combination)
Set/get combination of search ('and' or 'or')
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__searchObjects(ilQueryParser $query_parser)
Search in obect title,desctiption.
static getList(string $a_str)
GUI class for the workflow of copying objects.
GUI class for 'simple' search.
static _getMediacastSearchInstance(ilQueryParser $query_parser)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static _getWikiContentSearchInstance(ilQueryParser $query_parser)
__performDetailsSearch(ilQueryParser $query_parser, ilSearchResult $result)
handleCommand(string $a_cmd)
setRootNode(int $a_node_id)
parseStartDateFromCreationFilter()
setType(int $a_type)
Set/get type of search (detail or 'fast' search)
static _getExerciseSearchInstance(ilQueryParser $query_parser)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getGlossaryDefinitionSearchInstance(ilQueryParser $query_parser)
static http()
Fetches the global http state from ILIAS.
__parseQueryString()
parse query string, using query parser instance
setCreationDateFilterEndDate(?ilDate $day)
Presentation of search results using object list gui.
static _getForumSearchInstance(ilQueryParser $query_parser)
static _getObjectSearchInstance(ilQueryParser $query_parser)
parseCreationFilter(ilObjectSearch $search)
renderSearch(string $term, int $root_node=0)
static _getTestSearchInstance(ilQueryParser $query_parser)
getStringArrayTransformation()
mergeEntries(ilSearchResult $result_obj)
merge entries of this instance and another result object
addPager($result, string $a_session_key)
__construct(Container $dic, ilPlugin $plugin)
__getFilter()
Get object type for filter (If detail search is enabled)
static _getMetaDataSearchInstance(ilQueryParser $query_parser)
initPageNumberFromQuery()
static clear(string $a_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static set(string $a_var, $a_val)
Set a value.
setDetails(array $a_details)
Set/get details (object types for details search)
autoComplete()
Data resource for autoComplete.