3declare(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));
105 $form = $this->initForm(
false)
106 ->withRequest($this->
http->request());
108 if (!$form->getData()) {
109 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
110 $this->showForm(
false,
true);
115 $data = $form->getData()[
'section'];
122 if (!is_null(
$data[
'mime'])) {
125 $settings->showSubRelevance((
bool) (
$data[
'relevance'][
'subrelevance'] ??
false));
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');
141 }
catch (Exception $exception) {
142 $this->tpl->setOnScreenMessage(
'failure', $exception->getMessage());
143 $this->showForm(
false);
149 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
150 $this->
ctrl->redirect($this,
'readOnly');
153 protected function initForm(
bool $read_only): StandardForm
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')
180 )->withValue(
$settings->isPrefixWildcardQueryEnabled());
183 $frag_count = $field_factory->numeric(
184 $this->
lng->txt(
'lucene_num_fragments'),
185 $this->lng->txt(
'lucene_num_frag_info')
186 )->withValue(
$settings->getFragmentCount())
188 ->withAdditionalTransformation(
189 $this->
refinery->int()->isLessThanOrEqual(10)
190 )->withAdditionalTransformation(
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')
198 )->withValue(
$settings->getFragmentSize())
200 ->withAdditionalTransformation(
201 $this->
refinery->int()->isLessThanOrEqual(1000)
202 )->withAdditionalTransformation(
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')
210 )->withValue(
$settings->getMaxSubitems())
212 ->withAdditionalTransformation(
213 $this->
refinery->int()->isLessThanOrEqual(10)
214 )->withAdditionalTransformation(
215 $this->
refinery->int()->isGreaterThanOrEqual(1)
219 $subrel = $field_factory->checkbox(
220 $this->
lng->txt(
'lucene_show_sub_relevance')
221 )->withValue(
$settings->isSubRelevanceVisible());
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();
234 $datetime =
new DateTime(
237 $datetime->setTimezone(
new DateTimeZone($timezone));
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]
Provides fluid interface to RBAC services.
renderer()
Get a renderer for UI components.
mainTemplate()
Get the ILIAS main template.
factory()
Get the factory that crafts UI components.
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLuceneMimeFilterDefinitions()
static clear(string $a_var)
Interface GlobalHttpState.
A constraint encodes some resrtictions on values.
This is how the factory for UI elements looks.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.