ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
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 305 of file class.ilObjSearchSettingsFormGUI.php.

References ilSearchSettings\getInstance().

+ Here is the call graph for this function:

◆ initForm()

ilObjSearchSettingsFormGUI::initForm ( bool  $read_only)
protected

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

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

References ILIAS\UI\Implementation\Component\Input\Field\$options, 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 158 of file class.ilObjSearchSettingsFormGUI.php.

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

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 $filter_data = $form->getData()['filter_section'];
123 $user_data = $form->getData()['user_section'];
124
125 $settings->setMaxHits((int) $main_data['max_hits']);
126
127 switch ((int) $main_data['search_type']) {
129 $settings->enableLucene(false);
130 break;
132 $settings->enableLucene(true);
133 break;
134 }
135 $settings->setDefaultOperator((int) $main_data['operator']);
136 $settings->enableLuceneItemFilter(!is_null($filter_data['filter']));
137 if (!is_null($filter_data['filter'])) {
138 $settings->setLuceneItemFilter((array) $filter_data['filter']);
139 }
140 $settings->enableDateFilter((bool) $filter_data['cdate']);
141 $settings->setAutoCompleteLength((int) $user_data['auto_complete_length']);
142 $settings->showInactiveUser((bool) $user_data['inactive_user']);
143 $settings->showLimitedUser((bool) $user_data['limited_user']);
144 $settings->update();
145
146 // refresh lucene server
147 try {
148 if ($settings->enabledLucene()) {
149 $this->coordinator->refreshLuceneSettings();
150 }
151 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
152 $this->ctrl->redirect($this, 'edit');
153 } catch (Exception $exception) {
154 $this->showForm(false, false, $exception->getMessage());
155 }
156 }

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: