3 declare(strict_types=1);
57 $this->factory = $ui->
factory();
66 $cmd = $this->
ctrl->getCmd();
87 'Invalid command for ilObjSearchLuceneSettingsFormGUI: ' . $cmd
94 bool $get_from_post =
false 98 $form = $form->withRequest($this->
http->request());
100 $this->tpl->setContent($this->renderer->render($form));
106 ->withRequest($this->
http->request());
108 if (!$form->getData()) {
109 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
115 $data = $form->getData()[
'section'];
118 $settings->setFragmentSize((
int) $data[
'fragmentSize']);
119 $settings->setMaxSubitems((
int) $data[
'maxSubitems']);
120 $settings->showRelevance((
bool) $data[
'relevance']);
121 $settings->enableLuceneMimeFilter(!is_null($data[
'mime']));
122 if (!is_null($data[
'mime'])) {
123 $settings->setLuceneMimeFilter((array) $data[
'mime']);
125 $settings->showSubRelevance((
bool) ($data[
'relevance'][
'subrelevance'] ??
false));
126 $settings->enablePrefixWildcardQuery((
bool) $data[
'prefix']);
128 $data[
'last_index']->getTimestamp(),
136 $this->coordinator->refreshLuceneSettings();
138 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
140 $this->
ctrl->redirect($this,
'edit');
142 $this->tpl->setOnScreenMessage(
'failure', $exception->getMessage());
149 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
150 $this->
ctrl->redirect($this,
'readOnly');
156 $field_factory = $this->factory->input()->field();
159 $filter =
$settings->getLuceneMimeFilter();
162 $checks[$mime] = $field_factory->checkbox(
163 $this->
lng->txt($def[
'trans'])
164 )->
withValue(isset($filter[$mime]) && $filter[$mime]);
167 $item_filter = $field_factory->optionalGroup(
169 $this->
lng->txt(
'search_mime_filter_form'),
170 $this->
lng->txt(
'search_mime_filter_form_info')
172 if (!
$settings->isLuceneMimeFilterEnabled()) {
173 $item_filter = $item_filter->withValue(null);
177 $prefix = $field_factory->checkbox(
178 $this->
lng->txt(
'lucene_prefix_wildcard'),
179 $this->
lng->txt(
'lucene_prefix_wildcard_info')
183 $frag_count = $field_factory->numeric(
184 $this->
lng->txt(
'lucene_num_fragments'),
185 $this->
lng->txt(
'lucene_num_frag_info')
188 ->withAdditionalTransformation(
189 $this->
refinery->int()->isLessThanOrEqual(10)
191 $this->
refinery->int()->isGreaterThanOrEqual(1)
195 $frag_size = $field_factory->numeric(
196 $this->
lng->txt(
'lucene_size_fragments'),
197 $this->
lng->txt(
'lucene_size_frag_info')
200 ->withAdditionalTransformation(
201 $this->
refinery->int()->isLessThanOrEqual(1000)
203 $this->
refinery->int()->isGreaterThanOrEqual(10)
207 $max_sub = $field_factory->numeric(
208 $this->
lng->txt(
'lucene_max_sub'),
209 $this->
lng->txt(
'lucene_max_sub_info')
212 ->withAdditionalTransformation(
213 $this->
refinery->int()->isLessThanOrEqual(10)
215 $this->
refinery->int()->isGreaterThanOrEqual(1)
219 $subrel = $field_factory->checkbox(
220 $this->
lng->txt(
'lucene_show_sub_relevance')
223 $relevance = $field_factory->optionalGroup(
224 [
'subrelevance' => $subrel],
225 $this->
lng->txt(
'lucene_relevance'),
226 $this->
lng->txt(
'lucene_show_relevance_info')
229 $relevance = $relevance->withValue(null);
233 $timezone = $this->
user->getTimeZone();
238 $last_index = $field_factory->dateTime(
239 $this->
lng->txt(
'lucene_last_index_time'),
240 $this->
lng->txt(
'lucene_last_index_time_info')
241 )->withRequired(
true)
243 ->withTimezone($timezone);
244 $last_index = $last_index->withValue(
245 $datetime->format($last_index->getFormat()->toString() .
' H:i')
251 $section = $this->factory->input()->field()->section(
253 'mime' => $item_filter,
255 'fragmentCount' => $frag_count,
256 'fragmentSize' => $frag_size,
257 'maxSubitems' => $max_sub,
258 'relevance' => $relevance,
259 'last_index' => $last_index
261 $this->
lng->txt(
'lucene_settings_title')
262 )->withDisabled($read_only);
265 $action = $this->
ctrl->getFormAction($this,
'permDenied');
267 $action = $this->
ctrl->getFormAction($this,
'update');
270 return $this->factory->input()->container()->form()->standard(
272 [
'section' => $section]
Interface GlobalHttpState.
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Provides fluid interface to RBAC services.
static http()
Fetches the global http state from ILIAS.
static getLuceneMimeFilterDefinitions()
renderer()
Get a renderer for UI components.
factory()
Get the factory that crafts UI components.
static clear(string $a_var)
mainTemplate()
Get the ILIAS main template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...