19 declare(strict_types=1);
58 $this->factory = $ui->
factory();
67 $cmd = $this->
ctrl->getCmd();
88 'Invalid command for ilObjSearchLuceneSettingsFormGUI: ' . $cmd
95 bool $get_from_post =
false 99 $form = $form->withRequest($this->
http->request());
101 $this->tpl->setContent($this->renderer->render($form));
107 ->withRequest($this->
http->request());
109 if (!$form->getData()) {
110 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
116 $data = $form->getData()[
'section'];
118 $settings->enableLuceneUserSearch((
bool)
$data[
'user_search_enabled']);
119 $settings->setFragmentCount((
int) $data[
'fragmentCount']);
120 $settings->setFragmentSize((
int) $data[
'fragmentSize']);
121 $settings->setMaxSubitems((
int) $data[
'maxSubitems']);
122 $settings->enableLuceneMimeFilter(!is_null($data[
'mime']));
123 if (!is_null($data[
'mime'])) {
124 $settings->setLuceneMimeFilter((array) $data[
'mime']);
126 $settings->enablePrefixWildcardQuery((
bool) $data[
'prefix']);
128 $data[
'last_index']->getTimestamp(),
135 if ($settings->enabledLucene()) {
136 $this->coordinator->refreshLuceneSettings();
138 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
139 $this->
ctrl->redirect($this,
'edit');
141 $this->tpl->setOnScreenMessage(
'failure', $exception->getMessage());
148 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
149 $this->
ctrl->redirect($this,
'readOnly');
155 $field_factory = $this->factory->input()->field();
158 $user_search = $field_factory->checkbox(
159 $this->
lng->txt(
'search_user_search_form'),
160 $this->
lng->txt(
'search_user_search_info_form')
161 )->
withValue($settings->isLuceneUserSearchEnabled());
164 $filter = $settings->getLuceneMimeFilter();
167 $checks[$mime] = $field_factory->checkbox(
168 $this->
lng->txt($def[
'trans'])
169 )->
withValue(isset($filter[$mime]) && $filter[$mime]);
172 $item_filter = $field_factory->optionalGroup(
174 $this->
lng->txt(
'search_mime_filter_form'),
175 $this->
lng->txt(
'search_mime_filter_form_info')
177 if (!$settings->isLuceneMimeFilterEnabled()) {
178 $item_filter = $item_filter->withValue(null);
182 $prefix = $field_factory->checkbox(
183 $this->
lng->txt(
'lucene_prefix_wildcard'),
184 $this->
lng->txt(
'lucene_prefix_wildcard_info')
185 )->
withValue($settings->isPrefixWildcardQueryEnabled());
188 $frag_count = $field_factory->numeric(
189 $this->
lng->txt(
'lucene_num_fragments'),
190 $this->
lng->txt(
'lucene_num_frag_info')
191 )->
withValue($settings->getFragmentCount())
193 ->withAdditionalTransformation(
194 $this->
refinery->int()->isLessThanOrEqual(10)
196 $this->
refinery->int()->isGreaterThanOrEqual(1)
200 $frag_size = $field_factory->numeric(
201 $this->
lng->txt(
'lucene_size_fragments'),
202 $this->
lng->txt(
'lucene_size_frag_info')
203 )->
withValue($settings->getFragmentSize())
205 ->withAdditionalTransformation(
206 $this->
refinery->int()->isLessThanOrEqual(1000)
208 $this->
refinery->int()->isGreaterThanOrEqual(10)
212 $max_sub = $field_factory->numeric(
213 $this->
lng->txt(
'lucene_max_sub'),
214 $this->
lng->txt(
'lucene_max_sub_info')
215 )->
withValue($settings->getMaxSubitems())
217 ->withAdditionalTransformation(
218 $this->
refinery->int()->isLessThanOrEqual(10)
220 $this->
refinery->int()->isGreaterThanOrEqual(1)
224 $timezone = $this->
user->getTimeZone();
226 '@' . $settings->getLastIndexTime()->get(
IL_CAL_UNIX)
229 $last_index = $field_factory->dateTime(
230 $this->
lng->txt(
'lucene_last_index_time'),
231 $this->
lng->txt(
'lucene_last_index_time_info')
232 )->withRequired(
true)
234 ->withTimezone($timezone);
235 $last_index = $last_index->withValue(
236 $datetime->format($last_index->getFormat()->toString() .
' H:i')
242 $section = $this->factory->input()->field()->section(
244 'user_search_enabled' => $user_search,
245 'mime' => $item_filter,
247 'fragmentCount' => $frag_count,
248 'fragmentSize' => $frag_size,
249 'maxSubitems' => $max_sub,
250 'last_index' => $last_index
252 $this->
lng->txt(
'lucene_settings_title')
253 )->withDisabled($read_only);
256 $action = $this->
ctrl->getFormAction($this,
'permDenied');
258 $action = $this->
ctrl->getFormAction($this,
'update');
261 return $this->factory->input()->container()->form()->standard(
263 [
'section' => $section]
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()
This is how the factory for UI elements looks.
renderer()
Get a renderer for UI components.
factory()
Get the factory that crafts UI components.
mainTemplate()
Get the ILIAS main template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...