ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
EntriesTable.php
Go to the documentation of this file.
1<?php
2
20
22use Psr\Http\Message\ServerRequestInterface;
26use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
31use ILIAS\GlobalScreen\GUI\I18n\Translator;
34
36{
37 use Hasher;
38
39 public const COLUMN_ACTIVE = 'active';
40 public const COLUMN_TITLE = 'title';
41 public const CLUMNS_ITEMS = 'items';
43 private ServerRequestInterface $request;
46 private Translator $translator;
48 private \ILIAS\GlobalScreen\Scope\Footer\Collector\FooterMainCollector $collector;
49 private \ILIAS\GlobalScreen\Identification\IdentificationFactory $identification;
50
51 public function __construct(
52 private Pons $pons,
53 private readonly Group $group,
54 private readonly EntriesRepository $repository,
55 private readonly TokenContainer $token_container,
56 ) {
57 global $DIC;
58
59 $this->translator = $pons->i18n();
60 $this->ui_factory = $pons->out()->ui()->factory();
61 $this->url_builder = $this->token_container->builder();
62 $this->id_token = $this->token_container->token();
63 $this->request = $pons->in()->request();
64 $this->translations_repository = $pons->i18n()->ml()->repository();
65 $this->collector = $DIC->globalScreen()->collector()->footer();
66 $this->identification = $DIC->globalScreen()->identification();
67 }
68
69
70 public function getRows(OrderingRowBuilder $row_builder, array $visible_column_ids): \Generator
71 {
72 $ok = $this->pons->out()->ok();
73 $nok = $this->pons->out()->nok();
74
75 foreach ($this->repository->allForParent($this->group->getId()) as $entry) {
76 if ($entry->isCore()) {
77 $title = $this->collector->getSingleItemFromRaw(
78 $this->identification->fromSerializedIdentification($entry->getId()),
79 )?->getTitle() ?? 'Unknown';
80 } else {
81 $title = $this->translations_repository->get($entry)->getDefault()?->getTranslation(
82 ) ?? $entry->getTitle();
83 }
84
85 $row = $row_builder->buildOrderingRow(
86 $this->hash($entry->getId()),
87 [
88 self::COLUMN_TITLE => $title,
89 self::COLUMN_ACTIVE => $entry->isActive() ? $ok : $nok,
90 ]
91 );
92
93 if ($entry->isCore()) {
94 $row = $row->withDisabledAction('delete')
95 ->withDisabledAction('edit')
96 ->withDisabledAction('translate')
97 ->withDisabledAction('move');
98 }
99
100 yield $row;
101 }
102 }
103
104 public function get(): Ordering
105 {
106 $flow = $this->pons->flow();
107 return $this->ui_factory
108 ->table()
109 ->ordering(
110 $this,
111 $flow->getHereAsURI(\ilFooterEntriesGUI::CMD_SAVE_ORDER),
112 $this->group->getTitle(),
113 [
114 self::COLUMN_TITLE => $this->ui_factory->table()->column()->text(
115 $this->translator->translate('title', 'entry')
116 ),
117 self::COLUMN_ACTIVE => $this->ui_factory->table()->column()->statusIcon(
118 $this->translator->translate('active', 'entry')
119 )
120 ],
121 )
122 ->withRequest($this->request)
123 ->withActions(
124 [
125 'edit' => $this->ui_factory->table()->action()->single(
126 $this->translator->translate('edit', 'entry'),
127 $this->url_builder->withURI($flow->getHereAsURI(\ilFooterEntriesGUI::CMD_EDIT)),
128 $this->id_token
129 )->withAsync(true),
130
131 'toggle_activation' => $this->ui_factory->table()->action()->standard(
132 $this->translator->translate('toggle_activation', 'entry'),
133 $this->url_builder->withURI($flow->getHereAsURI(\ilFooterEntriesGUI::CMD_TOGGLE_ACTIVATION)),
134 $this->id_token
135 )->withAsync(false),
136
137 'delete' => $this->ui_factory->table()->action()->standard(
138 $this->translator->translate('delete', 'entry'),
139 $this->url_builder->withURI($flow->getHereAsURI(\ilFooterEntriesGUI::CMD_CONFIRM_DELETE)),
140 $this->id_token
141 )->withAsync(true),
142
143 'move' => $this->ui_factory->table()->action()->standard(
144 $this->translator->translate('move', 'entry'),
145 $this->url_builder->withURI($flow->getHereAsURI(\ilFooterEntriesGUI::CMD_SELECT_MOVE)),
146 $this->id_token
147 )->withAsync(true),
148
149 'translate' => $this->ui_factory->table()->action()->single(
150 $this->translator->translate('translate', 'group'),
151 $this->url_builder->withURI(
152 $flow->getTranslationAsURI()
153 ),
154 $this->id_token
155 )->withAsync(true),
156 ]
157 );
158 }
159
160
161}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
getRows(OrderingRowBuilder $row_builder, array $visible_column_ids)
This is called by the (ordering-)table to retrieve rows; map data-records to rows using the $row_buil...
ILIAS GlobalScreen Identification IdentificationFactory $identification
__construct(private Pons $pons, private readonly Group $group, private readonly EntriesRepository $repository, private readonly TokenContainer $token_container,)
ILIAS GlobalScreen Scope Footer Collector FooterMainCollector $collector
buildOrderingRow(string $id, array $record)
This describes a Table to specify the order of its data (rows).
Definition: Ordering.php:29
This is how the factory for UI elements looks.
Definition: Factory.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26