19declare(strict_types=1);
53 $this->tpl =
$service->dic()->ui()->mainTemplate();
60 $this->result_presenter =
$service->presentation()->result();
61 $this->actions =
$service->gui()->actions();
64 $this->tpl->loadStandardTemplate();
65 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.search.html',
'components/ILIAS/Search');
70 if ($this->
settings->enabledLucene()) {
71 $this->searcher =
$service->gui()->luceneSearcher();
72 $this->state_handler =
$service->gui()->luceneSearchStateHandler();
74 $this->searcher =
$service->gui()->directSearcher();
75 $this->state_handler =
$service->gui()->directSearchStateHandler();
81 $next_class = $this->
ctrl->getNextClass($this);
82 $cmd = $this->
ctrl->getCmd();
84 switch ($next_class) {
86 if (!$this->actions->isValidCommand($cmd)) {
87 $cmd =
'showSavedResults';
96 $cache = $this->state_handler->fetchCache($this->
user->getId());
97 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
99 $term = $this->state_handler->fetchRequestedSearchTerm();
100 $scope = $cache->getRoot();
101 $sortation = Sortation::RELEVANCE_DESC;
105 $this->state_handler->resetMaxPage();
106 $cache->deleteCachedEntries();
107 $cache->setQuery($term);
114 $this->searcher->performSearchAndRenderResults($this->
user->getId(), $cache, $view_control_infos, $this->state_handler);
122 $cache = $this->state_handler->fetchCache($this->
user->getId());
123 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
125 $term = $this->state_handler->fetchRequestedRemoteSearchTerm();
126 $scope = $this->state_handler->fetchRequestedRemoteScope();
127 $sortation = Sortation::RELEVANCE_DESC;
131 $this->state_handler->resetMaxPage();
132 $cache->deleteCachedEntries();
133 $cache->setQuery($term);
141 $this->searcher->performSearchAndRenderResults($this->
user->getId(), $cache, $view_control_infos, $this->state_handler);
146 $cache = $this->state_handler->fetchCache($this->
user->getId());
147 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
149 $term = $cache->getQuery();
150 $scope = $cache->getRoot();
151 $sortation = Sortation::RELEVANCE_DESC;
152 $page = $cache->getResultPageNumber();
153 $max_page = $this->state_handler->fetchMaxPage();
159 $this->searcher->readSavedResultsAndRenderResults($this->
user->getId(), $cache, $view_control_infos);
164 $cache = $this->state_handler->fetchCache($this->
user->getId());
165 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
167 $this->state_handler->loadFilterToCache($filter, $cache);
169 $term = $cache->getQuery();
170 $scope = $cache->getRoot();
171 $sortation = Sortation::RELEVANCE_DESC;
175 $this->state_handler->resetMaxPage();
176 $cache->deleteCachedEntries();
183 $this->searcher->performSearchAndRenderResults($this->
user->getId(), $cache, $view_control_infos, $this->state_handler);
188 $cache = $this->state_handler->fetchCache($this->
user->getId());
189 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
191 $term = $cache->getQuery();
192 $scope = $cache->getRoot();
193 $sortation = $this->state_handler->fetchSortation();
194 $page = $this->state_handler->fetchRequestedPage();
195 $max_page = max($this->state_handler->fetchMaxPage(), $page);
197 $this->state_handler->updateMaxPage($max_page);
198 $cache->setResultPageNumber($page);
205 $this->searcher->performSearchAndRenderResults($this->
user->getId(), $cache, $view_control_infos, $this->state_handler);
210 $cache = $this->state_handler->fetchCache($this->
user->getId());
211 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
213 $term = $cache->getQuery();
214 $scope = $cache->getRoot();
215 $sortation = $this->state_handler->fetchSortation();
216 $page = $cache->getResultPageNumber();
217 $max_page = $this->state_handler->fetchMaxPage();
223 $this->searcher->readSavedResultsAndRenderResults($this->
user->getId(), $cache, $view_control_infos);
228 $term = $this->state_handler->fetchRequestedAutoCompleteSearchTerm();
236 $this->tpl->addJavascript(
"assets/js/Search.js");
238 $this->tpl->setVariable(
"FORM_ACTION", $this->actions->search());
240 $this->tpl->setVariable(
"SEARCH_LABEL", $this->
lng->txt(
"search"));
242 $btn->setCommand(
"performSearch");
243 $btn->setCaption(
"search");
244 $this->tpl->setVariable(
"SUBMIT_BTN", $btn->render());
251 $filter_html = $filter->getHTML();
252 preg_match(
'/id="([^"]+)"/', $filter_html, $matches);
253 $filter_id = $matches[1];
254 $this->tpl->setVariable(
"SEARCH_FILTER", $filter_html);
256 $this->tpl->addOnLoadCode(
"il.Search.syncFilterScope('" . $filter_id .
"', '" .
$scope .
"');");
264 $this->
lng->txt(
'search'),
265 (
string) $this->actions->showSavedResults()
267 if ($this->
settings->enabledLucene() && $this->settings->isLuceneUserSearchEnabled()) {
268 $this->
tabs->addTarget(
270 $this->
ctrl->getLinkTargetByClass(ilLuceneUserSearchGUI::class)
273 $this->
tabs->activateTab(
'search');
276 if ($this->
settings->enabledLucene()) {
277 $this->
help->setScreenIdComponent(
'src_luc');
279 $this->
help->setScreenIdComponent(
'src');
284 $this->tpl->setTitleIcon(
288 $this->tpl->setTitle($this->
lng->txt(
"search"));
296 return $this->result_presenter->getViewControlInfos(
301 $this->actions->switchResultPage($sortation),
303 $this->actions->sortResultPage(),
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static getList(string $a_str)
@ilCtrl_IsCalledBy ilSearchGUI: ilSearchControllerGUI
SearchStateHandler $state_handler
ilSearchSettings $settings
remoteSearch()
Search from main menu.
renderFilter(ilSearchFilterGUI $filter, int $scope)
ilGlobalTemplateInterface $tpl
renderSearchInput(string $term)
buildViewControlInfos(Sortation $sortation, int $page, int $max_page)
ResultPresenter $result_presenter
initByMode(Service $service)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Until there is a unified format for search results, rendering also has to be done seperately.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...