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());
105 $this->tpl->setContent($this->
renderer->render([$message, $form]));
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'];
121 $text_data = $form->getData()[
'text_section'];
122 $index_data = $form->getData()[
'index_section'];
124 $settings->enableLuceneUserSearch((
bool)
$data[
'user_search_enabled']);
125 $settings->setFragmentCount((
int) $text_data[
'fragmentCount']);
126 $settings->setFragmentSize((
int) $text_data[
'fragmentSize']);
127 $settings->enableLuceneMimeFilter(!is_null(
$data[
'mime']));
128 if (!is_null(
$data[
'mime'])) {
129 $settings->setLuceneMimeFilter((array)
$data[
'mime']);
131 $settings->enablePrefixWildcardQuery((
bool)
$data[
'prefix']);
133 $index_data[
'last_index']->getTimestamp(),
140 if ($settings->enabledLucene()) {
141 $this->coordinator->refreshLuceneSettings();
143 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
144 $this->
ctrl->redirect($this,
'edit');
145 }
catch (Exception $exception) {
146 $this->tpl->setOnScreenMessage(
'failure', $exception->getMessage());
147 $this->showForm(
false);
153 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
154 $this->
ctrl->redirect($this,
'readOnly');
157 protected function initForm(
bool $read_only): StandardForm
159 $settings = $this->getSettings();
160 $field_factory = $this->
factory->input()->field();
163 $user_search = $field_factory->checkbox(
164 $this->
lng->txt(
'search_user_search_form'),
165 $this->lng->txt(
'search_user_search_info_form')
166 )->withValue($settings->isLuceneUserSearchEnabled());
169 $filter = $settings->getLuceneMimeFilter();
172 $checks[$mime] = $field_factory->checkbox(
173 $this->
lng->txt($def[
'trans'])
174 )->withValue(isset($filter[$mime]) && $filter[$mime]);
177 $item_filter = $field_factory->optionalGroup(
179 $this->
lng->txt(
'search_mime_filter_form'),
180 $this->lng->txt(
'search_mime_filter_form_info')
182 if (!$settings->isLuceneMimeFilterEnabled()) {
183 $item_filter = $item_filter->withValue(
null);
187 $prefix = $field_factory->checkbox(
188 $this->
lng->txt(
'lucene_prefix_wildcard'),
189 $this->lng->txt(
'lucene_prefix_wildcard_info')
190 )->withValue($settings->isPrefixWildcardQueryEnabled());
193 $frag_count = $field_factory->numeric(
194 $this->
lng->txt(
'lucene_num_fragments'),
195 $this->lng->txt(
'lucene_num_frag_info')
196 )->withValue($settings->getFragmentCount())
198 ->withAdditionalTransformation(
199 $this->
refinery->int()->isLessThanOrEqual(10)
200 )->withAdditionalTransformation(
201 $this->
refinery->int()->isGreaterThanOrEqual(1)
205 $frag_size = $field_factory->numeric(
206 $this->
lng->txt(
'lucene_size_fragments'),
207 $this->lng->txt(
'lucene_size_frag_info')
208 )->withValue($settings->getFragmentSize())
210 ->withAdditionalTransformation(
211 $this->
refinery->int()->isLessThanOrEqual(1000)
212 )->withAdditionalTransformation(
213 $this->
refinery->int()->isGreaterThanOrEqual(10)
217 $timezone = $this->
user->getTimeZone();
219 '@' . $settings->getLastIndexTime()->get(
IL_CAL_UNIX)
221 $datetime->setTimezone(
new DateTimeZone($timezone));
222 $last_index = $field_factory->dateTime(
223 $this->
lng->txt(
'lucene_last_index_time'),
224 $this->lng->txt(
'lucene_last_index_time_info')
225 )->withRequired(
true)
227 ->withTimezone($timezone);
228 $last_index = $last_index->withValue(
229 $datetime->format($last_index->getFormat()->toString() .
' H:i')
232 $section = $this->
factory->input()->field()->section(
234 'user_search_enabled' => $user_search,
235 'mime' => $item_filter,
238 $this->
lng->txt(
'lucene_settings_title')
239 )->withDisabled($read_only);
241 $text_section = $this->
factory->input()->field()->section(
243 'fragmentCount' => $frag_count,
244 'fragmentSize' => $frag_size
246 $this->
lng->txt(
'lucene_settings_text_section')
247 )->withDisabled($read_only);
249 $index_section = $this->
factory->input()->field()->section(
251 'last_index' => $last_index
253 $this->
lng->txt(
'lucene_settings_index_section')
254 )->withDisabled($read_only);
257 $action = $this->
ctrl->getFormAction($this,
'permDenied');
259 $action = $this->
ctrl->getFormAction($this,
'update');
262 return $this->
factory->input()->container()->form()->standard(
265 'section' => $section,
266 'text_section' => $text_section,
267 'index_section' => $index_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.