ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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(), factory(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\DI\UIServices\mainTemplate(), ILIAS\Repository\refinery(), ILIAS\DI\UIServices\renderer(), 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  }
factory()
renderer()
static http()
Fetches the global http state from ILIAS.
renderer()
Get a renderer for UI components.
Definition: UIServices.php:44
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:36
mainTemplate()
Get the ILIAS main template.
Definition: UIServices.php:54
+ 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)
+ Here is the call graph for this function:

◆ getSettings()

ilObjSearchLuceneSettingsFormGUI::getSettings ( )
protected

Definition at line 266 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 151 of file class.ilObjSearchLuceneSettingsFormGUI.php.

References $datetime, ILIAS\Repository\ctrl(), factory(), ilSearchSettings\getLuceneMimeFilterDefinitions(), getSettings(), IL_CAL_UNIX, ILIAS\Repository\lng(), null, 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().

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

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  }
renderer()
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 145 of file class.ilObjSearchLuceneSettingsFormGUI.php.

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

Referenced by executeCommand().

145  : void
146  {
147  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
148  $this->ctrl->redirect($this, 'readOnly');
149  }
+ 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\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->enableLuceneUserSearch((bool) $data['user_search_enabled']);
118  $settings->setFragmentCount((int) $data['fragmentCount']);
119  $settings->setFragmentSize((int) $data['fragmentSize']);
120  $settings->setMaxSubitems((int) $data['maxSubitems']);
121  $settings->enableLuceneMimeFilter(!is_null($data['mime']));
122  if (!is_null($data['mime'])) {
123  $settings->setLuceneMimeFilter((array) $data['mime']);
124  }
125  $settings->enablePrefixWildcardQuery((bool) $data['prefix']);
126  $settings->setLastIndexTime(new ilDateTime(
127  $data['last_index']->getTimestamp(),
129  ));
130  $settings->update();
131 
132  // refresh lucene server
133  try {
134  if ($settings->enabledLucene()) {
135  $this->coordinator->refreshLuceneSettings();
136  }
137  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
138  $this->ctrl->redirect($this, 'edit');
139  } catch (Exception $exception) {
140  $this->tpl->setOnScreenMessage('failure', $exception->getMessage());
141  $this->showForm(false);
142  }
143  }
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 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: