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

Public Member Functions

 __construct (Pons $pons,)
 
 getTokensToKeep ()
 
 getCurrentItem ()
 
 create ()
 
 update ()
 
 executeCommand ()
 
- Public Member Functions inherited from ILIAS\GlobalScreen\GUI\AbstractPonsGUI
 __construct (protected Pons $pons)
 
 __construct (Pons $pons)
 
 executeCommand ()
 
 getTokensToKeep ()
 
 getCurrentItem ()
 

Data Fields

const CMD_TOGGLE_ACTIVATION = 'toggleActivation'
 
const CMD_ADD = 'add'
 
const CMD_CREATE = 'create'
 
const CMD_EDIT = 'edit'
 
const CMD_UPDATE = 'update'
 
const CMD_RESET = 'reset'
 
const CMD_SAVE_ORDER = 'saveOrder'
 
const GSFO_ID = 'gsfo_group_id'
 
const CMD_CONFIRM_RESET = 'confirmReset'
 
const CMD_CONFIRM_DELETE = 'confirmDelete'
 
const CMD_DELETE = 'delete'
 
- Data Fields inherited from ILIAS\GlobalScreen\GUI\PonsGUI
const CMD_DEFAULT = 'index'
 

Private Member Functions

 addButtons ()
 
 index ()
 
 confirmReset ()
 
 toggleActivation ()
 
 confirmDelete ()
 
 delete ()
 
 add ()
 
 edit ()
 
 reset ()
 
 saveOrder ()
 

Private Attributes

GroupsRepository $repository
 
Factory $ui_factory
 
ilCtrlInterface $ctrl
 
ServerRequestInterface $request
 
Container $dic
 
TokenContainer $group_token
 
Translator $translator
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

@ilCtrl_isCalledBy ilFooterGroupsGUI: ilObjFooterAdministrationGUI @ilCtrl_Calls ilFooterGroupsGUI: ilPermissionGUI @ilCtrl_Calls ilFooterGroupsGUI: ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI

Definition at line 47 of file class.ilFooterGroupsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilFooterGroupsGUI::__construct ( Pons  $pons)

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Definition at line 112 of file class.ilFooterGroupsGUI.php.

114 {
115 parent::__construct($pons);
116 global $DIC;
117 $this->dic = $DIC;
118 $this->translator = $pons->i18n();
119 $this->ui_factory = $this->dic->ui()->factory();
120 $this->repository = new GroupsRepositoryDB(
121 $this->dic->database(),
122 new ilFooterCustomGroupsProvider($this->dic)
123 );
124 $this->group_token = $this->pons->in()->buildToken('group', 'id');
125 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\GlobalScreen\GUI\Pons\i18n(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilFooterGroupsGUI::add ( )
private

Definition at line 346 of file class.ilFooterGroupsGUI.php.

346 : void
347 {
348 $form = new GroupForm(
349 $this->repository,
350 $this->translator
351 );
352
353 $action = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
354
355 $this->pons->out()->outAsyncAsModal(
356 $this->translator->translate('group_add'),
357 $action,
358 $form->get($action)
359 );
360 }

References ILIAS\UI\examples\Deck\repository().

Referenced by executeCommand().

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

◆ addButtons()

ilFooterGroupsGUI::addButtons ( )
private

Definition at line 141 of file class.ilFooterGroupsGUI.php.

141 : array
142 {
143 $modal = $this->ui_factory
144 ->modal()
145 ->roundtrip(
146 $this->translator->translate('group_add'),
147 null
148 )
149 ->withAsyncRenderUrl(
150 (string) $this->pons->flow()->getHereAsURI(self::CMD_ADD)
151 );
152
153 $confirm_reset = $this->ui_factory
154 ->prompt()
155 ->standard(
156 $this->pons->flow()->getHereAsURI(self::CMD_CONFIRM_RESET),
157 );
158
159 $this->dic
160 ->toolbar()
161 ->addComponent(
162 $this->ui_factory
163 ->button()
164 ->primary(
165 $this->translator->translate('group_add'),
166 '#'
167 )
168 ->withOnClick($modal->getShowSignal())
169 ->withHelpTopics(
170 ...$this->ui_factory->helpTopics('gsfo_button_add')
171 )
172 );
173 $this->dic
174 ->toolbar()
175 ->addComponent(
176 $this->ui_factory
177 ->button()
178 ->standard(
179 $this->translator->translate('reset_footer'),
180 '#'
181 )
182 ->withOnClick($confirm_reset->getShowSignal())
183 ->withHelpTopics(
184 ...$this->ui_factory->helpTopics('gsfo_button_reset')
185 )
186 );
187
188 return [$modal, $confirm_reset];
189 }
button(string $caption, string $cmd)

References ILIAS\Repository\button(), and ILIAS\UI\examples\MainControls\Slate\Notification\standard().

Referenced by index().

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

◆ confirmDelete()

ilFooterGroupsGUI::confirmDelete ( )
private

Definition at line 261 of file class.ilFooterGroupsGUI.php.

261 : void
262 {
263 $items = [];
264
265 $nok = $this->pons->out()->nok();
266 $ok = $this->pons->out()->ok();
267
268 $from_request = $this->pons->in()->getAllFromRequest($this->group_token);
269
270 if (($from_request[0] ?? null) === Input::ALL_OBJECTS) {
271 $from_request = array_map(
272 fn(TranslatableItem $item): string => $item->getId(),
273 iterator_to_array($this->repository->all())
274 );
275 }
276
277 foreach ($from_request as $id) {
278 $group = $this->repository->get($id);
279 $id = $this->hash($id);
280 if ($group === null) {
281 continue;
282 }
283 if ($group->isCore()) {
284 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
285 $id,
286 $group->getTitle(),
287 $this->translator->translate('info_not_deletable_core') .
288 $this->pons->out()->ui()->renderer()->render(
289 $nok
290 )
291 );
292 continue;
293 }
294 if ($group->getItems() > 0) {
295 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
296 $id,
297 $group->getTitle(),
298 $this->translator->translate('info_not_deletable_not_empty') .
299 $this->pons->out()->ui()->renderer()->render($nok)
300 );
301 continue;
302 }
303
304 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
305 $id,
306 $group->getTitle(),
307 $this->pons->out()->ui()->renderer()->render($ok)
308 );
309 }
310
311 $this->pons->out()->outAsyncAsModal(
312 $this->pons->i18n()->translate('group_delete'),
313 (string) $this->pons->flow()->getHereAsURI(self::CMD_DELETE),
314 ...$items
315 );
316 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslatableItem\getId(), and ILIAS\UI\examples\Deck\repository().

Referenced by executeCommand().

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

◆ confirmReset()

ilFooterGroupsGUI::confirmReset ( )
private

Definition at line 218 of file class.ilFooterGroupsGUI.php.

218 : void
219 {
220 $this->pons->out()->outAsync(
221 $this->ui_factory->prompt()->state()->show(
222 $this->ui_factory->messageBox()->confirmation(
223 $this->translator->translate('confirm_reset')
224 )->withButtons(
225 [
226 $this->ui_factory->button()->standard(
227 $this->translator->translate('reset'),
228 (string) $this->pons->flow()->getHereAsURI(self::CMD_RESET)
229 )
230 ]
231 )
232 )
233 );
234 }

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ create()

ilFooterGroupsGUI::create ( )

Definition at line 363 of file class.ilFooterGroupsGUI.php.

363 : void
364 {
365 $form = new GroupForm(
366 $this->repository,
367 $this->translator
368 );
369 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
370 if ($form->store(
371 $this->pons->in()->request(),
372 $target
373 )) {
374 $this->pons->flow()->redirect(self::CMD_DEFAULT);
375 }
376 $this->pons->out()->out(
377 $form->get(
378 $target
379 )
380 );
381 }

References ILIAS\UI\examples\Deck\repository().

Referenced by executeCommand().

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

◆ delete()

ilFooterGroupsGUI::delete ( )
private

Definition at line 319 of file class.ilFooterGroupsGUI.php.

319 : void
320 {
321 $from_request = $this->pons->in()->getAllFromRequest($this->group_token);
322
323 if (($from_request[0] ?? null) === Input::ALL_OBJECTS) {
324 $from_request = array_map(
325 fn(TranslatableItem $item): string => $item->getId(),
326 iterator_to_array($this->repository->all())
327 );
328 }
329
330 foreach ($from_request as $id) {
331 $group = $this->repository->get($id);
332 if ($group === null) {
333 continue;
334 }
335 if ($group->isCore()) {
336 continue;
337 }
338 $this->repository->delete($group);
339 }
340
341 $this->pons->out()->success($this->translator->translate('group_deleted'));
342 $this->pons->flow()->redirect(self::CMD_DEFAULT);
343 }

References $id, ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslatableItem\getId(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ edit()

ilFooterGroupsGUI::edit ( )
private

Definition at line 384 of file class.ilFooterGroupsGUI.php.

384 : void
385 {
386 $id = $this->pons->in()->getFirstFromRequest($this->group_token);
387 $this->pons->in()->keepTokens($this);
388
389 $group = $this->repository->get($id);
390
391 $form = new GroupForm(
392 $this->repository,
393 $this->translator,
394 $group
395 );
396
397 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_UPDATE);
398 $this->pons->out()->outAsyncAsModal(
399 $this->translator->translate('group_edit'),
400 $target,
401 $form->get($target)
402 );
403 }

References $id, and ILIAS\UI\examples\Deck\repository().

Referenced by executeCommand().

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

◆ executeCommand()

ilFooterGroupsGUI::executeCommand ( )
Returns
bool true if you handled this command aka you were the CtrlClass, otherwise false

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Definition at line 460 of file class.ilFooterGroupsGUI.php.

460 : bool
461 {
462 if ($this->pons->handle(ilObjFooterAdministrationGUI::TAB_GROUPS)) {
463 return true;
464 }
465 match ($this->pons->flow()->getCommand(self::CMD_DEFAULT)) {
466 self::CMD_DEFAULT => $this->index(),
467 self::CMD_ADD => $this->add(),
468 self::CMD_CREATE => $this->create(),
469 self::CMD_EDIT => $this->edit(),
470 self::CMD_UPDATE => $this->update(),
471 self::CMD_CONFIRM_RESET => $this->confirmReset(),
472 self::CMD_CONFIRM_DELETE => $this->confirmDelete(),
473 self::CMD_DELETE => $this->delete(),
474 self::CMD_TOGGLE_ACTIVATION => $this->toggleActivation(),
475 self::CMD_RESET => $this->reset(),
476 self::CMD_SAVE_ORDER => $this->saveOrder(),
477 default => $this->pons->out()->outString(
478 'Unknown command: ' . $this->pons->flow()->getCommand(self::CMD_DEFAULT)
479 ),
480 };
481 return true;
482 }

References add(), confirmDelete(), confirmReset(), create(), edit(), index(), reset(), saveOrder(), ilObjFooterAdministrationGUI\TAB_GROUPS, toggleActivation(), and update().

+ Here is the call graph for this function:

◆ getCurrentItem()

ilFooterGroupsGUI::getCurrentItem ( )

Implements ILIAS\GlobalScreen\GUI\I18n\SupportsTranslationGUI.

Definition at line 134 of file class.ilFooterGroupsGUI.php.

135 {
136 return $this->repository->get(
137 $this->pons->in()->getFirstFromRequest($this->group_token)
138 );
139 }

References ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ getTokensToKeep()

ilFooterGroupsGUI::getTokensToKeep ( )

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Definition at line 127 of file class.ilFooterGroupsGUI.php.

127 : array
128 {
129 return [
130 $this->group_token->token(),
131 ];
132 }

◆ index()

ilFooterGroupsGUI::index ( )
private

Definition at line 192 of file class.ilFooterGroupsGUI.php.

192 : void
193 {
194 // Add new
195 $components = [];
196 if ($this->pons->access()->hasUserPermissionTo('write')) {
197 $components = $this->addButtons();
198 }
199 // Sync
200 $this->repository->syncWithGlobalScreen(
201 $this->dic->globalScreen()->collector()->footer()
202 );
203
204 // Table
205 $table = new GroupsTable(
206 $this->pons,
207 $this->repository,
208 $this->group_token
209 );
210
211 $this->pons->out()->out(
212 $table->get(),
213 ...$components
214 );
215 }
$components

References $components, addButtons(), and ILIAS\UI\examples\Deck\repository().

Referenced by executeCommand().

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

◆ reset()

ilFooterGroupsGUI::reset ( )
private

Definition at line 433 of file class.ilFooterGroupsGUI.php.

433 : never
434 {
435 $this->repository->reset(
436 $this->dic->globalScreen()->collector()->footer()
437 );
438 $entries_repo = new EntriesRepositoryDB($this->dic->database(), new ilFooterCustomGroupsProvider($this->dic));
439 $entries_repo->reset($this->dic->globalScreen()->collector()->footer());
440
441 $translations = new TranslationsRepositoryDB($this->dic->database());
442 $translations->reset();
443
444 $this->pons->out()->success($this->translator->translate('reset_success'));
445 $this->pons->flow()->redirect(self::CMD_DEFAULT);
446 }

References ILIAS\UI\examples\Deck\repository().

Referenced by executeCommand().

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

◆ saveOrder()

ilFooterGroupsGUI::saveOrder ( )
private

Definition at line 449 of file class.ilFooterGroupsGUI.php.

449 : void
450 {
451 foreach ($this->pons->in()->request()->getParsedBody() as $hashed_id => $position) {
452 $item = $this->repository->get($this->unhash($hashed_id));
453 $item = $item->withPosition((int) $position);
454 $this->repository->store($item);
455 }
456 $this->pons->out()->success($this->pons->i18n()->translate('order_saved'));
457 $this->pons->flow()->redirect(self::CMD_DEFAULT);
458 }

References ILIAS\UI\examples\Deck\repository().

Referenced by executeCommand().

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

◆ toggleActivation()

ilFooterGroupsGUI::toggleActivation ( )
private

Definition at line 237 of file class.ilFooterGroupsGUI.php.

237 : void
238 {
239 $from_request = $this->pons->in()->getAllFromRequest($this->group_token);
240
241 if (($from_request[0] ?? null) === Input::ALL_OBJECTS) {
242 $from_request = array_map(
243 fn(TranslatableItem $item): string => $item->getId(),
244 iterator_to_array($this->repository->all())
245 );
246 }
247
248 foreach ($from_request as $id) {
249 $group = $this->repository->get($id);
250 if ($group === null) {
251 continue;
252 }
253 $this->repository->store($group->withActive(!$group->isActive()));
254 }
255
256 $this->pons->out()->success($this->translator->translate('group_activation_toggled'));
257 $this->pons->flow()->redirect(self::CMD_DEFAULT);
258 }

References $id, ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslatableItem\getId(), and ILIAS\UI\examples\Deck\repository().

Referenced by executeCommand().

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

◆ update()

ilFooterGroupsGUI::update ( )

Definition at line 406 of file class.ilFooterGroupsGUI.php.

406 : void
407 {
408 $id = $this->pons->in()->getFirstFromRequest($this->group_token);
409
410 $group = $this->repository->get($id);
411
412 $form = new GroupForm(
413 $this->repository,
414 $this->translator,
415 $group
416 );
417
418 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_EDIT);
419 if ($form->store(
420 $this->pons->in()->request(),
421 $target
422 )) {
423 $this->pons->flow()->redirect(self::CMD_DEFAULT);
424 }
425 $this->pons->out()->out(
426 $form->get(
427 $target
428 )
429 );
430 }

References $id, and ILIAS\UI\examples\Deck\repository().

Referenced by executeCommand().

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

Field Documentation

◆ $ctrl

ilCtrlInterface ilFooterGroupsGUI::$ctrl
private

Definition at line 105 of file class.ilFooterGroupsGUI.php.

◆ $dic

Container ilFooterGroupsGUI::$dic
private

Definition at line 108 of file class.ilFooterGroupsGUI.php.

◆ $group_token

TokenContainer ilFooterGroupsGUI::$group_token
private

Definition at line 109 of file class.ilFooterGroupsGUI.php.

◆ $repository

GroupsRepository ilFooterGroupsGUI::$repository
private

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

◆ $request

ServerRequestInterface ilFooterGroupsGUI::$request
private

Definition at line 106 of file class.ilFooterGroupsGUI.php.

◆ $translator

Translator ilFooterGroupsGUI::$translator
private

Definition at line 110 of file class.ilFooterGroupsGUI.php.

◆ $ui_factory

Factory ilFooterGroupsGUI::$ui_factory
private

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

◆ CMD_ADD

const ilFooterGroupsGUI::CMD_ADD = 'add'

Definition at line 59 of file class.ilFooterGroupsGUI.php.

◆ CMD_CONFIRM_DELETE

const ilFooterGroupsGUI::CMD_CONFIRM_DELETE = 'confirmDelete'

◆ CMD_CONFIRM_RESET

const ilFooterGroupsGUI::CMD_CONFIRM_RESET = 'confirmReset'

Definition at line 94 of file class.ilFooterGroupsGUI.php.

◆ CMD_CREATE

const ilFooterGroupsGUI::CMD_CREATE = 'create'

Definition at line 64 of file class.ilFooterGroupsGUI.php.

◆ CMD_DELETE

const ilFooterGroupsGUI::CMD_DELETE = 'delete'

Definition at line 102 of file class.ilFooterGroupsGUI.php.

◆ CMD_EDIT

const ilFooterGroupsGUI::CMD_EDIT = 'edit'

◆ CMD_RESET

const ilFooterGroupsGUI::CMD_RESET = 'reset'

Definition at line 79 of file class.ilFooterGroupsGUI.php.

◆ CMD_SAVE_ORDER

const ilFooterGroupsGUI::CMD_SAVE_ORDER = 'saveOrder'

◆ CMD_TOGGLE_ACTIVATION

const ilFooterGroupsGUI::CMD_TOGGLE_ACTIVATION = 'toggleActivation'

◆ CMD_UPDATE

const ilFooterGroupsGUI::CMD_UPDATE = 'update'

Definition at line 74 of file class.ilFooterGroupsGUI.php.

◆ GSFO_ID

const ilFooterGroupsGUI::GSFO_ID = 'gsfo_group_id'

Definition at line 89 of file class.ilFooterGroupsGUI.php.


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