ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 40 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().

46  {
47  $this->http = $http;
48  $this->ctrl = $ctrl;
49  $this->lng = $lng;
50  $this->tpl = $ui->mainTemplate();
51  $this->factory = $ui->factory();
52  $this->renderer = $ui->renderer();
53  $this->coordinator = $coordinator;
54  }
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 56 of file class.ilObjSearchSettingsFormGUI.php.

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

56  : void
57  {
58  $cmd = $this->ctrl->getCmd();
59 
60  switch ($cmd) {
61  case 'readOnly':
62  $this->showForm(true);
63  break;
64 
65  case 'edit':
66  $this->showForm(false);
67  break;
68 
69  case 'permDenied':
70  $this->showPermissionDenied();
71  break;
72 
73  case 'update':
74  $this->update();
75  break;
76 
77  default:
79  'Invalid command for ilObjSearchSettingsFormGUI: ' . $cmd
80  );
81  }
82  }
showForm(bool $read_only, bool $get_from_post=false)
+ Here is the call graph for this function:

◆ getSettings()

ilObjSearchSettingsFormGUI::getSettings ( )
protected

Definition at line 296 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  // hide advanced search
226  $hide_adv = $field_factory->checkbox(
227  $this->lng->txt('search_hide_adv_search')
228  )->withValue($settings->getHideAdvancedSearch());
229 
230  // number of auto complete entries
231  $options = [
232  5 => 5,
233  10 => 10,
234  20 => 20,
235  30 => 30
236  ];
237  $val = ($settings->getAutoCompleteLength() > 0)
238  ? $settings->getAutoCompleteLength()
239  : 10;
240  $auto_complete = $field_factory->select(
241  $this->lng->txt('search_auto_complete_length'),
242  $options
243  )->withValue($val);
244 
245  // Show inactive users
246  $inactive_user = $field_factory->checkbox(
247  $this->lng->txt('search_show_inactive_user'),
248  $this->lng->txt('search_show_inactive_user_info')
249  )->withValue($settings->isInactiveUserVisible());
250 
251  // Show limited users
252  $limited_user = $field_factory->checkbox(
253  $this->lng->txt('search_show_limited_user'),
254  $this->lng->txt('search_show_limited_user_info')
255  )->withValue($settings->isLimitedUserVisible());
256 
260  $section = $this->factory->input()->field()->section(
261  [
262  'max_hits' => $hits,
263  'search_type' => $type,
264  'operator' => $operator,
265  'hide_adv_search' => $hide_adv,
266  'filter' => $item_filter,
267  'cdate' => $cdate
268  ],
269  $this->lng->txt('seas_settings')
270  )->withDisabled($read_only);
271 
272  $user_section = $this->factory->input()->field()->section(
273  [
274  'auto_complete_length' => $auto_complete,
275  'inactive_user' => $inactive_user,
276  'limited_user' => $limited_user
277  ],
278  $this->lng->txt('user_search_settings_section')
279  )->withDisabled($read_only);
280 
281  if ($read_only) {
282  $action = $this->ctrl->getFormAction($this, 'permDenied');
283  } else {
284  $action = $this->ctrl->getFormAction($this, 'update');
285  }
286 
287  return $this->factory->input()->container()->form()->standard(
288  $action,
289  [
290  'section' => $section,
291  'user_section' => $user_section,
292  ]
293  );
294  }
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 84 of file class.ilObjSearchSettingsFormGUI.php.

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

Referenced by executeCommand(), and update().

87  : void {
88  $form = $this->initForm($read_only);
89  if ($get_from_post) {
90  $form = $form->withRequest($this->http->request());
91  }
92  $this->tpl->setContent($this->renderer->render($form));
93  }
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 95 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().

95  : void
96  {
97  $form = $this->initForm(false)
98  ->withRequest($this->http->request());
99 
100  if (!$form->getData()) {
101  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
102  $this->showForm(false, true);
103  return;
104  }
105 
106  $settings = $this->getSettings();
107 
108  $main_data = $form->getData()['section'];
109  $user_data = $form->getData()['user_section'];
110 
111  $settings->setMaxHits((int) $main_data['max_hits']);
112 
113  switch ((int) $main_data['search_type']) {
115  $settings->enableLucene(false);
116  break;
118  $settings->enableLucene(true);
119  break;
120  }
121  $settings->setDefaultOperator((int) $main_data['operator']);
122  $settings->enableLuceneItemFilter(!is_null($main_data['filter']));
123  if (!is_null($main_data['filter'])) {
124  $settings->setLuceneItemFilter((array) $main_data['filter']);
125  }
126  $settings->setHideAdvancedSearch((bool) $main_data['hide_adv_search']);
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 38 of file class.ilObjSearchSettingsFormGUI.php.

Referenced by __construct().

◆ $ctrl

ilCtrlInterface ilObjSearchSettingsFormGUI::$ctrl
protected

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

Referenced by __construct().

◆ $factory

Factory ilObjSearchSettingsFormGUI::$factory
protected

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

◆ $http

GlobalHttpState ilObjSearchSettingsFormGUI::$http
protected

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

Referenced by __construct().

◆ $lng

ilLanguage ilObjSearchSettingsFormGUI::$lng
protected

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

Referenced by __construct().

◆ $renderer

Renderer ilObjSearchSettingsFormGUI::$renderer
protected

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

◆ $tpl

ilGlobalTemplateInterface ilObjSearchSettingsFormGUI::$tpl
protected

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


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