19declare(strict_types=1);
51 $this->tabs_gui =
$DIC->tabs();
52 $this->help_gui =
$DIC->help();
53 $this->
lng->loadLanguageModule(
"search");
55 $this->ui_factory =
$DIC->ui()->factory();
56 $this->ui_renderer =
$DIC->ui()->renderer();
61 $requested_search = (array) ($this->
http->request()->getParsedBody()[
'search'] ?? []);
63 if ($this->
http->wrapper()->post()->has(
'cmd')) {
65 } elseif ($this->
http->wrapper()->query()->has(
'cmd')) {
66 $requested_cmd = (array) $this->
http->wrapper()->query()->retrieve(
68 $this->
refinery->kindlyTo()->string()
70 $requested_cmd = [$requested_cmd[0] =>
"Search"];
74 $new_search = (bool) ($requested_cmd[
"performSearch"] ??
false);
75 $new_filter = (bool) ($requested_cmd[
"performSearchFilter"] ??
false);
76 $new_search_or_filter = $new_search || $new_filter;
78 $requested_filter_type = (array) ($this->search_filter_data[
"search_type"] ?? []);
79 $requested_filter_type = array_flip($requested_filter_type);
80 $requested_filter_type = array_fill_keys(array_keys($requested_filter_type),
"1");
82 foreach ($enabled_types as
$type => $pval) {
83 if (isset($requested_filter_type[
$type])) {
84 $requested_search[
"details"][
$type] = $requested_filter_type[
$type];
89 $post_term = $this->
http->wrapper()->post()->retrieve(
92 $this->refinery->kindlyTo()->string(),
93 $this->refinery->always(
null)
96 $filter_type_active = (is_null($this->search_filter_data[
"search_type"] ??
null))
98 : self::SEARCH_DETAILS;
99 $filter_scope = $this->search_filter_data[
"search_scope"] ??
ROOT_FOLDER_ID;
105 $requested_search[
"string"] = $post_term;
106 $requested_search[
"type"] = $filter_type_active;
111 $this->
setType((
int) ($requested_search[
'type'] ?? ($session_search[
'type'] ?? self::SEARCH_FAST)));
118 $this->
setString((
string) ($requested_search[
'string'] ?? ($session_search[
'string'] ??
'')));
120 $new_search_or_filter ?
121 ($requested_search[
'details'] ?? []) :
122 ($session_search[
'details'] ?? [])
125 if ($new_search_or_filter) {
127 $requested_search[
'string'] ?? ($session_search[
'string'] ??
'')
136 $next_class = $this->
ctrl->getNextClass($this);
137 $cmd = $this->
ctrl->getCmd();
139 switch ($next_class) {
140 case 'ilobjectcopygui':
142 $this->
ctrl->setReturn($this,
'');
144 $this->
ctrl->forwardCommand($cp);
149 $cmd =
"showSavedResults";
163 $session_search[
'type'] = $this->type = $a_type;
178 $session_search[
'combination'] = $this->combination = $a_combination;
189 $session_search[
'string'] = $this->
string = $a_str;
204 $session_search[
'details'] = $this->details = $a_details;
210 return $this->details ?? [];
226 if ($this->
http->wrapper()->post()->has(
'root_id')) {
227 $root_id = $this->
http->wrapper()->post()->retrieve(
233 if ($this->
http->wrapper()->post()->has(
'queryString')) {
234 $queryString = $this->
http->wrapper()->post()->retrieve(
236 $this->
refinery->kindlyTo()->string()
250 if ($this->
http->wrapper()->post()->has(
'term')) {
251 $query = $this->
http->wrapper()->post()->retrieve(
253 $this->
refinery->kindlyTo()->string()
255 } elseif ($this->
http->wrapper()->query()->has(
'term')) {
256 $query = $this->
http->wrapper()->query()->retrieve(
258 $this->
refinery->kindlyTo()->string()
262 if ($this->
http->wrapper()->post()->has(
'search_type')) {
263 $search_type = $this->
http->wrapper()->post()->retrieve(
267 } elseif ($this->
http->wrapper()->query()->has(
'search_type')) {
268 $search_type = $this->
http->wrapper()->query()->retrieve(
273 if ((
int) $search_type === -1) {
274 $a_fields = array(
'login',
'firstname',
'lastname',
'email');
275 $result_field =
'login';
281 $auto->setMoreLinkAvailable(
true);
282 $auto->setSearchFields($a_fields);
283 $auto->setResultField($result_field);
284 $auto->enableFieldSearchableCheck(
true);
285 $auto->setUserLimitations(
true);
287 $res = $auto->getList($query);
288 $res_obj = json_decode(
$res);
289 if (is_array($res_obj->items)) {
290 echo json_encode($res_obj->items);
302 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.search.html',
'components/ILIAS/Search');
317 if (count($result_obj->getResults())) {
318 $this->
addPager($result_obj,
'max_page');
321 $presentation->setResults($result_obj->getResultsForPresentation());
322 $presentation->setSubitemIds($result_obj->getSubitemIds());
323 $presentation->setPreviousNext($this->prev_link, $this->next_link);
324 #$presentation->setSearcher($searcher);
326 if ($presentation->render()) {
327 $this->tpl->setVariable(
'SEARCH_RESULTS', $presentation->getHTML());
340 if (!$page_number and $this->search_mode !=
'in_results') {
342 $this->search_cache->deleteCachedEntries();
344 $this->search_cache->setResultPageNumber($page_number);
346 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'search_choose_object_type'));
353 $this->tpl->setOnScreenMessage(
'info', $query_parser);
362 $result_meta = $this->
__searchMeta($query_parser,
'keyword');
363 $result->mergeEntries($result_meta);
365 $result_meta = $this->
__searchMeta($query_parser,
'contribute');
366 $result->mergeEntries($result_meta);
368 $result_meta = $this->
__searchMeta($query_parser,
'title');
369 $result->mergeEntries($result_meta);
371 $result_meta = $this->
__searchMeta($query_parser,
'description');
372 $result->mergeEntries($result_meta);
375 if ($this->
getType() == self::SEARCH_DETAILS) {
379 if ($this->search_mode ==
'in_results') {
381 $old_result_obj->read();
383 $result->diffEntriesFromResult();
397 if (!count($result->getResults())) {
398 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'search_no_match'));
401 if ($result->isLimitReached()) {
402 #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
403 #ilUtil::sendInfo($message);
407 $this->
addPager($result,
'max_page');
410 $presentation->setResults($result->getResultsForPresentation());
411 $presentation->setSubitemIds($result->getSubitemIds());
412 $presentation->setPreviousNext($this->prev_link, $this->next_link);
414 if ($presentation->render()) {
415 $this->tpl->setVariable(
'SEARCH_RESULTS', $presentation->getHTML());
421 parent::prepareOutput();
423 $this->help_gui->setScreenIdComponent(
"src");
425 $this->tabs_gui->addTab(
427 $this->
lng->txt(
"search"),
428 $this->ctrl->getLinkTarget($this)
431 $this->tabs_gui->activateTab(
"search");
444 $crs_search->setFilter(array(
'crs'));
450 $grp_search->setFilter(array(
'grp'));
457 $result->
mergeEntries($content_search->performSearch());
469 $gdf_search->setFilter(array(
'term'));
473 $result->
mergeEntries($gdf_term_search->performSearch());
501 $result->
mergeEntries($mob_search->performKeywordSearch());
527 $query_parser->parse();
529 if (!$query_parser->validate()) {
530 return $query_parser->getMessage();
532 return $query_parser;
541 if ($this->
getType() == self::SEARCH_DETAILS) {
545 return $obj_search->performSearch();
553 if (is_null($date_start) && is_null($date_end)) {
565 if (!($options[
'date_start'] ??
false)) {
574 if (!($options[
'date_end'] ??
false)) {
586 if ($this->
getType() == self::SEARCH_DETAILS) {
591 $meta_search->setMode(
'keyword');
595 $meta_search->setMode(
'contribute');
599 $meta_search->setMode(
'title');
603 $meta_search->setMode(
'description');
606 return $meta_search->performSearch();
615 if ($this->
getType() != self::SEARCH_DETAILS) {
620 foreach ($this->
getDetails() as $key => $detail_type) {
Builds a Color from either hex- or rgb values.
GUI class for the workflow of copying objects.
static _getObjectSearchInstance(ilQueryParser $query_parser)
static _getForumSearchInstance(ilQueryParser $query_parser)
static _getMediacastSearchInstance(ilQueryParser $query_parser)
static _getGlossaryDefinitionSearchInstance(ilQueryParser $query_parser)
static _getMetaDataSearchInstance(ilQueryParser $query_parser)
static _getMediaPoolSearchInstance(ilQueryParser $query_parser)
static _getExerciseSearchInstance(ilQueryParser $query_parser)
static _getWikiContentSearchInstance(ilQueryParser $query_parser)
static _getLMContentSearchInstance(ilQueryParser $query_parser)
static _getTestSearchInstance(ilQueryParser $query_parser)
setCreationDateFilterStartDate(?ilDate $day)
setCreationDateFilterEndDate(?ilDate $day)
static getList(string $a_str)
renderSearch(string $term, int $root_node=0)
addPager($result, string $a_session_key)
handleCommand(string $a_cmd)
getStringArrayTransformation()
initPageNumberFromQuery()
GUI class for 'simple' search.
parseEndDateFromCreationFilter()
setRootNode(int $a_node_id)
parseCreationFilter(ilObjectSearch $search)
parseStartDateFromCreationFilter()
autoComplete()
Data resource for autoComplete.
__getFilter()
Get object type for filter (If detail search is enabled)
__searchObjects(ilQueryParser $query_parser)
Search in obect title,desctiption.
__searchMeta(ilQueryParser $query_parser, string $a_type)
Search in object meta data (keyword)
__parseQueryString()
parse query string, using query parser instance
setCombination(string $a_combination)
Set/get combination of search ('and' or 'or')
setType(int $a_type)
Set/get type of search (detail or 'fast' search)
__performDetailsSearch(ilQueryParser $query_parser, ilSearchResult $result)
setDetails(array $a_details)
Set/get details (object types for details search)
Presentation of search results using object list gui.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
mergeEntries(ilSearchResult $result_obj)
merge entries of this instance and another result object
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
An entity that renders components to a string output.
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc