ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilObjSearchSettingsFormGUI Class Reference
+ Collaboration diagram for ilObjSearchSettingsFormGUI:

Public Member Functions

 __construct (GlobalHttpState $http, ilCtrlInterface $ctrl, ilLanguage $lng, UIServices $ui, ilObjSearchRpcClientCoordinator $coordinator)
 
 executeCommand ()
 

Protected Member Functions

 showForm (bool $read_only, bool $get_from_post=false)
 
 update ()
 
 showPermissionDenied ()
 
 initForm (bool $read_only)
 
 getSettings ()
 

Protected Attributes

GlobalHttpState $http
 
ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
Factory $factory
 
Renderer $renderer
 
ilObjSearchRpcClientCoordinator $coordinator
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjSearchSettingsFormGUI::__construct ( GlobalHttpState  $http,
ilCtrlInterface  $ctrl,
ilLanguage  $lng,
UIServices  $ui,
ilObjSearchRpcClientCoordinator  $coordinator 
)

Definition at line 41 of file class.ilObjSearchSettingsFormGUI.php.

References $coordinator, $ctrl, $http, $lng, ILIAS\Repository\ctrl(), ILIAS\DI\UIServices\factory(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\DI\UIServices\mainTemplate(), and ILIAS\DI\UIServices\renderer().

47  {
48  $this->http = $http;
49  $this->ctrl = $ctrl;
50  $this->lng = $lng;
51  $this->tpl = $ui->mainTemplate();
52  $this->factory = $ui->factory();
53  $this->renderer = $ui->renderer();
54  $this->coordinator = $coordinator;
55  }
ilObjSearchRpcClientCoordinator $coordinator
static http()
Fetches the global http state from ILIAS.
renderer()
Get a renderer for UI components.
Definition: UIServices.php:43
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:35
mainTemplate()
Get the ILIAS main template.
Definition: UIServices.php:53
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilObjSearchSettingsFormGUI::executeCommand ( )

Definition at line 57 of file class.ilObjSearchSettingsFormGUI.php.

References ILIAS\Repository\ctrl(), showForm(), showPermissionDenied(), and update().

57  : void
58  {
59  $cmd = $this->ctrl->getCmd();
60 
61  switch ($cmd) {
62  case 'readOnly':
63  $this->showForm(true);
64  break;
65 
66  case 'edit':
67  $this->showForm(false);
68  break;
69 
70  case 'permDenied':
71  $this->showPermissionDenied();
72  break;
73 
74  case 'update':
75  $this->update();
76  break;
77 
78  default:
80  'Invalid command for ilObjSearchSettingsFormGUI: ' . $cmd
81  );
82  }
83  }
showForm(bool $read_only, bool $get_from_post=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getSettings()

ilObjSearchSettingsFormGUI::getSettings ( )
protected

Definition at line 297 of file class.ilObjSearchSettingsFormGUI.php.

References ilSearchSettings\getInstance().

Referenced by initForm(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilObjSearchSettingsFormGUI::initForm ( bool  $read_only)
protected

TODO: Split up the form into two or three sections.

Definition at line 153 of file class.ilObjSearchSettingsFormGUI.php.

References ILIAS\Repository\ctrl(), ilSearchSettings\getLuceneItemFilterDefinitions(), getSettings(), ilSearchSettings\LIKE_SEARCH, ILIAS\Repository\lng(), ilSearchSettings\LUCENE_SEARCH, ilSearchSettings\OPERATOR_AND, ilSearchSettings\OPERATOR_OR, and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by showForm(), and update().

153  : StandardForm
154  {
155  $settings = $this->getSettings();
156  $field_factory = $this->factory->input()->field();
157 
158  // Max hits
159  $values = [];
160  for ($value = 5; $value <= 50; $value += 5) {
161  $values[$value] = $value;
162  }
163  $hits = $field_factory->select(
164  $this->lng->txt('seas_max_hits'),
165  $values,
166  $this->lng->txt('seas_max_hits_info')
167  )->withValue($settings->getMaxHits())
168  ->withRequired(true);
169 
170  // Search type
171  $type = $field_factory->radio(
172  $this->lng->txt('search_type')
173  )->withOption(
175  $this->lng->txt('search_direct'),
176  $this->lng->txt('search_like_info')
177  )->withOption(
179  $this->lng->txt('search_lucene'),
180  $this->lng->txt('java_server_info')
181  )->withRequired(true);
182 
183  if ($settings->enabledLucene()) {
184  $type = $type->withValue((string) ilSearchSettings::LUCENE_SEARCH);
185  } else {
186  $type = $type->withValue((string) ilSearchSettings::LIKE_SEARCH);
187  }
188 
189  // Default operator
190  $operator = $field_factory->radio(
191  $this->lng->txt('lucene_default_operator'),
192  $this->lng->txt('lucene_default_operator_info')
193  )->withOption(
195  $this->lng->txt('lucene_and')
196  )->withOption(
198  $this->lng->txt('lucene_or')
199  )->withRequired(true)
200  ->withValue((string) $settings->getDefaultOperator());
201 
202  // Item filter
203  $filter = $settings->getLuceneItemFilter();
204  $checks = [];
205  foreach (ilSearchSettings::getLuceneItemFilterDefinitions() as $obj => $def) {
206  $checks[$obj] = $field_factory->checkbox(
207  $this->lng->txt($def['trans'])
208  )->withValue(isset($filter[$obj]) && $filter[$obj]);
209  }
210 
211  $item_filter = $field_factory->optionalGroup(
212  $checks,
213  $this->lng->txt('search_item_filter_form'),
214  $this->lng->txt('search_item_filter_form_info')
215  );
216  if (!$settings->isLuceneItemFilterEnabled()) {
217  $item_filter = $item_filter->withValue(null);
218  }
219 
220  // Filter by date
221  $cdate = $field_factory->checkbox(
222  $this->lng->txt('search_cdate_filter'),
223  $this->lng->txt('search_cdate_filter_info')
224  )->withValue($settings->isDateFilterEnabled());
225 
226  // hide advanced search
227  $hide_adv = $field_factory->checkbox(
228  $this->lng->txt('search_hide_adv_search')
229  )->withValue($settings->getHideAdvancedSearch());
230 
231  // number of auto complete entries
232  $options = [
233  5 => 5,
234  10 => 10,
235  20 => 20,
236  30 => 30
237  ];
238  $val = ($settings->getAutoCompleteLength() > 0)
239  ? $settings->getAutoCompleteLength()
240  : 10;
241  $auto_complete = $field_factory->select(
242  $this->lng->txt('search_auto_complete_length'),
243  $options
244  )->withValue($val);
245 
246  // Show inactive users
247  $inactive_user = $field_factory->checkbox(
248  $this->lng->txt('search_show_inactive_user'),
249  $this->lng->txt('search_show_inactive_user_info')
250  )->withValue($settings->isInactiveUserVisible());
251 
252  // Show limited users
253  $limited_user = $field_factory->checkbox(
254  $this->lng->txt('search_show_limited_user'),
255  $this->lng->txt('search_show_limited_user_info')
256  )->withValue($settings->isLimitedUserVisible());
257 
261  $section = $this->factory->input()->field()->section(
262  [
263  'max_hits' => $hits,
264  'search_type' => $type,
265  'operator' => $operator,
266  'hide_adv_search' => $hide_adv,
267  'filter' => $item_filter,
268  'cdate' => $cdate
269  ],
270  $this->lng->txt('seas_settings')
271  )->withDisabled($read_only);
272 
273  $user_section = $this->factory->input()->field()->section(
274  [
275  'auto_complete_length' => $auto_complete,
276  'inactive_user' => $inactive_user,
277  'limited_user' => $limited_user
278  ],
279  $this->lng->txt('user_search_settings_section')
280  )->withDisabled($read_only);
281 
282  if ($read_only) {
283  $action = $this->ctrl->getFormAction($this, 'permDenied');
284  } else {
285  $action = $this->ctrl->getFormAction($this, 'update');
286  }
287 
288  return $this->factory->input()->container()->form()->standard(
289  $action,
290  [
291  'section' => $section,
292  'user_section' => $user_section,
293  ]
294  );
295  }
static getLuceneItemFilterDefinitions()
Get lucene item filter definitions.
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:59
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showForm()

ilObjSearchSettingsFormGUI::showForm ( bool  $read_only,
bool  $get_from_post = false 
)
protected

Definition at line 85 of file class.ilObjSearchSettingsFormGUI.php.

References ILIAS\FileDelivery\http(), and initForm().

Referenced by executeCommand(), and update().

88  : void {
89  $form = $this->initForm($read_only);
90  if ($get_from_post) {
91  $form = $form->withRequest($this->http->request());
92  }
93  $this->tpl->setContent($this->renderer->render($form));
94  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showPermissionDenied()

ilObjSearchSettingsFormGUI::showPermissionDenied ( )
protected

Definition at line 147 of file class.ilObjSearchSettingsFormGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by executeCommand().

147  : void
148  {
149  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
150  $this->ctrl->redirect($this, 'readOnly');
151  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilObjSearchSettingsFormGUI::update ( )
protected

Definition at line 96 of file class.ilObjSearchSettingsFormGUI.php.

References ILIAS\Repository\ctrl(), getSettings(), ILIAS\FileDelivery\http(), initForm(), ilSearchSettings\LIKE_SEARCH, ILIAS\Repository\lng(), ilSearchSettings\LUCENE_SEARCH, and showForm().

Referenced by executeCommand().

96  : void
97  {
98  $form = $this->initForm(false)
99  ->withRequest($this->http->request());
100 
101  if (!$form->getData()) {
102  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
103  $this->showForm(false, true);
104  return;
105  }
106 
107  $settings = $this->getSettings();
108 
109  $main_data = $form->getData()['section'];
110  $user_data = $form->getData()['user_section'];
111 
112  $settings->setMaxHits((int) $main_data['max_hits']);
113 
114  switch ((int) $main_data['search_type']) {
116  $settings->enableLucene(false);
117  break;
119  $settings->enableLucene(true);
120  break;
121  }
122  $settings->setDefaultOperator((int) $main_data['operator']);
123  $settings->enableLuceneItemFilter(!is_null($main_data['filter']));
124  if (!is_null($main_data['filter'])) {
125  $settings->setLuceneItemFilter((array) $main_data['filter']);
126  }
127  $settings->setHideAdvancedSearch((bool) $main_data['hide_adv_search']);
128  $settings->enableDateFilter((bool) $main_data['cdate']);
129  $settings->setAutoCompleteLength((int) $user_data['auto_complete_length']);
130  $settings->showInactiveUser((bool) $user_data['inactive_user']);
131  $settings->showLimitedUser((bool) $user_data['limited_user']);
132  $settings->update();
133 
134  // refresh lucene server
135  try {
136  if ($settings->enabledLucene()) {
137  $this->coordinator->refreshLuceneSettings();
138  }
139  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
140  $this->ctrl->redirect($this, 'edit');
141  } catch (Exception $exception) {
142  $this->tpl->setOnScreenMessage('failure', $exception->getMessage());
143  $this->showForm(false);
144  }
145  }
showForm(bool $read_only, bool $get_from_post=false)
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $coordinator

ilObjSearchRpcClientCoordinator ilObjSearchSettingsFormGUI::$coordinator
protected

Definition at line 39 of file class.ilObjSearchSettingsFormGUI.php.

Referenced by __construct().

◆ $ctrl

ilCtrlInterface ilObjSearchSettingsFormGUI::$ctrl
protected

Definition at line 33 of file class.ilObjSearchSettingsFormGUI.php.

Referenced by __construct().

◆ $factory

Factory ilObjSearchSettingsFormGUI::$factory
protected

Definition at line 36 of file class.ilObjSearchSettingsFormGUI.php.

◆ $http

GlobalHttpState ilObjSearchSettingsFormGUI::$http
protected

Definition at line 32 of file class.ilObjSearchSettingsFormGUI.php.

Referenced by __construct().

◆ $lng

ilLanguage ilObjSearchSettingsFormGUI::$lng
protected

Definition at line 34 of file class.ilObjSearchSettingsFormGUI.php.

Referenced by __construct().

◆ $renderer

Renderer ilObjSearchSettingsFormGUI::$renderer
protected

Definition at line 37 of file class.ilObjSearchSettingsFormGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilObjSearchSettingsFormGUI::$tpl
protected

Definition at line 35 of file class.ilObjSearchSettingsFormGUI.php.


The documentation for this class was generated from the following file: