ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ILIAS\Search\GUI\Lucene\SearcherImpl Class Reference
+ Inheritance diagram for ILIAS\Search\GUI\Lucene\SearcherImpl:
+ Collaboration diagram for ILIAS\Search\GUI\Lucene\SearcherImpl:

Public Member Functions

 __construct (protected ilSearchSettings $settings, protected ilGlobalTemplateInterface $tpl, protected UIRenderer $ui_renderer, protected ResultPresenter $presenter, protected ilLanguage $lng)
 
 performSearchAndRenderResults (int $usr_id, ilUserSearchCache $cache, ViewControlInfos $view_control_infos, SearchStateHandler $state_handler)
 Note that the cache doubles here as an actual cache, but also as a data object bundling all inputs needed to search. More...
 
 readSavedResultsAndRenderResults (int $usr_id, ilUserSearchCache $cache, ViewControlInfos $view_control_infos)
 
 performSearchAndRenderResults (int $usr_id, ilUserSearchCache $cache, ViewControlInfos $view_control_infos, SearchStateHandler $state_handler)
 Note that the cache doubles here as an actual cache, but also as a data object bundling all inputs needed to search. More...
 
 readSavedResultsAndRenderResults (int $usr_id, ilUserSearchCache $cache, ViewControlInfos $view_control_infos)
 

Protected Member Functions

 renderResults (ilLuceneSearchResultFilter $filter, ?ilLuceneHighlighterResultParser $highlighter, string $term, ViewControlInfos $view_control_infos)
 
 parseCreationFilter (ilUserSearchCache $cache)
 
 parseCopyrightFilter (ilUserSearchCache $cache)
 

Detailed Description

Definition at line 40 of file SearcherImpl.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Search\GUI\Lucene\SearcherImpl::__construct ( protected ilSearchSettings  $settings,
protected ilGlobalTemplateInterface  $tpl,
protected UIRenderer  $ui_renderer,
protected ResultPresenter  $presenter,
protected ilLanguage  $lng 
)

Definition at line 42 of file SearcherImpl.php.

48 {
49 }

Member Function Documentation

◆ parseCopyrightFilter()

ILIAS\Search\GUI\Lucene\SearcherImpl::parseCopyrightFilter ( ilUserSearchCache  $cache)
protected

Definition at line 222 of file SearcherImpl.php.

222 : string
223 {
224 $identifiers = $cache->getCopyrightFilter();
225 if ($identifiers === []) {
226 return '';
227 }
228
229 $conditions = [];
230 foreach ($identifiers as $identifier) {
231 $conditions[] = 'lomCopyright:"' . $identifier . '"';
232 }
233 return '+(' . implode(' OR ', $conditions) . ')';
234 }

References ilUserSearchCache\getCopyrightFilter().

+ Here is the call graph for this function:

◆ parseCreationFilter()

ILIAS\Search\GUI\Lucene\SearcherImpl::parseCreationFilter ( ilUserSearchCache  $cache)
protected

Definition at line 193 of file SearcherImpl.php.

193 : string
194 {
195 $options = $cache->getCreationFilter();
196
197 if (!($options['date_start'] ?? false) && !($options['date_end'] ?? false)) {
198 return '';
199 }
200
201 $start = null;
202 $end = null;
203 if (($options['date_start'] ?? false)) {
204 $start = new ilDate($options['date_start'] ?? "", IL_CAL_DATE);
205 }
206 if (($options['date_end'] ?? false)) {
207 $end = new ilDate($options['date_end'] ?? "", IL_CAL_DATE);
208 }
209
210 if ($start && is_null($end)) {
211 $now = new ilDate(time(), IL_CAL_UNIX);
212 return '+(cdate:[' . $start->get(IL_CAL_DATE) . ' TO ' . $now->get(IL_CAL_DATE) . '*]) ';
213 } elseif ($end && is_null($start)) {
214 return '+(cdate:[* TO ' . $end->get(IL_CAL_DATE) . ']) ';
215 } else {
216 return '+(cdate:[' . $start->get(IL_CAL_DATE) . ' TO ' . $end->get(IL_CAL_DATE) . '*]) ';
217 }
218
219 return '';
220 }
const IL_CAL_DATE
const IL_CAL_UNIX
Class for single dates.

References ILIAS\UI\Implementation\Component\Input\Field\$options, ilUserSearchCache\getCreationFilter(), IL_CAL_DATE, and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ performSearchAndRenderResults()

ILIAS\Search\GUI\Lucene\SearcherImpl::performSearchAndRenderResults ( int  $usr_id,
ilUserSearchCache  $cache,
ViewControlInfos  $view_control_infos,
SearchStateHandler  $state_handler 
)

Note that the cache doubles here as an actual cache, but also as a data object bundling all inputs needed to search.

Maybe split that up in the future?

This should not be here. As soon as we have a unified format for search results, this should be done by the GUI.

Implements ILIAS\Search\GUI\Searcher.

Definition at line 51 of file SearcherImpl.php.

56 : void {
57 $filter_query = '';
58 if ($cache->getItemFilter() and ilSearchSettings::getInstance()->isLuceneItemFilterEnabled()) {
59 $filter_settings = ilSearchSettings::getInstance()->getEnabledLuceneItemFilterDefinitions();
60 foreach ($cache->getItemFilter() as $obj => $value) {
61 if (!$filter_query) {
62 $filter_query .= '+( ';
63 } else {
64 $filter_query .= 'OR';
65 }
66 $filter_query .= (' ' . $filter_settings[$obj]['filter'] . ' ');
67 }
68 $filter_query .= ') ';
69 }
70
71 $mime_query = '';
72 if ($cache->getMimeFilter() and ilSearchSettings::getInstance()->isLuceneMimeFilterEnabled()) {
73 $filter_settings = ilSearchSettings::getInstance()->getEnabledLuceneMimeFilterDefinitions();
74 foreach ($cache->getMimeFilter() as $mime => $value) {
75 if (!$mime_query) {
76 $mime_query .= '+( ';
77 } else {
78 $mime_query .= 'OR';
79 }
80 $mime_query .= (' ' . $filter_settings[$mime]['filter'] . ' ');
81 }
82 $mime_query .= ') ';
83 }
84
85 $cdate_query = $this->parseCreationFilter($cache);
86 $copyright_query = $this->parseCopyrightFilter($cache);
87
88 $filter_query = $filter_query . ' ' . $mime_query . ' ' . $cdate_query . ' ' . $copyright_query;
89
90 $query = $cache->getQuery();
91 if ($query) {
92 $query = ' +(' . $query . ')';
93 }
94 $qp = new ilLuceneQueryParser($filter_query . $query);
95 $qp->parse();
96 $searcher = ilLuceneSearcher::getInstance($qp);
97 $searcher->search();
98
99 // Filter results
101 $filter->addFilter(new ilLucenePathFilter($cache->getRoot()));
102 $filter->setCandidates($searcher->getResult());
103 $filter->filter();
104
105 if ($filter->getResultObjIds()) {
106 $searcher->highlight($filter->getResultObjIds());
107 }
108
113 if (
114 $view_control_infos->currentPage() === $view_control_infos->maxPages() &&
115 $filter->isLimitReached()
116 ) {
117 $view_control_infos = $this->presenter->getViewControlInfos(
118 $view_control_infos->sortation(),
119 $view_control_infos->currentPage(),
120 $view_control_infos->maxPages() + 1,
121 $view_control_infos->pageSize(),
122 $view_control_infos->paginationAction(),
123 $view_control_infos->pageParam(),
124 $view_control_infos->sortationAction(),
125 $view_control_infos->sortationParam()
126 );
127 $state_handler->updateMaxPage($view_control_infos->maxPages());
128 }
129
130 $this->renderResults($filter, $searcher->getHighlighter(), $cache->getQuery(), $view_control_infos);
131 }
renderResults(ilLuceneSearchResultFilter $filter, ?ilLuceneHighlighterResultParser $highlighter, string $term, ViewControlInfos $view_control_infos)
parseCreationFilter(ilUserSearchCache $cache)
parseCopyrightFilter(ilUserSearchCache $cache)
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.

References ilSearchSettings\getInstance(), and ilUserSearchCache\getItemFilter().

+ Here is the call graph for this function:

◆ readSavedResultsAndRenderResults()

ILIAS\Search\GUI\Lucene\SearcherImpl::readSavedResultsAndRenderResults ( int  $usr_id,
ilUserSearchCache  $cache,
ViewControlInfos  $view_control_infos 
)

Implements ILIAS\Search\GUI\Searcher.

Definition at line 133 of file SearcherImpl.php.

137 : void {
138 if (!strlen($cache->getQuery())) {
139 $this->tpl->setOnScreenMessage(
141 $this->lng->txt('search_no_match')
142 );
143 return;
144 }
145
146 $qp = new ilLuceneQueryParser($cache->getQuery());
147 $qp->parse();
148 $searcher = ilLuceneSearcher::getInstance($qp);
149 $searcher->search();
150
151 // Load saved results
153 $filter->loadFromDb();
154
155 // Highlight
156 $searcher->highlight($filter->getResultObjIds());
157
158 $this->renderResults($filter, $searcher->getHighlighter(), $cache->getQuery(), $view_control_infos);
159 }

References ILIAS\Repository\lng(), and ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_INFO.

+ Here is the call graph for this function:

◆ renderResults()

ILIAS\Search\GUI\Lucene\SearcherImpl::renderResults ( ilLuceneSearchResultFilter  $filter,
?ilLuceneHighlighterResultParser  $highlighter,
string  $term,
ViewControlInfos  $view_control_infos 
)
protected

Definition at line 161 of file SearcherImpl.php.

166 : void {
167 if ($filter->getResults() && $highlighter !== null) {
168 $result_panel_and_modals = $this->presenter->getLuceneSearchResultAsPanel(
169 $filter,
170 $highlighter,
171 $view_control_infos
172 );
173 $this->tpl->setVariable(
174 'SEARCH_RESULTS',
175 $this->presenter->replacePlaceholders($this->ui_renderer->render($result_panel_and_modals))
176 );
177 } elseif ($term !== '') {
178 $this->tpl->setOnScreenMessage(
180 sprintf(
181 $this->lng->txt('search_no_match_hint'),
182 $term
183 )
184 );
185 } else {
186 $this->tpl->setOnScreenMessage(
188 $this->lng->txt('search_no_match')
189 );
190 }
191 }

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