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 $user_data = $form->getData()[
'user_section'];
124 $settings->setMaxHits((
int) $main_data[
'max_hits']);
126 switch ((
int) $main_data[
'search_type']) {
128 $settings->enableLucene(
false);
131 $settings->enableLucene(
true);
134 $settings->setDefaultOperator((
int) $main_data[
'operator']);
135 $settings->enableLuceneItemFilter(!is_null($main_data[
'filter']));
136 if (!is_null($main_data[
'filter'])) {
137 $settings->setLuceneItemFilter((array) $main_data[
'filter']);
139 $settings->enableDateFilter((
bool) $main_data[
'cdate']);
140 $settings->setAutoCompleteLength((
int) $user_data[
'auto_complete_length']);
141 $settings->showInactiveUser((
bool) $user_data[
'inactive_user']);
142 $settings->showLimitedUser((
bool) $user_data[
'limited_user']);
147 if ($settings->enabledLucene()) {
148 $this->coordinator->refreshLuceneSettings();
150 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
151 $this->
ctrl->redirect($this,
'edit');
152 }
catch (Exception $exception) {
153 $this->showForm(
false,
false, $exception->getMessage());
159 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
160 $this->
ctrl->redirect($this,
'readOnly');
163 protected function initForm(
bool $read_only): StandardForm
165 $settings = $this->getSettings();
166 $field_factory = $this->
factory->input()->field();
170 for ($value = 5; $value <= 50; $value += 5) {
171 $values[$value] = $value;
173 $hits = $field_factory->select(
174 $this->
lng->txt(
'seas_max_hits'),
176 $this->lng->txt(
'seas_max_hits_info')
177 )->withValue($settings->getMaxHits())
178 ->withRequired(
true);
181 $type = $field_factory->radio(
182 $this->
lng->txt(
'seas_search_type')
185 $this->
lng->txt(
'search_direct'),
186 $this->lng->txt(
'search_like_info')
189 $this->
lng->txt(
'search_lucene'),
190 $this->lng->txt(
'java_server_info')
191 )->withRequired(
true);
193 if ($settings->enabledLucene()) {
200 $operator = $field_factory->radio(
201 $this->
lng->txt(
'lucene_default_operator'),
202 $this->lng->txt(
'lucene_default_operator_info')
205 $this->
lng->txt(
'lucene_and')
208 $this->
lng->txt(
'lucene_or')
209 )->withRequired(
true)
210 ->withValue((
string) $settings->getDefaultOperator());
213 $filter = $settings->getLuceneItemFilter();
216 $checks[$obj] = $field_factory->checkbox(
217 $this->
lng->txt($def[
'trans'])
218 )->withValue(isset($filter[$obj]) && $filter[$obj]);
221 $item_filter = $field_factory->optionalGroup(
223 $this->
lng->txt(
'search_item_filter_form'),
224 $this->lng->txt(
'search_item_filter_form_info')
226 if (!$settings->isLuceneItemFilterEnabled()) {
227 $item_filter = $item_filter->withValue(
null);
231 $cdate = $field_factory->checkbox(
232 $this->
lng->txt(
'search_cdate_filter'),
233 $this->lng->txt(
'search_cdate_filter_info')
234 )->withValue($settings->isDateFilterEnabled());
244 $auto_complete = $field_factory->select(
245 $this->
lng->txt(
'search_auto_complete_length'),
247 )->withRequired(
true)->withValue($settings->getAutoCompleteLength());
250 $inactive_user = $field_factory->checkbox(
251 $this->
lng->txt(
'search_show_inactive_user'),
252 $this->lng->txt(
'search_show_inactive_user_info')
253 )->withValue($settings->isInactiveUserVisible());
256 $limited_user = $field_factory->checkbox(
257 $this->
lng->txt(
'search_show_limited_user'),
258 $this->lng->txt(
'search_show_limited_user_info')
259 )->withValue($settings->isLimitedUserVisible());
264 $section = $this->
factory->input()->field()->section(
267 'search_type' => $type,
268 'operator' => $operator,
269 'filter' => $item_filter,
272 $this->
lng->txt(
'seas_settings')
273 )->withDisabled($read_only);
275 $user_section = $this->
factory->input()->field()->section(
277 'auto_complete_length' => $auto_complete,
278 'inactive_user' => $inactive_user,
279 'limited_user' => $limited_user
281 $this->
lng->txt(
'user_search_settings_section')
282 )->withDisabled($read_only);
285 $action = $this->
ctrl->getFormAction($this,
'permDenied');
287 $action = $this->
ctrl->getFormAction($this,
'update');
290 return $this->
factory->input()->container()->form()->standard(
293 'section' => $section,
294 '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.