19declare(strict_types=1);
63 $cmd = $this->
ctrl->getCmd();
84 'Invalid command for ilObjSearchSettingsFormGUI: ' . $cmd
91 bool $get_from_post =
false,
92 string $error_message =
''
95 if ($error_message !==
'') {
96 $content[] = $this->readme_helper->getServerErrorMessageBox($error_message);
100 if ($get_from_post) {
101 $form = $form->withRequest($this->
http->request());
105 $this->tpl->setContent($this->
renderer->render($content));
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();
121 $main_data = $form->getData()[
'section'];
122 $filter_data = $form->getData()[
'filter_section'];
123 $user_data = $form->getData()[
'user_section'];
125 $settings->setMaxHits((
int) $main_data[
'max_hits']);
127 switch ((
int) $main_data[
'search_type']) {
129 $settings->enableLucene(
false);
132 $settings->enableLucene(
true);
135 $settings->setDefaultOperator((
int) $main_data[
'operator']);
136 $settings->enableLuceneItemFilter(!is_null($filter_data[
'filter']));
137 if (!is_null($filter_data[
'filter'])) {
138 $settings->setLuceneItemFilter((array) $filter_data[
'filter']);
140 $settings->enableDateFilter((
bool) $filter_data[
'cdate']);
141 $settings->setAutoCompleteLength((
int) $user_data[
'auto_complete_length']);
142 $settings->showInactiveUser((
bool) $user_data[
'inactive_user']);
143 $settings->showLimitedUser((
bool) $user_data[
'limited_user']);
148 if ($settings->enabledLucene()) {
149 $this->coordinator->refreshLuceneSettings();
151 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
152 $this->
ctrl->redirect($this,
'edit');
153 }
catch (Exception $exception) {
154 $this->showForm(
false,
false, $exception->getMessage());
160 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
161 $this->
ctrl->redirect($this,
'readOnly');
164 protected function initForm(
bool $read_only): StandardForm
166 $settings = $this->getSettings();
167 $field_factory = $this->
factory->input()->field();
171 for ($value = 5; $value <= 50; $value += 5) {
172 $values[$value] = $value;
174 $hits = $field_factory->select(
175 $this->
lng->txt(
'seas_max_hits'),
177 $this->lng->txt(
'seas_max_hits_info')
178 )->withValue($settings->getMaxHits())
179 ->withRequired(
true);
182 $type = $field_factory->radio(
183 $this->
lng->txt(
'seas_search_type')
186 $this->
lng->txt(
'search_direct'),
187 $this->lng->txt(
'search_like_info')
190 $this->
lng->txt(
'search_lucene'),
191 $this->lng->txt(
'java_server_info')
192 )->withRequired(
true);
194 if ($settings->enabledLucene()) {
201 $operator = $field_factory->radio(
202 $this->
lng->txt(
'lucene_default_operator'),
203 $this->lng->txt(
'lucene_default_operator_info')
206 $this->
lng->txt(
'lucene_and')
209 $this->
lng->txt(
'lucene_or')
210 )->withRequired(
true)
211 ->withValue((
string) $settings->getDefaultOperator());
214 $filter = $settings->getLuceneItemFilter();
217 $checks[$obj] = $field_factory->checkbox(
218 $this->
lng->txt($def[
'trans'])
219 )->withValue(isset($filter[$obj]) && $filter[$obj]);
222 $item_filter = $field_factory->optionalGroup(
224 $this->
lng->txt(
'search_item_filter_form'),
225 $this->lng->txt(
'search_item_filter_form_info')
227 if (!$settings->isLuceneItemFilterEnabled()) {
228 $item_filter = $item_filter->withValue(
null);
232 $cdate = $field_factory->checkbox(
233 $this->
lng->txt(
'search_cdate_filter'),
234 $this->lng->txt(
'search_cdate_filter_info')
235 )->withValue($settings->isDateFilterEnabled());
245 $auto_complete = $field_factory->select(
246 $this->
lng->txt(
'search_auto_complete_length'),
248 $this->lng->txt(
'search_auto_complete_length_info'),
249 )->withRequired(
true)->withValue($settings->getAutoCompleteLength());
252 $inactive_user = $field_factory->checkbox(
253 $this->
lng->txt(
'search_show_inactive_user'),
254 $this->lng->txt(
'search_show_inactive_user_info')
255 )->withValue($settings->isInactiveUserVisible());
258 $limited_user = $field_factory->checkbox(
259 $this->
lng->txt(
'search_show_limited_user'),
260 $this->lng->txt(
'search_show_limited_user_info')
261 )->withValue($settings->isLimitedUserVisible());
263 $section = $this->
factory->input()->field()->section(
265 'search_type' => $type,
267 'operator' => $operator
269 $this->
lng->txt(
'seas_settings')
270 )->withDisabled($read_only);
272 $filter_section = $this->
factory->input()->field()->section(
274 'filter' => $item_filter,
277 $this->
lng->txt(
'search_filter_settings_section')
278 )->withDisabled($read_only);
280 $user_section = $this->
factory->input()->field()->section(
282 'auto_complete_length' => $auto_complete,
283 'inactive_user' => $inactive_user,
284 'limited_user' => $limited_user
286 $this->
lng->txt(
'user_search_settings_section')
287 )->withDisabled($read_only);
290 $action = $this->
ctrl->getFormAction($this,
'permDenied');
292 $action = $this->
ctrl->getFormAction($this,
'update');
295 return $this->
factory->input()->container()->form()->standard(
298 'section' => $section,
299 'filter_section' => $filter_section,
300 'user_section' => $user_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.
static getLuceneItemFilterDefinitions()
Get lucene item filter definitions.
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.