ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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'
 
- Data Fields inherited from ILIAS\GlobalScreen\GUI\PonsGUI
const CMD_DEFAULT = 'index'
 

Private Member Functions

 index ()
 
 add ()
 
 addButtons ()
 
 saveCurrentEntry ()
 
 edit ()
 
 toggleActivation ()
 
 confirmDelete ()
 
 delete ()
 
 saveOrder ()
 

Private Attributes

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

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 46 of file class.ilFooterEntriesGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilFooterEntriesGUI::__construct ( Pons  $pons)

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

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

107 {
108 parent::__construct($pons);
109 global $DIC;
110 $this->translator = $pons->i18n();
111 $this->dic = $DIC;
112 $this->ui_factory = $this->dic->ui()->factory();
113
114 $group_repository = new GroupsRepositoryDB(
115 $this->dic->database(),
117 );
118
119 $this->repository = new EntriesRepositoryDB(
120 $this->dic->database(),
122 );
123 $this->group_token = $this->pons->in()->buildToken('group', 'id');
124 $this->entry_token = $this->pons->in()->buildToken('entry', 'id');
125 $this->group = $group_repository->get(
126 $this->pons->in()->getFirstFromRequest($this->group_token)
127 );
128 $this->pons->in()->keep($this->group_token);
129 }
__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 173 of file class.ilFooterEntriesGUI.php.

173 : void
174 {
175 $form = new EntryForm(
176 $this->repository,
177 $this->translator,
178 $this->group
179 );
180
181 $target = $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
182 $this->pons->out()->outAsyncAsModal(
183 $this->translator->translate('add', 'entries'),
184 $target,
185 $form->get((string) $target)
186 );
187 }

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 189 of file class.ilFooterEntriesGUI.php.

189 : array
190 {
191 $modal = $this->ui_factory->modal()->roundtrip(
192 $this->translator->translate('add', 'entries'),
193 null
194 )->withAsyncRenderUrl(
195 (string) $this->pons->flow()->getHereAsURI(self::CMD_ADD)
196 );
197
198 $this->dic->toolbar()->addComponent(
199 $this->ui_factory
200 ->button()
201 ->primary(
202 $this->translator->translate('add', 'entries'),
203 '#'
204 )
205 ->withOnClick($modal->getShowSignal())
206 );
207
208 return [$modal];
209 }
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:

◆ confirmDelete()

ilFooterEntriesGUI::confirmDelete ( )
private

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

311 : void
312 {
313 $items = [];
314
315 $from_request = $this->pons->in()->getAllFromRequest($this->entry_token);
316
317 if (($from_request[0] ?? null) === Input::ALL_OBJECTS) {
318 $from_request = array_map(
319 fn(TranslatableItem $item): string => $item->getId(),
320 iterator_to_array($this->repository->all())
321 );
322 }
323
324 foreach ($from_request as $id) {
325 $entry = $this->repository->get($id);
326 if ($entry === null) {
327 continue;
328 }
329 if ($entry->isCore()) {
330 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
331 $id,
332 $entry->getTitle(),
333 $this->translator->translate('info_not_deletable_core') .
334 $this->pons->out()->render($this->pons->out()->nok())
335 );
336 continue;
337 }
338 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
339 $this->hash($entry->getId()),
340 $entry->getTitle(),
341 $this->pons->out()->render($this->pons->out()->ok())
342 );
343 }
344
345 $this->pons->out()->outAsyncAsModal(
346 $this->translator->translate('entry_delete'),
347 $this->pons->flow()->getHereAsURI(self::CMD_DELETE),
348 ...$items
349 );
350 }
$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 220 of file class.ilFooterEntriesGUI.php.

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

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 353 of file class.ilFooterEntriesGUI.php.

353 : void
354 {
355 $from_request = $this->pons->in()->getAllFromRequest($this->entry_token);
356
357 if (($from_request[0] ?? null) === Input::ALL_OBJECTS) {
358 $from_request = array_map(
359 fn(TranslatableItem $item): string => $item->getId(),
360 iterator_to_array($this->repository->all())
361 );
362 }
363
364 foreach ($from_request as $id) {
365 $item = $this->repository->get($id);
366 if ($item === null) {
367 continue;
368 }
369 if ($item->isCore()) {
370 continue;
371 }
372 $this->repository->delete($item);
373 }
374
375 $this->pons->out()->success($this->translator->translate('entry_deleted'), true);
376 $this->pons->flow()->redirect(self::CMD_DEFAULT);
377 }

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 242 of file class.ilFooterEntriesGUI.php.

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

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 390 of file class.ilFooterEntriesGUI.php.

390 : bool
391 {
392 if ($this->pons->handle(ilObjFooterAdministrationGUI::TAB_SUB_ITEMS)) {
393 return true;
394 }
395 match ($this->pons->flow()->getCommand(self::CMD_DEFAULT)) {
396 self::CMD_DEFAULT => $this->index(),
397 self::CMD_ADD => $this->add(),
398 self::CMD_CREATE => $this->create(),
399 self::CMD_EDIT => $this->edit(),
400 self::CMD_UPDATE => $this->update(),
401 self::CMD_CONFIRM_DELETE => $this->confirmDelete(),
402 self::CMD_DELETE => $this->delete(),
403 self::CMD_TOGGLE_ACTIVATION => $this->toggleActivation(),
404 self::CMD_SAVE_ORDER => $this->saveOrder(),
405 default => $this->pons->out()->outString(
406 'Unknown command: ' . $this->pons->flow()->getCommand(self::CMD_DEFAULT)
407 ),
408 };
409 return true;
410 }

References add(), confirmDelete(), create(), edit(), index(), saveOrder(), 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 139 of file class.ilFooterEntriesGUI.php.

140 {
141 return $this->repository->get(
142 $this->pons->in()->getFirstFromRequest($this->entry_token->token())
143 );
144 }

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 131 of file class.ilFooterEntriesGUI.php.

131 : array
132 {
133 return [
134 $this->group_token->token(),
135 $this->entry_token->token(),
136 ];
137 }

◆ index()

ilFooterEntriesGUI::index ( )
private

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

147 : void
148 {
149 // Add new
150 $components = [];
151 if ($this->pons->access()->hasUserPermissionTo('write')) {
152 $components = $this->addButtons();
153 }
154 // Sync
155 $this->repository->syncWithGlobalScreen(
156 $this->dic->globalScreen()->collector()->footer()
157 );
158 // Table
159 $table = new EntriesTable(
160 $this->pons,
161 $this->group,
162 $this->repository,
163 $this->entry_token
164 );
165
166 $this->pons->out()->out(
167 $table->get(),
168 ...$components
169 );
170 }
$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 211 of file class.ilFooterEntriesGUI.php.

211 : mixed
212 {
213 $id = $this->pons->in()->getFirstFromRequest($this->entry_token);
214 $this->pons->in()->keep($this->entry_token);
215
216 return $id;
217 }

References $id.

Referenced by edit().

+ Here is the caller graph for this function:

◆ saveOrder()

ilFooterEntriesGUI::saveOrder ( )
private

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

379 : void
380 {
381 foreach ($this->pons->in()->request()->getParsedBody() as $hashed_id => $position) {
382 $item = $this->repository->get($this->unhash($hashed_id));
383 $item = $item->withPosition((int) $position);
384 $this->repository->store($item);
385 }
386 $this->pons->out()->success($this->pons->i18n()->translate('order_saved'));
387 $this->pons->flow()->redirect(self::CMD_DEFAULT);
388 }

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

ilFooterEntriesGUI::toggleActivation ( )
private

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

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

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 263 of file class.ilFooterEntriesGUI.php.

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

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 96 of file class.ilFooterEntriesGUI.php.

◆ $dic

Container ilFooterEntriesGUI::$dic
private

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

◆ $entry_token

TokenContainer ilFooterEntriesGUI::$entry_token
private

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

◆ $group

Group ilFooterEntriesGUI::$group
private

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

◆ $group_token

TokenContainer ilFooterEntriesGUI::$group_token
private

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

◆ $repository

EntriesRepository ilFooterEntriesGUI::$repository
private

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

◆ $request

ServerRequestInterface ilFooterEntriesGUI::$request
private

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

◆ $translator

Translator ilFooterEntriesGUI::$translator
private

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

◆ $ui_factory

Factory ilFooterEntriesGUI::$ui_factory
private

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

◆ CMD_ADD

const ilFooterEntriesGUI::CMD_ADD = 'add'

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

◆ CMD_CONFIRM_DELETE

const ilFooterEntriesGUI::CMD_CONFIRM_DELETE = 'confirmDelete'

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

◆ CMD_CREATE

const ilFooterEntriesGUI::CMD_CREATE = 'create'

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

◆ CMD_DEFAULT

◆ CMD_DELETE

const ilFooterEntriesGUI::CMD_DELETE = 'delete'

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

◆ CMD_EDIT

const ilFooterEntriesGUI::CMD_EDIT = 'edit'

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

◆ CMD_RESET

const ilFooterEntriesGUI::CMD_RESET = 'reset'

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

◆ CMD_SAVE_ORDER

const ilFooterEntriesGUI::CMD_SAVE_ORDER = 'saveOrder'

◆ CMD_TOGGLE_ACTIVATION

const ilFooterEntriesGUI::CMD_TOGGLE_ACTIVATION = 'toggleActivation'

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

◆ CMD_UPDATE

const ilFooterEntriesGUI::CMD_UPDATE = 'update'

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

◆ GSFO_ID

const ilFooterEntriesGUI::GSFO_ID = 'gsfo_entry_id'

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


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