ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjSearchSettingsFormGUI Class Reference
+ Collaboration diagram for ilObjSearchSettingsFormGUI:

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

50 {
51 $this->http = $http;
52 $this->ctrl = $ctrl;
53 $this->lng = $lng;
54 $this->tpl = $ui->mainTemplate();
55 $this->factory = $ui->factory();
56 $this->renderer = $ui->renderer();
57 $this->coordinator = $coordinator;
58 $this->readme_helper = $readme_helper;
59 }
renderer()
factory()
renderer()
Get a renderer for UI components.
Definition: UIServices.php:44
mainTemplate()
Get the ILIAS main template.
Definition: UIServices.php:54
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:36
ilObjSearchRpcClientCoordinator $coordinator
static http()
Fetches the global http state from ILIAS.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilObjSearchSettingsFormGUI::executeCommand ( )

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

61 : void
62 {
63 $cmd = $this->ctrl->getCmd();
64
65 switch ($cmd) {
66 case 'readOnly':
67 $this->showForm(true);
68 break;
69
70 case 'edit':
71 $this->showForm(false);
72 break;
73
74 case 'permDenied':
75 $this->showPermissionDenied();
76 break;
77
78 case 'update':
79 $this->update();
80 break;
81
82 default:
84 'Invalid command for ilObjSearchSettingsFormGUI: ' . $cmd
85 );
86 }
87 }
showForm(bool $read_only, bool $get_from_post=false, string $error_message='')

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

+ Here is the call graph for this function:

◆ getSettings()

ilObjSearchSettingsFormGUI::getSettings ( )
protected

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

163 : StandardForm
164 {
165 $settings = $this->getSettings();
166 $field_factory = $this->factory->input()->field();
167
168 // Max hits
169 $values = [];
170 for ($value = 5; $value <= 50; $value += 5) {
171 $values[$value] = $value;
172 }
173 $hits = $field_factory->select(
174 $this->lng->txt('seas_max_hits'),
175 $values,
176 $this->lng->txt('seas_max_hits_info')
177 )->withValue($settings->getMaxHits())
178 ->withRequired(true);
179
180 // Search type
181 $type = $field_factory->radio(
182 $this->lng->txt('seas_search_type')
183 )->withOption(
185 $this->lng->txt('search_direct'),
186 $this->lng->txt('search_like_info')
187 )->withOption(
189 $this->lng->txt('search_lucene'),
190 $this->lng->txt('java_server_info')
191 )->withRequired(true);
192
193 if ($settings->enabledLucene()) {
194 $type = $type->withValue((string) ilSearchSettings::LUCENE_SEARCH);
195 } else {
196 $type = $type->withValue((string) ilSearchSettings::LIKE_SEARCH);
197 }
198
199 // Default operator
200 $operator = $field_factory->radio(
201 $this->lng->txt('lucene_default_operator'),
202 $this->lng->txt('lucene_default_operator_info')
203 )->withOption(
205 $this->lng->txt('lucene_and')
206 )->withOption(
208 $this->lng->txt('lucene_or')
209 )->withRequired(true)
210 ->withValue((string) $settings->getDefaultOperator());
211
212 // Item filter
213 $filter = $settings->getLuceneItemFilter();
214 $checks = [];
215 foreach (ilSearchSettings::getLuceneItemFilterDefinitions() as $obj => $def) {
216 $checks[$obj] = $field_factory->checkbox(
217 $this->lng->txt($def['trans'])
218 )->withValue(isset($filter[$obj]) && $filter[$obj]);
219 }
220
221 $item_filter = $field_factory->optionalGroup(
222 $checks,
223 $this->lng->txt('search_item_filter_form'),
224 $this->lng->txt('search_item_filter_form_info')
225 );
226 if (!$settings->isLuceneItemFilterEnabled()) {
227 $item_filter = $item_filter->withValue(null);
228 }
229
230 // Filter by date
231 $cdate = $field_factory->checkbox(
232 $this->lng->txt('search_cdate_filter'),
233 $this->lng->txt('search_cdate_filter_info')
234 )->withValue($settings->isDateFilterEnabled());
235
236 // number of auto complete entries
237 $options = [
238 0 => 0,
239 5 => 5,
240 10 => 10,
241 20 => 20,
242 30 => 30
243 ];
244 $auto_complete = $field_factory->select(
245 $this->lng->txt('search_auto_complete_length'),
246 $options
247 )->withRequired(true)->withValue($settings->getAutoCompleteLength());
248
249 // Show inactive users
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());
254
255 // Show limited users
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());
260
264 $section = $this->factory->input()->field()->section(
265 [
266 'max_hits' => $hits,
267 'search_type' => $type,
268 'operator' => $operator,
269 'filter' => $item_filter,
270 'cdate' => $cdate
271 ],
272 $this->lng->txt('seas_settings')
273 )->withDisabled($read_only);
274
275 $user_section = $this->factory->input()->field()->section(
276 [
277 'auto_complete_length' => $auto_complete,
278 'inactive_user' => $inactive_user,
279 'limited_user' => $limited_user
280 ],
281 $this->lng->txt('user_search_settings_section')
282 )->withDisabled($read_only);
283
284 if ($read_only) {
285 $action = $this->ctrl->getFormAction($this, 'permDenied');
286 } else {
287 $action = $this->ctrl->getFormAction($this, 'update');
288 }
289
290 return $this->factory->input()->container()->form()->standard(
291 $action,
292 [
293 'section' => $section,
294 'user_section' => $user_section,
295 ]
296 );
297 }
static getLuceneItemFilterDefinitions()
Get lucene item filter definitions.

References ILIAS\Repository\ctrl(), factory(), ilSearchSettings\getLuceneItemFilterDefinitions(), ilSearchSettings\LIKE_SEARCH, ILIAS\Repository\lng(), ilSearchSettings\LUCENE_SEARCH, ilSearchSettings\OPERATOR_AND, and ilSearchSettings\OPERATOR_OR.

+ Here is the call graph for this function:

◆ showForm()

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

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

93 : void {
94 $content = [];
95 if ($error_message !== '') {
96 $content[] = $this->readme_helper->getServerErrorMessageBox($error_message);
97 }
98
99 $form = $this->initForm($read_only);
100 if ($get_from_post) {
101 $form = $form->withRequest($this->http->request());
102 }
103 $content[] = $form;
104
105 $this->tpl->setContent($this->renderer->render($content));
106 }

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ showPermissionDenied()

ilObjSearchSettingsFormGUI::showPermissionDenied ( )
protected

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

157 : void
158 {
159 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
160 $this->ctrl->redirect($this, 'readOnly');
161 }

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 108 of file class.ilObjSearchSettingsFormGUI.php.

108 : void
109 {
110 $form = $this->initForm(false)
111 ->withRequest($this->http->request());
112
113 if (!$form->getData()) {
114 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
115 $this->showForm(false, true);
116 return;
117 }
118
119 $settings = $this->getSettings();
120
121 $main_data = $form->getData()['section'];
122 $user_data = $form->getData()['user_section'];
123
124 $settings->setMaxHits((int) $main_data['max_hits']);
125
126 switch ((int) $main_data['search_type']) {
128 $settings->enableLucene(false);
129 break;
131 $settings->enableLucene(true);
132 break;
133 }
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']);
138 }
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']);
143 $settings->update();
144
145 // refresh lucene server
146 try {
147 if ($settings->enabledLucene()) {
148 $this->coordinator->refreshLuceneSettings();
149 }
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());
154 }
155 }

References ILIAS\Repository\ctrl(), 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 40 of file class.ilObjSearchSettingsFormGUI.php.

Referenced by __construct().

◆ $ctrl

ilCtrlInterface ilObjSearchSettingsFormGUI::$ctrl
protected

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

Referenced by __construct().

◆ $factory

Factory ilObjSearchSettingsFormGUI::$factory
protected

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

◆ $http

GlobalHttpState ilObjSearchSettingsFormGUI::$http
protected

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

Referenced by __construct().

◆ $lng

ilLanguage ilObjSearchSettingsFormGUI::$lng
protected

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

Referenced by __construct().

◆ $readme_helper

ServerReadmeHelper ilObjSearchSettingsFormGUI::$readme_helper
protected

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

Referenced by __construct().

◆ $renderer

Renderer ilObjSearchSettingsFormGUI::$renderer
protected

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

◆ $tpl

ilGlobalTemplateInterface ilObjSearchSettingsFormGUI::$tpl
protected

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


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