ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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(), factory(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\DI\UIServices\mainTemplate(), ILIAS\DI\UIServices\renderer(), and 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
factory()
renderer()
static http()
Fetches the global http state from ILIAS.
renderer()
Get a renderer for UI components.
Definition: UIServices.php:44
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:36
mainTemplate()
Get the ILIAS main template.
Definition: UIServices.php:54
+ 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)
+ Here is the call graph for this function:

◆ getSettings()

ilObjSearchSettingsFormGUI::getSettings ( )
protected

Definition at line 290 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 152 of file class.ilObjSearchSettingsFormGUI.php.

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

Referenced by showForm(), and update().

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

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  }
renderer()
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 146 of file class.ilObjSearchSettingsFormGUI.php.

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

Referenced by executeCommand().

146  : void
147  {
148  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
149  $this->ctrl->redirect($this, 'readOnly');
150  }
+ 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->enableDateFilter((bool) $main_data['cdate']);
128  $settings->setAutoCompleteLength((int) $user_data['auto_complete_length']);
129  $settings->showInactiveUser((bool) $user_data['inactive_user']);
130  $settings->showLimitedUser((bool) $user_data['limited_user']);
131  $settings->update();
132 
133  // refresh lucene server
134  try {
135  if ($settings->enabledLucene()) {
136  $this->coordinator->refreshLuceneSettings();
137  }
138  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
139  $this->ctrl->redirect($this, 'edit');
140  } catch (Exception $exception) {
141  $this->tpl->setOnScreenMessage('failure', $exception->getMessage());
142  $this->showForm(false);
143  }
144  }
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: