ILIAS  release_8 Revision v8.24
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.

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 }
renderer()
Get a renderer for UI components.
Definition: UIServices.php:43
mainTemplate()
Get the ILIAS main template.
Definition: UIServices.php:53
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:35
ilObjSearchRpcClientCoordinator $coordinator
static http()
Fetches the global http state from ILIAS.

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().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilObjSearchSettingsFormGUI::executeCommand ( )

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

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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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

+ Here is the call graph for this function:

◆ getSettings()

ilObjSearchSettingsFormGUI::getSettings ( )
protected

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

References ilSearchSettings\getInstance().

+ Here is the call 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.

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 // User search
202 $user_search = $field_factory->checkbox(
203 $this->lng->txt('search_user_search_form'),
204 $this->lng->txt('search_user_search_info_form')
205 )->withValue($settings->isLuceneUserSearchEnabled());
206
207 // Item filter
208 $filter = $settings->getLuceneItemFilter();
209 $checks = [];
210 foreach (ilSearchSettings::getLuceneItemFilterDefinitions() as $obj => $def) {
211 $checks[$obj] = $field_factory->checkbox(
212 $this->lng->txt($def['trans'])
213 )->withValue(isset($filter[$obj]) && $filter[$obj]);
214 }
215
216 $item_filter = $field_factory->optionalGroup(
217 $checks,
218 $this->lng->txt('search_item_filter_form'),
219 $this->lng->txt('search_item_filter_form_info')
220 );
221 if (!$settings->isLuceneItemFilterEnabled()) {
222 $item_filter = $item_filter->withValue(null);
223 }
224
225 // Filter by date
226 $cdate = $field_factory->checkbox(
227 $this->lng->txt('search_cdate_filter'),
228 $this->lng->txt('search_cdate_filter_info')
229 )->withValue($settings->isDateFilterEnabled());
230
231 // hide advanced search
232 $hide_adv = $field_factory->checkbox(
233 $this->lng->txt('search_hide_adv_search')
234 )->withValue($settings->getHideAdvancedSearch());
235
236 // number of auto complete entries
237 $options = [
238 5 => 5,
239 10 => 10,
240 20 => 20,
241 30 => 30
242 ];
243 $val = ($settings->getAutoCompleteLength() > 0)
244 ? $settings->getAutoCompleteLength()
245 : 10;
246 $auto_complete = $field_factory->select(
247 $this->lng->txt('search_auto_complete_length'),
248 $options
249 )->withValue($val);
250
251 // Show inactive users
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());
256
257 // Show limited users
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());
262
266 $section = $this->factory->input()->field()->section(
267 [
268 'max_hits' => $hits,
269 'search_type' => $type,
270 'operator' => $operator,
271 'user_search_enabled' => $user_search,
272 'filter' => $item_filter,
273 'cdate' => $cdate,
274 'hide_adv_search' => $hide_adv,
275 'auto_complete_length' => $auto_complete,
276 'inactive_user' => $inactive_user,
277 'limited_user' => $limited_user
278 ],
279 $this->lng->txt('seas_settings')
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 ['section' => $section]
291 );
292 }
static getLuceneItemFilterDefinitions()
Get lucene item filter definitions.
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:59
$type

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

+ Here is the call 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.

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 }

References ILIAS\FileDelivery\http().

Referenced by executeCommand().

+ 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.

146 : void
147 {
148 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
149 $this->ctrl->redirect($this, 'readOnly');
150 }

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

Referenced by executeCommand().

+ 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.

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 $data = $form->getData()['section'];
108
109 $settings->setMaxHits((int) $data['max_hits']);
110
111 switch ((int) $data['search_type']) {
113 $settings->enableLucene(false);
114 break;
116 $settings->enableLucene(true);
117 break;
118 }
119 $settings->setDefaultOperator((int) $data['operator']);
120 $settings->enableLuceneItemFilter(!is_null($data['filter']));
121 if (!is_null($data['filter'])) {
122 $settings->setLuceneItemFilter((array) $data['filter']);
123 }
124 $settings->setHideAdvancedSearch((bool) $data['hide_adv_search']);
125 $settings->setAutoCompleteLength((int) $data['auto_complete_length']);
126 $settings->showInactiveUser((bool) $data['inactive_user']);
127 $settings->showLimitedUser((bool) $data['limited_user']);
128 $settings->enableDateFilter((bool) $data['cdate']);
129 $settings->enableLuceneUserSearch((bool) $data['user_search_enabled']);
130 $settings->update();
131
132 // refresh lucene server
133 try {
134 if ($settings->enabledLucene()) {
135 $this->coordinator->refreshLuceneSettings();
136 }
137 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
138 ilSession::clear('search_last_class');
139 $this->ctrl->redirect($this, 'edit');
140 } catch (Exception $exception) {
141 $this->tpl->setOnScreenMessage('failure', $exception->getMessage());
142 $this->showForm(false);
143 }
144 }
static clear(string $a_var)

References $data, ILIAS\LTI\ToolProvider\$settings, ilSession\clear(), ILIAS\Repository\ctrl(), ILIAS\LTI\ToolProvider\getSettings(), ILIAS\FileDelivery\http(), ilSearchSettings\LIKE_SEARCH, ILIAS\Repository\lng(), and ilSearchSettings\LUCENE_SEARCH.

Referenced by executeCommand().

+ 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: