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

Public Member Functions

 __construct (GlobalHttpState $http, ilCtrlInterface $ctrl, ilLanguage $lng, UIServices $ui, RefFactory $refinery, ilObjUser $user, ilObjSearchRpcClientCoordinator $coordinator, ServerReadmeHelper $readme_helper)
 
 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
 
RefFactory $refinery
 
ilObjUser $user
 
ilObjSearchRpcClientCoordinator $coordinator
 
ServerReadmeHelper $readme_helper
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjSearchLuceneSettingsFormGUI::__construct ( GlobalHttpState  $http,
ilCtrlInterface  $ctrl,
ilLanguage  $lng,
UIServices  $ui,
RefFactory  $refinery,
ilObjUser  $user,
ilObjSearchRpcClientCoordinator  $coordinator,
ServerReadmeHelper  $readme_helper 
)

Definition at line 46 of file class.ilObjSearchLuceneSettingsFormGUI.php.

55 {
56 $this->http = $http;
57 $this->ctrl = $ctrl;
58 $this->lng = $lng;
59 $this->tpl = $ui->mainTemplate();
60 $this->factory = $ui->factory();
61 $this->renderer = $ui->renderer();
62 $this->refinery = $refinery;
63 $this->user = $user;
64 $this->coordinator = $coordinator;
65 $this->readme_helper = $readme_helper;
66 }
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
static http()
Fetches the global http state from ILIAS.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilObjSearchLuceneSettingsFormGUI::executeCommand ( )

Definition at line 68 of file class.ilObjSearchLuceneSettingsFormGUI.php.

68 : void
69 {
70 $cmd = $this->ctrl->getCmd();
71
72 switch ($cmd) {
73 case 'readOnly':
74 $this->showForm(true);
75 break;
76
77 case 'edit':
78 $this->showForm(false);
79 break;
80
81 case 'permDenied':
82 $this->showPermissionDenied();
83 break;
84
85 case 'update':
86 $this->update();
87 break;
88
89 default:
91 'Invalid command for ilObjSearchLuceneSettingsFormGUI: ' . $cmd
92 );
93 }
94 }
showForm(bool $read_only, bool $get_from_post=false)

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

+ Here is the call graph for this function:

◆ getSettings()

ilObjSearchLuceneSettingsFormGUI::getSettings ( )
protected

Definition at line 271 of file class.ilObjSearchLuceneSettingsFormGUI.php.

References ilSearchSettings\getInstance().

+ Here is the call graph for this function:

◆ initForm()

ilObjSearchLuceneSettingsFormGUI::initForm ( bool  $read_only)
protected

TODO: Split up the form into two or three sections.

Definition at line 156 of file class.ilObjSearchLuceneSettingsFormGUI.php.

156 : StandardForm
157 {
158 $settings = $this->getSettings();
159 $field_factory = $this->factory->input()->field();
160
161 // User search
162 $user_search = $field_factory->checkbox(
163 $this->lng->txt('search_user_search_form'),
164 $this->lng->txt('search_user_search_info_form')
165 )->withValue($settings->isLuceneUserSearchEnabled());
166
167 // Item filter
168 $filter = $settings->getLuceneMimeFilter();
169 $checks = [];
170 foreach (ilSearchSettings::getLuceneMimeFilterDefinitions() as $mime => $def) {
171 $checks[$mime] = $field_factory->checkbox(
172 $this->lng->txt($def['trans'])
173 )->withValue(isset($filter[$mime]) && $filter[$mime]);
174 }
175
176 $item_filter = $field_factory->optionalGroup(
177 $checks,
178 $this->lng->txt('search_mime_filter_form'),
179 $this->lng->txt('search_mime_filter_form_info')
180 );
181 if (!$settings->isLuceneMimeFilterEnabled()) {
182 $item_filter = $item_filter->withValue(null);
183 }
184
185 // Prefix
186 $prefix = $field_factory->checkbox(
187 $this->lng->txt('lucene_prefix_wildcard'),
188 $this->lng->txt('lucene_prefix_wildcard_info')
189 )->withValue($settings->isPrefixWildcardQueryEnabled());
190
191 // Number of fragments
192 $frag_count = $field_factory->numeric(
193 $this->lng->txt('lucene_num_fragments'),
194 $this->lng->txt('lucene_num_frag_info')
195 )->withValue($settings->getFragmentCount())
196 ->withRequired(true)
197 ->withAdditionalTransformation(
198 $this->refinery->int()->isLessThanOrEqual(10)
199 )->withAdditionalTransformation(
200 $this->refinery->int()->isGreaterThanOrEqual(1)
201 );
202
203 // Size of fragments
204 $frag_size = $field_factory->numeric(
205 $this->lng->txt('lucene_size_fragments'),
206 $this->lng->txt('lucene_size_frag_info')
207 )->withValue($settings->getFragmentSize())
208 ->withRequired(true)
209 ->withAdditionalTransformation(
210 $this->refinery->int()->isLessThanOrEqual(1000)
211 )->withAdditionalTransformation(
212 $this->refinery->int()->isGreaterThanOrEqual(10)
213 );
214
215 // Number of sub-items
216 $max_sub = $field_factory->numeric(
217 $this->lng->txt('lucene_max_sub'),
218 $this->lng->txt('lucene_max_sub_info')
219 )->withValue($settings->getMaxSubitems())
220 ->withRequired(true)
221 ->withAdditionalTransformation(
222 $this->refinery->int()->isLessThanOrEqual(10)
223 )->withAdditionalTransformation(
224 $this->refinery->int()->isGreaterThanOrEqual(1)
225 );
226
227 // Last Index
228 $timezone = $this->user->getTimeZone();
229 $datetime = new DateTime(
230 '@' . $settings->getLastIndexTime()->get(IL_CAL_UNIX)
231 );
232 $datetime->setTimezone(new DateTimeZone($timezone));
233 $last_index = $field_factory->dateTime(
234 $this->lng->txt('lucene_last_index_time'),
235 $this->lng->txt('lucene_last_index_time_info')
236 )->withRequired(true)
237 ->withUseTime(true)
238 ->withTimezone($timezone);
239 $last_index = $last_index->withValue(
240 $datetime->format($last_index->getFormat()->toString() . ' H:i')
241 );
242
246 $section = $this->factory->input()->field()->section(
247 [
248 'user_search_enabled' => $user_search,
249 'mime' => $item_filter,
250 'prefix' => $prefix,
251 'fragmentCount' => $frag_count,
252 'fragmentSize' => $frag_size,
253 'maxSubitems' => $max_sub,
254 'last_index' => $last_index
255 ],
256 $this->lng->txt('lucene_settings_title')
257 )->withDisabled($read_only);
258
259 if ($read_only) {
260 $action = $this->ctrl->getFormAction($this, 'permDenied');
261 } else {
262 $action = $this->ctrl->getFormAction($this, 'update');
263 }
264
265 return $this->factory->input()->container()->form()->standard(
266 $action,
267 ['section' => $section]
268 );
269 }
$datetime
const IL_CAL_UNIX
static getLuceneMimeFilterDefinitions()

References $datetime, ILIAS\Repository\ctrl(), factory(), ilSearchSettings\getLuceneMimeFilterDefinitions(), IL_CAL_UNIX, ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ showForm()

ilObjSearchLuceneSettingsFormGUI::showForm ( bool  $read_only,
bool  $get_from_post = false 
)
protected

Definition at line 96 of file class.ilObjSearchLuceneSettingsFormGUI.php.

99 : void {
100 $message = $this->readme_helper->getServerInfoMessageBox();
101 $form = $this->initForm($read_only);
102 if ($get_from_post) {
103 $form = $form->withRequest($this->http->request());
104 }
105 $this->tpl->setContent($this->renderer->render([$message, $form]));
106 }
$message
Definition: xapiexit.php:31

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ showPermissionDenied()

ilObjSearchLuceneSettingsFormGUI::showPermissionDenied ( )
protected

Definition at line 150 of file class.ilObjSearchLuceneSettingsFormGUI.php.

150 : void
151 {
152 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
153 $this->ctrl->redirect($this, 'readOnly');
154 }

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

ilObjSearchLuceneSettingsFormGUI::update ( )
protected

Definition at line 108 of file class.ilObjSearchLuceneSettingsFormGUI.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 $data = $form->getData()['section'];
121
122 $settings->enableLuceneUserSearch((bool) $data['user_search_enabled']);
123 $settings->setFragmentCount((int) $data['fragmentCount']);
124 $settings->setFragmentSize((int) $data['fragmentSize']);
125 $settings->setMaxSubitems((int) $data['maxSubitems']);
126 $settings->enableLuceneMimeFilter(!is_null($data['mime']));
127 if (!is_null($data['mime'])) {
128 $settings->setLuceneMimeFilter((array) $data['mime']);
129 }
130 $settings->enablePrefixWildcardQuery((bool) $data['prefix']);
131 $settings->setLastIndexTime(new ilDateTime(
132 $data['last_index']->getTimestamp(),
134 ));
135 $settings->update();
136
137 // refresh lucene server
138 try {
139 if ($settings->enabledLucene()) {
140 $this->coordinator->refreshLuceneSettings();
141 }
142 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
143 $this->ctrl->redirect($this, 'edit');
144 } catch (Exception $exception) {
145 $this->tpl->setOnScreenMessage('failure', $exception->getMessage());
146 $this->showForm(false);
147 }
148 }
@classDescription Date and time handling

References $data, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), IL_CAL_UNIX, and ILIAS\Repository\lng().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $coordinator

ilObjSearchRpcClientCoordinator ilObjSearchLuceneSettingsFormGUI::$coordinator
protected

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

Referenced by __construct().

◆ $ctrl

ilCtrlInterface ilObjSearchLuceneSettingsFormGUI::$ctrl
protected

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

Referenced by __construct().

◆ $factory

Factory ilObjSearchLuceneSettingsFormGUI::$factory
protected

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

◆ $http

GlobalHttpState ilObjSearchLuceneSettingsFormGUI::$http
protected

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

Referenced by __construct().

◆ $lng

ilLanguage ilObjSearchLuceneSettingsFormGUI::$lng
protected

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

Referenced by __construct().

◆ $readme_helper

ServerReadmeHelper ilObjSearchLuceneSettingsFormGUI::$readme_helper
protected

Definition at line 44 of file class.ilObjSearchLuceneSettingsFormGUI.php.

Referenced by __construct().

◆ $refinery

RefFactory ilObjSearchLuceneSettingsFormGUI::$refinery
protected

Definition at line 40 of file class.ilObjSearchLuceneSettingsFormGUI.php.

Referenced by __construct().

◆ $renderer

Renderer ilObjSearchLuceneSettingsFormGUI::$renderer
protected

Definition at line 39 of file class.ilObjSearchLuceneSettingsFormGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilObjSearchLuceneSettingsFormGUI::$tpl
protected

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

◆ $user

ilObjUser ilObjSearchLuceneSettingsFormGUI::$user
protected

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

Referenced by __construct().


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