ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilSearchGUI Class Reference

@ilCtrl_IsCalledBy ilSearchGUI: ilSearchControllerGUI More...

+ Collaboration diagram for ilSearchGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 

Protected Member Functions

 initByMode (Service $service)
 
 search ()
 
 remoteSearch ()
 Search from main menu. More...
 
 showSavedResults ()
 
 applyFilter ()
 
 switchResultPage ()
 
 sortResultPage ()
 
 autoComplete ()
 
 renderSearchInput (string $term)
 
 renderFilter (ilSearchFilterGUI $filter, int $scope)
 
 fillHeaderAndTabs ()
 
 buildViewControlInfos (Sortation $sortation, int $page, int $max_page)
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
ilObjUser $user
 
ilLanguage $lng
 
ilCtrlInterface $ctrl
 
ilTabsGUI $tabs
 
ilHelpGUI $help
 
ilSearchSettings $settings
 
ResultPresenter $result_presenter
 
Actions $actions
 
Searcher $searcher
 
SearchStateHandler $state_handler
 

Detailed Description

@ilCtrl_IsCalledBy ilSearchGUI: ilSearchControllerGUI

Definition at line 33 of file class.ilSearchGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSearchGUI::__construct ( )

Definition at line 47 of file class.ilSearchGUI.php.

48 {
49 global $DIC;
50
51 $service = new Service($DIC);
52
53 $this->tpl = $service->dic()->ui()->mainTemplate();
54 $this->user = $service->dic()->user();
55 $this->lng = $service->dic()->language();
56 $this->ctrl = $service->dic()->ctrl();
57 $this->tabs = $service->dic()->tabs();
58 $this->help = $service->dic()->help();
60 $this->result_presenter = $service->presentation()->result();
61 $this->actions = $service->gui()->actions();
62
63 $this->initByMode($service);
64 $this->tpl->loadStandardTemplate();
65 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.search.html', 'components/ILIAS/Search');
66 }
initByMode(Service $service)
$service
Definition: ltiresult.php:36
global $DIC
Definition: shib_login.php:26

References $DIC, $service, ILIAS\Repository\ctrl(), ilSearchSettings\getInstance(), ILIAS\Repository\help(), initByMode(), ILIAS\Repository\lng(), ILIAS\Repository\settings(), ILIAS\Repository\tabs(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilter()

ilSearchGUI::applyFilter ( )
protected

Definition at line 162 of file class.ilSearchGUI.php.

162 : void
163 {
164 $cache = $this->state_handler->fetchCache($this->user->getId());
165 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
166
167 $this->state_handler->loadFilterToCache($filter, $cache);
168
169 $term = $cache->getQuery();
170 $scope = $cache->getRoot();
171 $sortation = Sortation::RELEVANCE_DESC;
172 $page = 1;
173 $max_page = 1;
174
175 $this->state_handler->resetMaxPage();
176 $cache->deleteCachedEntries();
177 $cache->save();
178
179 $this->fillHeaderAndTabs();
180 $this->renderSearchInput($term);
181 $this->renderFilter($filter, $scope);
182 $view_control_infos = $this->buildViewControlInfos($sortation, $page, $max_page);
183 $this->searcher->performSearchAndRenderResults($this->user->getId(), $cache, $view_control_infos, $this->state_handler);
184 }
renderFilter(ilSearchFilterGUI $filter, int $scope)
renderSearchInput(string $term)
buildViewControlInfos(Sortation $sortation, int $page, int $max_page)
$scope
Definition: ltiregstart.php:51

References $scope, buildViewControlInfos(), fillHeaderAndTabs(), renderFilter(), renderSearchInput(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ autoComplete()

ilSearchGUI::autoComplete ( )
protected

Definition at line 226 of file class.ilSearchGUI.php.

226 : void
227 {
228 $term = $this->state_handler->fetchRequestedAutoCompleteSearchTerm();
229 $list = ilSearchAutoComplete::getList($term);
230 echo $list;
231 exit;
232 }
static getList(string $a_str)
exit

References exit, and ilSearchAutoComplete\getList().

+ Here is the call graph for this function:

◆ buildViewControlInfos()

ilSearchGUI::buildViewControlInfos ( Sortation  $sortation,
int  $page,
int  $max_page 
)
protected

Definition at line 291 of file class.ilSearchGUI.php.

296 return $this->result_presenter->getViewControlInfos(
297 $sortation,
298 $page,
299 $max_page,
300 $this->settings->getMaxHits(),
301 $this->actions->switchResultPage($sortation),
303 $this->actions->sortResultPage(),
304 Param::SORTATION
305 );
306 }

Referenced by applyFilter(), remoteSearch(), search(), showSavedResults(), sortResultPage(), and switchResultPage().

+ Here is the caller graph for this function:

◆ executeCommand()

ilSearchGUI::executeCommand ( )

Definition at line 79 of file class.ilSearchGUI.php.

79 : void
80 {
81 $next_class = $this->ctrl->getNextClass($this);
82 $cmd = $this->ctrl->getCmd();
83
84 switch ($next_class) {
85 default:
86 if (!$this->actions->isValidCommand($cmd)) {
87 $cmd = 'showSavedResults';
88 }
89 $this->$cmd();
90 break;
91 }
92 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ fillHeaderAndTabs()

ilSearchGUI::fillHeaderAndTabs ( )
protected

Definition at line 259 of file class.ilSearchGUI.php.

259 : void
260 {
261 // tabs
262 $this->tabs->addTab(
263 'search',
264 $this->lng->txt('search'),
265 (string) $this->actions->showSavedResults()
266 );
267 if ($this->settings->enabledLucene() && $this->settings->isLuceneUserSearchEnabled()) {
268 $this->tabs->addTarget(
269 'search_user',
270 $this->ctrl->getLinkTargetByClass(ilLuceneUserSearchGUI::class)
271 );
272 }
273 $this->tabs->activateTab('search');
274
275 // help
276 if ($this->settings->enabledLucene()) {
277 $this->help->setScreenIdComponent('src_luc');
278 } else {
279 $this->help->setScreenIdComponent('src');
280
281 }
282
283 // header
284 $this->tpl->setTitleIcon(
285 ilObject::_getIcon(0, "big", "src"),
286 ""
287 );
288 $this->tpl->setTitle($this->lng->txt("search"));
289 }
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.

References ilObject\_getIcon(), ILIAS\Repository\ctrl(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ILIAS\Repository\settings(), and ILIAS\Repository\tabs().

Referenced by applyFilter(), remoteSearch(), search(), showSavedResults(), sortResultPage(), and switchResultPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initByMode()

ilSearchGUI::initByMode ( Service  $service)
protected

Definition at line 68 of file class.ilSearchGUI.php.

68 : void
69 {
70 if ($this->settings->enabledLucene()) {
71 $this->searcher = $service->gui()->luceneSearcher();
72 $this->state_handler = $service->gui()->luceneSearchStateHandler();
73 } else {
74 $this->searcher = $service->gui()->directSearcher();
75 $this->state_handler = $service->gui()->directSearchStateHandler();
76 }
77 }

References $service, and ILIAS\Repository\settings().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remoteSearch()

ilSearchGUI::remoteSearch ( )
protected

Search from main menu.

Definition at line 120 of file class.ilSearchGUI.php.

120 : void
121 {
122 $cache = $this->state_handler->fetchCache($this->user->getId());
123 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
124
125 $term = $this->state_handler->fetchRequestedRemoteSearchTerm();
126 $scope = $this->state_handler->fetchRequestedRemoteScope();
127 $sortation = Sortation::RELEVANCE_DESC;
128 $page = 1;
129 $max_page = 1;
130
131 $this->state_handler->resetMaxPage();
132 $cache->deleteCachedEntries();
133 $cache->setQuery($term);
134 $cache->setRoot($scope);
135 $cache->save();
136
137 $this->fillHeaderAndTabs();
138 $this->renderSearchInput($term);
139 $this->renderFilter($filter, $scope);
140 $view_control_infos = $this->buildViewControlInfos($sortation, $page, $max_page);
141 $this->searcher->performSearchAndRenderResults($this->user->getId(), $cache, $view_control_infos, $this->state_handler);
142 }

References $scope, buildViewControlInfos(), fillHeaderAndTabs(), renderFilter(), renderSearchInput(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ renderFilter()

ilSearchGUI::renderFilter ( ilSearchFilterGUI  $filter,
int  $scope 
)
protected

Definition at line 247 of file class.ilSearchGUI.php.

250 : void {
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);
255 // scope in filter must be manipulated by JS if search is triggered in meta bar
256 $this->tpl->addOnLoadCode("il.Search.syncFilterScope('" . $filter_id . "', '" . $scope . "');");
257 }

Referenced by applyFilter(), remoteSearch(), search(), showSavedResults(), sortResultPage(), and switchResultPage().

+ Here is the caller graph for this function:

◆ renderSearchInput()

ilSearchGUI::renderSearchInput ( string  $term)
protected

Definition at line 234 of file class.ilSearchGUI.php.

234 : void
235 {
236 $this->tpl->addJavascript("assets/js/Search.js");
237
238 $this->tpl->setVariable("FORM_ACTION", $this->actions->search());
239 $this->tpl->setVariable("TERM", ilLegacyFormElementsUtil::prepareFormOutput($term));
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());
245 }
static prepareFormOutput($a_str, bool $a_strip=false)

References ilSubmitButton\getInstance(), ILIAS\Repository\lng(), and ilLegacyFormElementsUtil\prepareFormOutput().

Referenced by applyFilter(), remoteSearch(), search(), showSavedResults(), sortResultPage(), and switchResultPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ search()

ilSearchGUI::search ( )
protected

Definition at line 94 of file class.ilSearchGUI.php.

94 : void
95 {
96 $cache = $this->state_handler->fetchCache($this->user->getId());
97 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
98
99 $term = $this->state_handler->fetchRequestedSearchTerm();
100 $scope = $cache->getRoot();
101 $sortation = Sortation::RELEVANCE_DESC;
102 $page = 1;
103 $max_page = 1;
104
105 $this->state_handler->resetMaxPage();
106 $cache->deleteCachedEntries();
107 $cache->setQuery($term);
108 $cache->save();
109
110 $this->fillHeaderAndTabs();
111 $this->renderSearchInput($term);
112 $this->renderFilter($filter, $scope);
113 $view_control_infos = $this->buildViewControlInfos($sortation, $page, $max_page);
114 $this->searcher->performSearchAndRenderResults($this->user->getId(), $cache, $view_control_infos, $this->state_handler);
115 }

References $scope, buildViewControlInfos(), fillHeaderAndTabs(), renderFilter(), renderSearchInput(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ showSavedResults()

ilSearchGUI::showSavedResults ( )
protected

Definition at line 144 of file class.ilSearchGUI.php.

144 : void
145 {
146 $cache = $this->state_handler->fetchCache($this->user->getId());
147 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
148
149 $term = $cache->getQuery();
150 $scope = $cache->getRoot();
151 $sortation = Sortation::RELEVANCE_DESC;
152 $page = $cache->getResultPageNumber();
153 $max_page = $this->state_handler->fetchMaxPage();
154
155 $this->fillHeaderAndTabs();
156 $this->renderSearchInput($term);
157 $this->renderFilter($filter, $scope);
158 $view_control_infos = $this->buildViewControlInfos($sortation, $page, $max_page);
159 $this->searcher->readSavedResultsAndRenderResults($this->user->getId(), $cache, $view_control_infos);
160 }

References $scope, buildViewControlInfos(), fillHeaderAndTabs(), renderFilter(), renderSearchInput(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ sortResultPage()

ilSearchGUI::sortResultPage ( )
protected

Definition at line 208 of file class.ilSearchGUI.php.

208 : void
209 {
210 $cache = $this->state_handler->fetchCache($this->user->getId());
211 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
212
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();
218
219 $this->fillHeaderAndTabs();
220 $this->renderSearchInput($term);
221 $this->renderFilter($filter, $scope);
222 $view_control_infos = $this->buildViewControlInfos($sortation, $page, $max_page);
223 $this->searcher->readSavedResultsAndRenderResults($this->user->getId(), $cache, $view_control_infos);
224 }

References $scope, buildViewControlInfos(), fillHeaderAndTabs(), renderFilter(), renderSearchInput(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ switchResultPage()

ilSearchGUI::switchResultPage ( )
protected

Definition at line 186 of file class.ilSearchGUI.php.

186 : void
187 {
188 $cache = $this->state_handler->fetchCache($this->user->getId());
189 $filter = $this->state_handler->fetchFilter($this->actions->applyFilter());
190
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);
196
197 $this->state_handler->updateMaxPage($max_page);
198 $cache->setResultPageNumber($page);
199 $cache->save();
200
201 $this->fillHeaderAndTabs();
202 $this->renderSearchInput($term);
203 $this->renderFilter($filter, $scope);
204 $view_control_infos = $this->buildViewControlInfos($sortation, $page, $max_page);
205 $this->searcher->performSearchAndRenderResults($this->user->getId(), $cache, $view_control_infos, $this->state_handler);
206 }

References $scope, buildViewControlInfos(), fillHeaderAndTabs(), renderFilter(), renderSearchInput(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Field Documentation

◆ $actions

Actions ilSearchGUI::$actions
protected

Definition at line 43 of file class.ilSearchGUI.php.

◆ $ctrl

ilCtrlInterface ilSearchGUI::$ctrl
protected

Definition at line 38 of file class.ilSearchGUI.php.

◆ $help

ilHelpGUI ilSearchGUI::$help
protected

Definition at line 40 of file class.ilSearchGUI.php.

◆ $lng

ilLanguage ilSearchGUI::$lng
protected

Definition at line 37 of file class.ilSearchGUI.php.

◆ $result_presenter

ResultPresenter ilSearchGUI::$result_presenter
protected

Definition at line 42 of file class.ilSearchGUI.php.

◆ $searcher

Searcher ilSearchGUI::$searcher
protected

Definition at line 44 of file class.ilSearchGUI.php.

◆ $settings

ilSearchSettings ilSearchGUI::$settings
protected

Definition at line 41 of file class.ilSearchGUI.php.

◆ $state_handler

SearchStateHandler ilSearchGUI::$state_handler
protected

Definition at line 45 of file class.ilSearchGUI.php.

◆ $tabs

ilTabsGUI ilSearchGUI::$tabs
protected

Definition at line 39 of file class.ilSearchGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilSearchGUI::$tpl
protected

Definition at line 35 of file class.ilSearchGUI.php.

◆ $user

ilObjUser ilSearchGUI::$user
protected

Definition at line 36 of file class.ilSearchGUI.php.


The documentation for this class was generated from the following file: