19declare(strict_types=1);
70 $cmd = $this->
ctrl->getCmd();
91 'Invalid command for ilObjSearchLuceneSettingsFormGUI: ' . $cmd
98 bool $get_from_post =
false
100 $message = $this->readme_helper->getServerInfoMessageBox();
101 $form = $this->
initForm($read_only);
102 if ($get_from_post) {
103 $form = $form->withRequest($this->
http->request());
110 $form = $this->initForm(
false)
111 ->withRequest($this->
http->request());
113 if (!$form->getData()) {
114 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
115 $this->showForm(
false,
true);
119 $settings = $this->getSettings();
120 $data = $form->getData()[
'section'];
122 $settings->enableLuceneUserSearch((
bool)
$data[
'user_search_enabled']);
123 $settings->setFragmentCount((
int)
$data[
'fragmentCount']);
124 $settings->setFragmentSize((
int)
$data[
'fragmentSize']);
125 $settings->setMaxSubitems((
int)
$data[
'maxSubitems']);
126 $settings->enableLuceneMimeFilter(!is_null(
$data[
'mime']));
127 if (!is_null(
$data[
'mime'])) {
128 $settings->setLuceneMimeFilter((array)
$data[
'mime']);
130 $settings->enablePrefixWildcardQuery((
bool)
$data[
'prefix']);
132 $data[
'last_index']->getTimestamp(),
139 if ($settings->enabledLucene()) {
140 $this->coordinator->refreshLuceneSettings();
142 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
143 $this->
ctrl->redirect($this,
'edit');
144 }
catch (Exception $exception) {
145 $this->tpl->setOnScreenMessage(
'failure', $exception->getMessage());
146 $this->showForm(
false);
152 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
153 $this->
ctrl->redirect($this,
'readOnly');
156 protected function initForm(
bool $read_only): StandardForm
158 $settings = $this->getSettings();
159 $field_factory = $this->
factory->input()->field();
162 $user_search = $field_factory->checkbox(
163 $this->
lng->txt(
'search_user_search_form'),
164 $this->lng->txt(
'search_user_search_info_form')
165 )->withValue($settings->isLuceneUserSearchEnabled());
168 $filter = $settings->getLuceneMimeFilter();
171 $checks[$mime] = $field_factory->checkbox(
172 $this->
lng->txt($def[
'trans'])
173 )->withValue(isset($filter[$mime]) && $filter[$mime]);
176 $item_filter = $field_factory->optionalGroup(
178 $this->
lng->txt(
'search_mime_filter_form'),
179 $this->lng->txt(
'search_mime_filter_form_info')
181 if (!$settings->isLuceneMimeFilterEnabled()) {
182 $item_filter = $item_filter->withValue(
null);
186 $prefix = $field_factory->checkbox(
187 $this->
lng->txt(
'lucene_prefix_wildcard'),
188 $this->lng->txt(
'lucene_prefix_wildcard_info')
189 )->withValue($settings->isPrefixWildcardQueryEnabled());
192 $frag_count = $field_factory->numeric(
193 $this->
lng->txt(
'lucene_num_fragments'),
194 $this->lng->txt(
'lucene_num_frag_info')
195 )->withValue($settings->getFragmentCount())
197 ->withAdditionalTransformation(
198 $this->
refinery->int()->isLessThanOrEqual(10)
199 )->withAdditionalTransformation(
200 $this->
refinery->int()->isGreaterThanOrEqual(1)
204 $frag_size = $field_factory->numeric(
205 $this->
lng->txt(
'lucene_size_fragments'),
206 $this->lng->txt(
'lucene_size_frag_info')
207 )->withValue($settings->getFragmentSize())
209 ->withAdditionalTransformation(
210 $this->
refinery->int()->isLessThanOrEqual(1000)
211 )->withAdditionalTransformation(
212 $this->
refinery->int()->isGreaterThanOrEqual(10)
216 $max_sub = $field_factory->numeric(
217 $this->
lng->txt(
'lucene_max_sub'),
218 $this->lng->txt(
'lucene_max_sub_info')
219 )->withValue($settings->getMaxSubitems())
221 ->withAdditionalTransformation(
222 $this->
refinery->int()->isLessThanOrEqual(10)
223 )->withAdditionalTransformation(
224 $this->
refinery->int()->isGreaterThanOrEqual(1)
228 $timezone = $this->
user->getTimeZone();
230 '@' . $settings->getLastIndexTime()->get(
IL_CAL_UNIX)
232 $datetime->setTimezone(
new DateTimeZone($timezone));
233 $last_index = $field_factory->dateTime(
234 $this->
lng->txt(
'lucene_last_index_time'),
235 $this->lng->txt(
'lucene_last_index_time_info')
236 )->withRequired(
true)
238 ->withTimezone($timezone);
239 $last_index = $last_index->withValue(
240 $datetime->format($last_index->getFormat()->toString() .
' H:i')
246 $section = $this->
factory->input()->field()->section(
248 'user_search_enabled' => $user_search,
249 'mime' => $item_filter,
251 'fragmentCount' => $frag_count,
252 'fragmentSize' => $frag_size,
253 'maxSubitems' => $max_sub,
254 'last_index' => $last_index
256 $this->
lng->txt(
'lucene_settings_title')
257 )->withDisabled($read_only);
260 $action = $this->
ctrl->getFormAction($this,
'permDenied');
262 $action = $this->
ctrl->getFormAction($this,
'update');
265 return $this->
factory->input()->container()->form()->standard(
267 [
'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.
Builds a Color from either hex- or rgb values.
@classDescription Date and time handling
static getLuceneMimeFilterDefinitions()
Interface GlobalHttpState.
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...
static http()
Fetches the global http state from ILIAS.