ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 44 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().

52  {
53  $this->http = $http;
54  $this->ctrl = $ctrl;
55  $this->lng = $lng;
56  $this->tpl = $ui->mainTemplate();
57  $this->factory = $ui->factory();
58  $this->renderer = $ui->renderer();
59  $this->refinery = $refinery;
60  $this->user = $user;
61  $this->coordinator = $coordinator;
62  }
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 64 of file class.ilObjSearchLuceneSettingsFormGUI.php.

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

64  : void
65  {
66  $cmd = $this->ctrl->getCmd();
67 
68  switch ($cmd) {
69  case 'readOnly':
70  $this->showForm(true);
71  break;
72 
73  case 'edit':
74  $this->showForm(false);
75  break;
76 
77  case 'permDenied':
78  $this->showPermissionDenied();
79  break;
80 
81  case 'update':
82  $this->update();
83  break;
84 
85  default:
87  'Invalid command for ilObjSearchLuceneSettingsFormGUI: ' . $cmd
88  );
89  }
90  }
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 276 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 153 of file class.ilObjSearchLuceneSettingsFormGUI.php.

References ILIAS\LTI\ToolProvider\$settings, 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().

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

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

Referenced by executeCommand(), and update().

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

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

Referenced by executeCommand().

147  : void
148  {
149  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
150  $this->ctrl->redirect($this, 'readOnly');
151  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilObjSearchLuceneSettingsFormGUI::update ( )
protected

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

References $data, ILIAS\LTI\ToolProvider\$settings, ilSession\clear(), ILIAS\Repository\ctrl(), getSettings(), ILIAS\FileDelivery\http(), IL_CAL_UNIX, initForm(), ILIAS\Repository\lng(), and showForm().

Referenced by executeCommand().

103  : void
104  {
105  $form = $this->initForm(false)
106  ->withRequest($this->http->request());
107 
108  if (!$form->getData()) {
109  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
110  $this->showForm(false, true);
111  return;
112  }
113 
114  $settings = $this->getSettings();
115  $data = $form->getData()['section'];
116 
117  $settings->setFragmentCount((int) $data['fragmentCount']);
118  $settings->setFragmentSize((int) $data['fragmentSize']);
119  $settings->setMaxSubitems((int) $data['maxSubitems']);
120  $settings->showRelevance((bool) $data['relevance']);
121  $settings->enableLuceneMimeFilter(!is_null($data['mime']));
122  if (!is_null($data['mime'])) {
123  $settings->setLuceneMimeFilter((array) $data['mime']);
124  }
125  $settings->showSubRelevance((bool) ($data['relevance']['subrelevance'] ?? false));
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  ilSession::clear('search_last_class');
140  $this->ctrl->redirect($this, 'edit');
141  } catch (Exception $exception) {
142  $this->tpl->setOnScreenMessage('failure', $exception->getMessage());
143  $this->showForm(false);
144  }
145  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
const IL_CAL_UNIX
static http()
Fetches the global http state from ILIAS.
showForm(bool $read_only, bool $get_from_post=false)
static clear(string $a_var)
+ 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 42 of file class.ilObjSearchLuceneSettingsFormGUI.php.

Referenced by __construct().

◆ $ctrl

ilCtrlInterface ilObjSearchLuceneSettingsFormGUI::$ctrl
protected

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

Referenced by __construct().

◆ $factory

Factory ilObjSearchLuceneSettingsFormGUI::$factory
protected

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

◆ $http

GlobalHttpState ilObjSearchLuceneSettingsFormGUI::$http
protected

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

Referenced by __construct().

◆ $lng

ilLanguage ilObjSearchLuceneSettingsFormGUI::$lng
protected

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

Referenced by __construct().

◆ $refinery

RefFactory ilObjSearchLuceneSettingsFormGUI::$refinery
protected

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

Referenced by __construct().

◆ $renderer

Renderer ilObjSearchLuceneSettingsFormGUI::$renderer
protected

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

◆ $tpl

ilGlobalTemplateInterface ilObjSearchLuceneSettingsFormGUI::$tpl
protected

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

◆ $user

ilObjUser ilObjSearchLuceneSettingsFormGUI::$user
protected

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

Referenced by __construct().


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