19declare(strict_types=1);
55 $this->
tabs = $DIC->tabs();
56 $this->
help = $DIC->help();
58 $this->ui_factory =
$DIC->ui()->factory();
59 $this->ui_renderer =
$DIC->ui()->renderer();
70 $next_class = $this->
ctrl->getNextClass($this);
71 $cmd = $this->
ctrl->getCmd();
73 switch ($next_class) {
74 case 'ilobjectcopygui':
76 $this->
ctrl->setReturn($this,
'');
78 $this->
ctrl->forwardCommand($cp);
84 $cmd =
"showSavedResults";
96 parent::prepareOutput();
114 return $this->search_cache->getItemFilter();
123 return $this->search_cache->getMimeFilter();
132 if ($this->
http->wrapper()->post()->has(
'queryString')) {
133 $queryString = $this->
http->wrapper()->post()->retrieve(
135 $this->
refinery->kindlyTo()->string()
139 if ($this->
http->wrapper()->post()->has(
'root_id')) {
140 $root_id = $this->
http->wrapper()->post()->retrieve(
146 $qp->parseAutoWildcard();
148 $query = $qp->getQuery();
150 $this->search_cache->setRoot($root_id);
152 $this->search_cache->save();
162 if (!strlen($this->search_cache->getQuery())) {
174 $filter->loadFromDb();
177 $searcher->highlight($filter->getResultObjIds());
180 $presentation->setResults($filter->getResultIds());
181 $presentation->setSearcher($searcher);
182 $this->
addPager($filter,
'max_page');
183 $presentation->setPreviousNext($this->prev_link, $this->next_link);
187 if ($presentation->render()) {
188 $this->tpl->setVariable(
'SEARCH_RESULTS', $presentation->getHTML());
189 } elseif (strlen($this->search_cache->getQuery())) {
190 $this->tpl->setOnScreenMessage(
193 $this->
lng->txt(
'search_no_match_hint'),
223 $this->search_cache->deleteCachedEntries();
228 foreach ($this->search_cache->getItemFilter() as $obj => $value) {
229 if (!$filter_query) {
230 $filter_query .=
'+( ';
232 $filter_query .=
'OR';
234 $filter_query .= (
' ' . $filter_settings[$obj][
'filter'] .
' ');
236 $filter_query .=
') ';
242 foreach ($this->search_cache->getMimeFilter() as $mime => $value) {
244 $mime_query .=
'+( ';
248 $mime_query .= (
' ' . $filter_settings[$mime][
'filter'] .
' ');
258 $filter_query = $filter_query .
' ' . $mime_query .
' ' . $cdate_query;
261 $query = $this->search_cache->getQuery();
263 $query =
' +(' . $query .
')';
273 $filter->setCandidates($searcher->getResult());
276 if ($filter->getResultObjIds()) {
277 $searcher->highlight($filter->getResultObjIds());
284 $presentation->setResults($filter->getResultIds());
285 $presentation->setSearcher($searcher);
288 $this->
addPager($filter,
'max_page');
290 $presentation->setPreviousNext($this->prev_link, $this->next_link);
292 if ($presentation->render()) {
293 $this->tpl->setVariable(
'SEARCH_RESULTS', $presentation->getHTML());
295 $this->tpl->setOnScreenMessage(
298 $this->
lng->txt(
'search_no_match_hint'),
310 $this->
help->setScreenIdComponent(
"src_luc");
312 $this->
tabs->addTarget(
'search', $this->
ctrl->getLinkTarget($this));
315 $this->
tabs->addTarget(
'search_user', $this->
ctrl->getLinkTargetByClass(
'illuceneusersearchgui'));
318 $this->
tabs->setTabActive(
'search');
327 if ($this->
http->wrapper()->post()->has(
'cmd')) {
329 } elseif ($this->
http->wrapper()->query()->has(
'cmd')) {
330 $requested_cmd = (array) $this->
http->wrapper()->query()->retrieve(
332 $this->
refinery->kindlyTo()->string()
334 $requested_cmd = [$requested_cmd[0] =>
"Search"];
338 $new_search = (bool) ($requested_cmd[
"performSearch"] ??
false);
339 $new_filter = (bool) ($requested_cmd[
"performSearchFilter"] ??
false);
340 $new_search_or_filter = $new_search || $new_filter;
342 if ($this->
http->wrapper()->post()->has(
'root_id')) {
343 $filter_scope = $this->
http->wrapper()->post()->retrieve(
348 $filter_scope = (
int) ($this->search_filter_data[
"search_scope"] ??
ROOT_FOLDER_ID);
351 $filter_type_active = (is_null($this->search_filter_data[
"search_type"] ??
null))
354 $requested_filter_type = (array) ($this->search_filter_data[
"search_type"] ?? []);
355 $requested_filter_type = array_flip($requested_filter_type);
356 $requested_filter_type = array_fill_keys(array_keys($requested_filter_type),
"1");
359 $this->search_cache->setResultPageNumber($page_number);
362 if ($this->
http->wrapper()->post()->has(
'term')) {
363 $term = $this->
http->wrapper()->post()->retrieve(
365 $this->
refinery->kindlyTo()->string()
368 $term = $this->search_cache->getQuery();
370 $this->search_cache->setQuery($term);
372 if ($filter_type_active) {
375 if ($requested_filter_type[$type] ??
false) {
376 $filtered[$type] = 1;
379 $this->search_cache->setItemFilter($filtered);
384 if ($requested_filter_type[$type] ??
false) {
388 $this->search_cache->setMimeFilter($mime);
391 if (!$filter_type_active) {
393 $this->search_cache->setItemFilter([]);
394 $this->search_cache->setMimeFilter([]);
396 if (!isset($this->search_filter_data[
"search_date"])) {
397 $this->search_cache->setCreationFilter([]);
401 $this->search_cache->setRoot($filter_scope);
415 if ((count($this->admin_panel_commands) > 0)) {
416 foreach ($this->admin_panel_commands as $cmd) {
417 $this->tpl->setCurrentBlock(
"lucene_admin_panel_cmd");
418 $this->tpl->setVariable(
"LUCENE_PANEL_CMD", $cmd[
"cmd"]);
419 $this->tpl->setVariable(
"LUCENE_TXT_PANEL_CMD", $cmd[
"txt"]);
420 $this->tpl->parseCurrentBlock();
426 $this->tpl->setCurrentBlock(
"lucene_adm_view_components");
428 $this->tpl->setVariable(
"LUCENE_ADM_ALT_ARROW", $this->
lng->txt(
"actions"));
429 $this->tpl->parseCurrentBlock();
430 $adm_view_cmp =
true;
434 if (is_array($this->admin_view_button)) {
435 if (is_array($this->admin_view_button)) {
436 $this->tpl->setCurrentBlock(
"lucene_admin_button");
437 $this->tpl->setVariable(
438 "LUCENE_ADMIN_MODE_LINK",
439 $this->admin_view_button[
"link"]
441 $this->tpl->setVariable(
442 "LUCENE_TXT_ADMIN_MODE",
443 $this->admin_view_button[
"txt"]
445 $this->tpl->parseCurrentBlock();
447 $this->tpl->setCurrentBlock(
"lucene_admin_view");
448 $this->tpl->parseCurrentBlock();
453 if (is_array($this->creation_selector)) {
454 $this->tpl->setCurrentBlock(
"lucene_add_commands");
456 $this->tpl->setVariable(
"LUCENE_ADD_COM_WIDTH",
'width="1"');
458 $this->tpl->setVariable(
459 "LUCENE_SELECT_OBJTYPE_REPOS",
460 $this->creation_selector[
"options"]
462 $this->tpl->setVariable(
463 "LUCENE_BTN_NAME_REPOS",
464 $this->creation_selector[
"command"]
466 $this->tpl->setVariable(
467 "LUCENE_TXT_ADD_REPOS",
468 $this->creation_selector[
"txt"]
470 $this->tpl->parseCurrentBlock();
474 $this->tpl->setCurrentBlock(
"lucene_adm_panel");
476 $this->tpl->setVariable(
"LUCENE_ADM_TBL_WIDTH",
'width:"100%";');
478 $this->tpl->parseCurrentBlock();
487 $this->admin_panel_commands[] =
488 array(
"cmd" => $a_cmd,
"txt" => $a_txt);
496 $this->admin_view_button =
497 array(
"link" => $a_link,
"txt" => $a_txt);
502 $this->page_form_action = $a_action;
507 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.search.html',
'components/ILIAS/Search');
508 $this->
renderSearch($this->search_cache->getQuery(), $this->search_cache->getRoot());
516 $options = $this->search_cache->getCreationFilter();
518 if (!($options[
'date_start'] ??
false) && !($options[
'date_end'] ??
false)) {
524 if (($options[
'date_start'] ??
false)) {
527 if (($options[
'date_end'] ??
false)) {
531 if ($start && is_null($end)) {
534 } elseif ($end && is_null($start)) {
535 return '+(cdate:[* TO ' . $end->get(
IL_CAL_DATE) .
']) ';
Builds a Color from either hex- or rgb values.
addAdminPanelCommand(string $a_cmd, string $a_txt)
Add a command to the admin panel.
setPageFormAction(string $a_action)
remoteSearch()
Search from main menu.
parseCreationFilter()
Parse creation date.
showSavedResults()
Show saved results.
__construct()
Constructor.
fillAdminPanel()
Put admin panel into template:
setAdminViewButton(string $a_link, string $a_txt)
Show admin view button.
array $admin_panel_commands
getMimeDetails()
Needed for base class search form.
getDetails()
Needed for base class search form.
executeCommand()
Execute Command.
performSearch()
Perform search.
search()
Search (button pressed)
prepareOutput()
Add admin panel command.
static getInstance(int $a_user_id)
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
GUI class for the workflow of copying objects.
renderSearch(string $term, int $root_node=0)
addPager($result, string $a_session_key)
handleCommand(string $a_cmd)
getStringArrayTransformation()
initPageNumberFromQuery()
Presentation of search results using object list gui.
static clear(string $a_var)
static resetDetails()
As long as static::resetDetails is not possible this method is final.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstance(int $a_usr_id)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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