ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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)
 
 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
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

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

53  {
54  $this->http = $http;
55  $this->ctrl = $ctrl;
56  $this->lng = $lng;
57  $this->tpl = $ui->mainTemplate();
58  $this->factory = $ui->factory();
59  $this->renderer = $ui->renderer();
60  $this->refinery = $refinery;
61  $this->user = $user;
62  $this->coordinator = $coordinator;
63  }
static http()
Fetches the global http state from ILIAS.
renderer()
Get a renderer for UI components.
Definition: UIServices.php:43
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:35
mainTemplate()
Get the ILIAS main template.
Definition: UIServices.php:53
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilObjSearchLuceneSettingsFormGUI::executeCommand ( )

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

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

65  : void
66  {
67  $cmd = $this->ctrl->getCmd();
68 
69  switch ($cmd) {
70  case 'readOnly':
71  $this->showForm(true);
72  break;
73 
74  case 'edit':
75  $this->showForm(false);
76  break;
77 
78  case 'permDenied':
79  $this->showPermissionDenied();
80  break;
81 
82  case 'update':
83  $this->update();
84  break;
85 
86  default:
88  'Invalid command for ilObjSearchLuceneSettingsFormGUI: ' . $cmd
89  );
90  }
91  }
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...
+ Here is the call graph for this function:

◆ getSettings()

ilObjSearchLuceneSettingsFormGUI::getSettings ( )
protected

Definition at line 267 of file class.ilObjSearchLuceneSettingsFormGUI.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()

ilObjSearchLuceneSettingsFormGUI::initForm ( bool  $read_only)
protected

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

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

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

◆ showForm()

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

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

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

Referenced by executeCommand(), and update().

96  : void {
97  $form = $this->initForm($read_only);
98  if ($get_from_post) {
99  $form = $form->withRequest($this->http->request());
100  }
101  $this->tpl->setContent($this->renderer->render($form));
102  }
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()

ilObjSearchLuceneSettingsFormGUI::showPermissionDenied ( )
protected

Definition at line 146 of file class.ilObjSearchLuceneSettingsFormGUI.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()

ilObjSearchLuceneSettingsFormGUI::update ( )
protected

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

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

Referenced by executeCommand().

104  : void
105  {
106  $form = $this->initForm(false)
107  ->withRequest($this->http->request());
108 
109  if (!$form->getData()) {
110  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
111  $this->showForm(false, true);
112  return;
113  }
114 
115  $settings = $this->getSettings();
116  $data = $form->getData()['section'];
117 
118  $settings->enableLuceneUserSearch((bool) $data['user_search_enabled']);
119  $settings->setFragmentCount((int) $data['fragmentCount']);
120  $settings->setFragmentSize((int) $data['fragmentSize']);
121  $settings->setMaxSubitems((int) $data['maxSubitems']);
122  $settings->enableLuceneMimeFilter(!is_null($data['mime']));
123  if (!is_null($data['mime'])) {
124  $settings->setLuceneMimeFilter((array) $data['mime']);
125  }
126  $settings->enablePrefixWildcardQuery((bool) $data['prefix']);
127  $settings->setLastIndexTime(new ilDateTime(
128  $data['last_index']->getTimestamp(),
130  ));
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  }
const IL_CAL_UNIX
static http()
Fetches the global http state from ILIAS.
showForm(bool $read_only, bool $get_from_post=false)
+ 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().

◆ $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: