ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilFooterEntriesGUI Class Reference
+ Inheritance diagram for ilFooterEntriesGUI:
+ Collaboration diagram for ilFooterEntriesGUI:

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_DEFAULT = 'index'
 
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 CMD_CONFIRM_DELETE = 'confirmDelete'
 
const CMD_DELETE = 'delete'
 
const GSFO_ID = 'gsfo_entry_id'
 
const CMD_TOGGLE_ACTIVATION = 'toggleActivation'
 
const string CMD_SELECT_MOVE = 'selectMove'
 
const string CMD_MOVE = 'move'
 
- Data Fields inherited from ILIAS\GlobalScreen\GUI\PonsGUI
const CMD_DEFAULT = 'index'
 

Private Member Functions

 index ()
 
 add ()
 
 addButtons ()
 
 saveCurrentEntry ()
 
 edit ()
 
 toggleActivation ()
 
 confirmDelete ()
 
 delete ()
 
 saveOrder ()
 
 buildTargetSelectorForm (URI $post_url)
 
 selectMove ()
 

Private Attributes

EntriesRepository $repository
 
Factory $ui_factory
 
ilCtrlInterface $ctrl
 
ServerRequestInterface $request
 
Translator $translator
 
Container $dic
 
TokenContainer $group_token
 
TokenContainer $entry_token
 
Group $group
 
GroupsRepositoryDB $groups_repository
 

Detailed Description

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

@ilCtrl_isCalledBy ilFooterEntriesGUI: ilFooterGroupsGUI @ilCtrl_Calls ilFooterEntriesGUI: ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI

Definition at line 49 of file class.ilFooterEntriesGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilFooterEntriesGUI::__construct ( Pons  $pons)

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Definition at line 111 of file class.ilFooterEntriesGUI.php.

113 {
114 parent::__construct($pons);
115 global $DIC;
116 $this->translator = $pons->i18n();
117 $this->dic = $DIC;
118 $this->ui_factory = $this->dic->ui()->factory();
119
120 $this->groups_repository = new GroupsRepositoryDB(
121 $this->dic->database(),
123 );
124
125 $this->repository = new EntriesRepositoryDB(
126 $this->dic->database(),
128 );
129 $this->group_token = $this->pons->in()->buildToken('group', 'id');
130 $this->entry_token = $this->pons->in()->buildToken('entry', 'id');
131 $this->group = $this->groups_repository->get(
132 $this->pons->in()->getFirstFromRequest($this->group_token)
133 );
134 $this->pons->in()->keep($this->group_token);
135 }
__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()

ilFooterEntriesGUI::add ( )
private

Definition at line 179 of file class.ilFooterEntriesGUI.php.

179 : void
180 {
181 $form = new EntryForm(
182 $this->repository,
183 $this->translator,
184 $this->group
185 );
186
187 $target = $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
188 $this->pons->out()->outAsyncAsModal(
189 $this->translator->translate('add', 'entries'),
190 $target,
191 $form->get((string) $target)
192 );
193 }

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

ilFooterEntriesGUI::addButtons ( )
private

Definition at line 195 of file class.ilFooterEntriesGUI.php.

195 : array
196 {
197 $modal = $this->ui_factory->modal()->roundtrip(
198 $this->translator->translate('add', 'entries'),
199 null
200 )->withAsyncRenderUrl(
201 (string) $this->pons->flow()->getHereAsURI(self::CMD_ADD)
202 );
203
204 $this->dic->toolbar()->addComponent(
205 $this->ui_factory
206 ->button()
207 ->primary(
208 $this->translator->translate('add', 'entries'),
209 '#'
210 )
211 ->withOnClick($modal->getShowSignal())
212 );
213
214 return [$modal];
215 }
button(string $caption, string $cmd)

References ILIAS\Repository\button().

Referenced by index().

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

◆ buildTargetSelectorForm()

ilFooterEntriesGUI::buildTargetSelectorForm ( URI  $post_url)
private

Definition at line 404 of file class.ilFooterEntriesGUI.php.

404 : Standard
405 {
406 // determine parent group
407 $all_groups = $this->groups_repository->all();
408
409 $selection = [];
410 foreach ($all_groups as $group) {
411 if ($this->group !== null && $group->getId() === $this->group->getId()) {
412 continue;
413 }
414 $selection[$this->hash($group->getId())] = $group->getTitle();
415 }
416
417 return $this->pons->out()->ui()->factory()->input()->container()->form()->standard(
418 (string) $post_url,
419 [
420 $this->pons->out()->ui()->factory()->input()->field()->select(
421 $this->pons->i18n()->t('target_group', 'entries'),
422 $selection
423 )->withRequired(true)
424 ]
425 );
426 }
This describes a standard form.
Definition: Standard.php:30

References $group, ILIAS\GlobalScreen\UI\Footer\Groups\Group\getId(), and ILIAS\GlobalScreen\UI\Footer\Groups\Group\getTitle().

+ Here is the call graph for this function:

◆ confirmDelete()

ilFooterEntriesGUI::confirmDelete ( )
private

Definition at line 317 of file class.ilFooterEntriesGUI.php.

317 : void
318 {
319 $items = [];
320
321 $from_request = $this->pons->in()->getAllFromRequest($this->entry_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 $entry = $this->repository->get($id);
332 if ($entry === null) {
333 continue;
334 }
335 if ($entry->isCore()) {
336 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
337 $id,
338 $entry->getTitle(),
339 $this->translator->translate('info_not_deletable_core') .
340 $this->pons->out()->render($this->pons->out()->nok())
341 );
342 continue;
343 }
344 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
345 $this->hash($entry->getId()),
346 $entry->getTitle(),
347 $this->pons->out()->render($this->pons->out()->ok())
348 );
349 }
350
351 $this->pons->out()->outAsyncAsModal(
352 $this->translator->translate('entry_delete'),
353 $this->pons->flow()->getHereAsURI(self::CMD_DELETE),
354 ...$items
355 );
356 }
$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:

◆ create()

ilFooterEntriesGUI::create ( )

Definition at line 226 of file class.ilFooterEntriesGUI.php.

226 : void
227 {
228 $form = new EntryForm(
229 $this->repository,
230 $this->translator,
231 $this->group
232 );
233 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
234 if ($form->store(
235 $this->pons->in()->request(),
236 $target
237 )) {
238 $this->pons->flow()->redirect(self::CMD_DEFAULT);
239 }
240 $this->pons->out()->out(
241 $form->get(
242 $target
243 )
244 );
245 }

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

ilFooterEntriesGUI::delete ( )
private

Definition at line 359 of file class.ilFooterEntriesGUI.php.

359 : void
360 {
361 $from_request = $this->pons->in()->getAllFromRequest($this->entry_token);
362
363 if (($from_request[0] ?? null) === Input::ALL_OBJECTS) {
364 $from_request = array_map(
365 fn(TranslatableItem $item): string => $item->getId(),
366 iterator_to_array($this->repository->all())
367 );
368 }
369
370 $successful_deletions = 0;
371 foreach ($from_request as $id) {
372 $item = $this->repository->get($id);
373 if ($item === null) {
374 continue;
375 }
376 if ($item->isCore()) {
377 continue;
378 }
379 $this->repository->delete($item);
380 $successful_deletions++;
381 }
382
383 if ($successful_deletions === 0) {
384 $this->pons->out()->error($this->translator->translate('entry_deleted_failed'), true);
385 $this->pons->flow()->redirect(self::CMD_DEFAULT);
386 return;
387 }
388 $this->pons->out()->success($this->translator->translate('entry_deleted'), true);
389 $this->pons->flow()->redirect(self::CMD_DEFAULT);
390 }

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

+ Here is the call graph for this function:

◆ edit()

ilFooterEntriesGUI::edit ( )
private

Definition at line 248 of file class.ilFooterEntriesGUI.php.

248 : void
249 {
250 $id = $this->saveCurrentEntry();
251 $entry = $this->repository->get($id);
252
253 $form = new EntryForm(
254 $this->repository,
255 $this->translator,
256 $this->group,
257 $entry
258 );
259
260 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_UPDATE);
261 $this->pons->out()->outAsyncAsModal(
262 $this->translator->translate('edit', 'entries'),
263 $target,
264 $form->get($target)
265 );
266 }

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

Referenced by executeCommand().

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

◆ executeCommand()

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

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Definition at line 471 of file class.ilFooterEntriesGUI.php.

471 : bool
472 {
473 if ($this->pons->handle(ilObjFooterAdministrationGUI::TAB_SUB_ITEMS)) {
474 return true;
475 }
476 match ($this->pons->flow()->getCommand(self::CMD_DEFAULT)) {
477 self::CMD_DEFAULT => $this->index(),
478 self::CMD_ADD => $this->add(),
479 self::CMD_CREATE => $this->create(),
480 self::CMD_EDIT => $this->edit(),
481 self::CMD_UPDATE => $this->update(),
482 self::CMD_CONFIRM_DELETE => $this->confirmDelete(),
483 self::CMD_DELETE => $this->delete(),
484 self::CMD_TOGGLE_ACTIVATION => $this->toggleActivation(),
485 self::CMD_SAVE_ORDER => $this->saveOrder(),
486 self::CMD_SELECT_MOVE => $this->selectMove(),
487 self::CMD_MOVE => $this->move(),
488 default => $this->pons->out()->outString(
489 'Unknown command: ' . $this->pons->flow()->getCommand(self::CMD_DEFAULT)
490 ),
491 };
492 return true;
493 }

References add(), confirmDelete(), create(), edit(), index(), saveOrder(), selectMove(), ilObjFooterAdministrationGUI\TAB_SUB_ITEMS, toggleActivation(), and update().

+ Here is the call graph for this function:

◆ getCurrentItem()

ilFooterEntriesGUI::getCurrentItem ( )

Implements ILIAS\GlobalScreen\GUI\I18n\SupportsTranslationGUI.

Definition at line 145 of file class.ilFooterEntriesGUI.php.

146 {
147 return $this->repository->get(
148 $this->pons->in()->getFirstFromRequest($this->entry_token->token())
149 );
150 }

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

+ Here is the call graph for this function:

◆ getTokensToKeep()

ilFooterEntriesGUI::getTokensToKeep ( )

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Definition at line 137 of file class.ilFooterEntriesGUI.php.

137 : array
138 {
139 return [
140 $this->group_token->token(),
141 $this->entry_token->token(),
142 ];
143 }

◆ index()

ilFooterEntriesGUI::index ( )
private

Definition at line 153 of file class.ilFooterEntriesGUI.php.

153 : void
154 {
155 // Add new
156 $components = [];
157 if ($this->pons->access()->hasUserPermissionTo('write')) {
158 $components = $this->addButtons();
159 }
160 // Sync
161 $this->repository->syncWithGlobalScreen(
162 $this->dic->globalScreen()->collector()->footer()
163 );
164 // Table
165 $table = new EntriesTable(
166 $this->pons,
167 $this->group,
168 $this->repository,
169 $this->entry_token
170 );
171
172 $this->pons->out()->out(
173 $table->get(),
174 ...$components
175 );
176 }
$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:

◆ saveCurrentEntry()

ilFooterEntriesGUI::saveCurrentEntry ( )
private

Definition at line 217 of file class.ilFooterEntriesGUI.php.

217 : mixed
218 {
219 $id = $this->pons->in()->getFirstFromRequest($this->entry_token);
220 $this->pons->in()->keep($this->entry_token);
221
222 return $id;
223 }

References $id.

Referenced by edit().

+ Here is the caller graph for this function:

◆ saveOrder()

ilFooterEntriesGUI::saveOrder ( )
private

Definition at line 393 of file class.ilFooterEntriesGUI.php.

393 : void
394 {
395 foreach ($this->pons->in()->request()->getParsedBody() as $hashed_id => $position) {
396 $item = $this->repository->get($this->unhash($hashed_id));
397 $item = $item->withPosition((int) $position);
398 $this->repository->store($item);
399 }
400 $this->pons->out()->success($this->pons->i18n()->translate('order_saved'));
401 $this->pons->flow()->redirect(self::CMD_DEFAULT);
402 }

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:

◆ selectMove()

ilFooterEntriesGUI::selectMove ( )
private

Definition at line 429 of file class.ilFooterEntriesGUI.php.

429 : void
430 {
431 $this->pons->in()->keepTokens($this);
432
433 $post_url = $this->pons->flow()->getHereAsURI(self::CMD_MOVE);
434 $this->pons->out()->outAsyncAsModal(
435 $this->pons->i18n()->t(self::CMD_MOVE),
436 $post_url,
437 $this->buildTargetSelectorForm($post_url)
438 );
439 }

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ toggleActivation()

ilFooterEntriesGUI::toggleActivation ( )
private

Definition at line 293 of file class.ilFooterEntriesGUI.php.

293 : void
294 {
295 $from_request = $this->pons->in()->getAllFromRequest($this->entry_token);
296
297 if (($from_request[0] ?? null) === Input::ALL_OBJECTS) {
298 $from_request = array_map(
299 fn(TranslatableItem $item): string => $item->getId(),
300 iterator_to_array($this->repository->all())
301 );
302 }
303
304 foreach ($from_request as $id) {
305 $entry = $this->repository->get($id);
306 if ($entry === null) {
307 continue;
308 }
309 $this->repository->store($entry->withActive(!$entry->isActive()));
310 }
311
312 $this->pons->out()->success($this->translator->translate('group_activation_toggled'), true);
313 $this->pons->flow()->redirect(self::CMD_DEFAULT);
314 }

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

ilFooterEntriesGUI::update ( )

Definition at line 269 of file class.ilFooterEntriesGUI.php.

269 : void
270 {
271 $id = $this->pons->in()->getFirstFromRequest($this->entry_token);
272 $entry = $this->repository->get($id);
273
274 $form = new EntryForm(
275 $this->repository,
276 $this->translator,
277 $this->group,
278 $entry
279 );
280 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
281 if ($form->store(
282 $this->pons->in()->request(),
283 $target
284 )) {
285 $this->pons->flow()->redirect(self::CMD_DEFAULT);
286 }
287 $this->pons->out()->out(
288 $form->get($target)
289 );
290 }

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 ilFooterEntriesGUI::$ctrl
private

Definition at line 101 of file class.ilFooterEntriesGUI.php.

◆ $dic

Container ilFooterEntriesGUI::$dic
private

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

◆ $entry_token

TokenContainer ilFooterEntriesGUI::$entry_token
private

Definition at line 107 of file class.ilFooterEntriesGUI.php.

◆ $group

Group ilFooterEntriesGUI::$group
private

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

Referenced by buildTargetSelectorForm().

◆ $group_token

TokenContainer ilFooterEntriesGUI::$group_token
private

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

◆ $groups_repository

GroupsRepositoryDB ilFooterEntriesGUI::$groups_repository
private

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

◆ $repository

EntriesRepository ilFooterEntriesGUI::$repository
private

Definition at line 99 of file class.ilFooterEntriesGUI.php.

◆ $request

ServerRequestInterface ilFooterEntriesGUI::$request
private

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

◆ $translator

Translator ilFooterEntriesGUI::$translator
private

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

◆ $ui_factory

Factory ilFooterEntriesGUI::$ui_factory
private

Definition at line 100 of file class.ilFooterEntriesGUI.php.

◆ CMD_ADD

const ilFooterEntriesGUI::CMD_ADD = 'add'

Definition at line 60 of file class.ilFooterEntriesGUI.php.

◆ CMD_CONFIRM_DELETE

const ilFooterEntriesGUI::CMD_CONFIRM_DELETE = 'confirmDelete'

◆ CMD_CREATE

const ilFooterEntriesGUI::CMD_CREATE = 'create'

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

◆ CMD_DEFAULT

◆ CMD_DELETE

const ilFooterEntriesGUI::CMD_DELETE = 'delete'

Definition at line 88 of file class.ilFooterEntriesGUI.php.

◆ CMD_EDIT

const ilFooterEntriesGUI::CMD_EDIT = 'edit'

◆ CMD_MOVE

const string ilFooterEntriesGUI::CMD_MOVE = 'move'

Definition at line 98 of file class.ilFooterEntriesGUI.php.

◆ CMD_RESET

const ilFooterEntriesGUI::CMD_RESET = 'reset'

Definition at line 76 of file class.ilFooterEntriesGUI.php.

◆ CMD_SAVE_ORDER

const ilFooterEntriesGUI::CMD_SAVE_ORDER = 'saveOrder'

◆ CMD_SELECT_MOVE

const string ilFooterEntriesGUI::CMD_SELECT_MOVE = 'selectMove'

◆ CMD_TOGGLE_ACTIVATION

const ilFooterEntriesGUI::CMD_TOGGLE_ACTIVATION = 'toggleActivation'

◆ CMD_UPDATE

const ilFooterEntriesGUI::CMD_UPDATE = 'update'

Definition at line 72 of file class.ilFooterEntriesGUI.php.

◆ GSFO_ID

const ilFooterEntriesGUI::GSFO_ID = 'gsfo_entry_id'

Definition at line 92 of file class.ilFooterEntriesGUI.php.


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