ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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
49 public function __construct(
50 private Pons $pons,
51 private readonly Group $group,
52 private readonly EntriesRepository $repository,
53 private readonly TokenContainer $token_container,
54 ) {
55 $this->translator = $pons->i18n();
56 $this->ui_factory = $pons->out()->ui()->factory();
57 $this->url_builder = $this->token_container->builder();
58 $this->id_token = $this->token_container->token();
59 $this->request = $pons->in()->request();
60 $this->translations_repository = $pons->i18n()->ml()->repository();
61 }
62
63
64 public function getRows(OrderingRowBuilder $row_builder, array $visible_column_ids): \Generator
65 {
66 $ok = $this->pons->out()->ok();
67 $nok = $this->pons->out()->nok();
68
69 foreach ($this->repository->allForParent($this->group->getId()) as $entry) {
70 if ($entry->isCore()) {
71 $title = $this->collector->getSingleItemFromRaw(
72 $this->identification->fromSerializedIdentification($entry->getId()),
73 )?->getTitle() ?? 'Unknown';
74 } else {
75 $title = $this->translations_repository->get($entry)->getDefault()?->getTranslation(
76 ) ?? $entry->getTitle();
77 }
78
79 $row = $row_builder->buildOrderingRow(
80 $this->hash($entry->getId()),
81 [
82 self::COLUMN_TITLE => $title,
83 self::COLUMN_ACTIVE => $entry->isActive() ? $ok : $nok,
84 ]
85 );
86
87 if ($entry->isCore()) {
88 $row = $row->withDisabledAction('delete')
89 ->withDisabledAction('edit')
90 ->withDisabledAction('translate')
91 ->withDisabledAction('move');
92 }
93
94 yield $row;
95 }
96 }
97
98 public function get(): Ordering
99 {
100 $flow = $this->pons->flow();
101 return $this->ui_factory
102 ->table()
103 ->ordering(
104 $this,
105 $flow->getHereAsURI(\ilFooterEntriesGUI::CMD_SAVE_ORDER),
106 $this->group->getTitle(),
107 [
108 self::COLUMN_TITLE => $this->ui_factory->table()->column()->text(
109 $this->translator->translate('title', 'entry')
110 ),
111 self::COLUMN_ACTIVE => $this->ui_factory->table()->column()->statusIcon(
112 $this->translator->translate('active', 'entry')
113 )
114 ],
115 )
116 ->withRequest($this->request)
117 ->withActions(
118 [
119 'edit' => $this->ui_factory->table()->action()->single(
120 $this->translator->translate('edit', 'entry'),
121 $this->url_builder->withURI($flow->getHereAsURI(\ilFooterEntriesGUI::CMD_EDIT)),
122 $this->id_token
123 )->withAsync(true),
124
125 'toggle_activation' => $this->ui_factory->table()->action()->standard(
126 $this->translator->translate('toggle_activation', 'entry'),
127 $this->url_builder->withURI($flow->getHereAsURI(\ilFooterEntriesGUI::CMD_TOGGLE_ACTIVATION)),
128 $this->id_token
129 )->withAsync(false),
130
131 'delete' => $this->ui_factory->table()->action()->standard(
132 $this->translator->translate('delete', 'entry'),
133 $this->url_builder->withURI($flow->getHereAsURI(\ilFooterEntriesGUI::CMD_CONFIRM_DELETE)),
134 $this->id_token
135 )->withAsync(true),
136
137 'move' => $this->ui_factory->table()->action()->standard(
138 $this->translator->translate('move', 'entry'),
139 $this->url_builder->withURI($flow->getHereAsURI(\ilFooterEntriesGUI::CMD_SELECT_MOVE)),
140 $this->id_token
141 )->withAsync(true),
142
143 'translate' => $this->ui_factory->table()->action()->single(
144 $this->translator->translate('translate', 'group'),
145 $this->url_builder->withURI(
146 $flow->getTranslationAsURI()
147 ),
148 $this->id_token
149 )->withAsync(true),
150 ]
151 );
152 }
153
154
155}
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...
__construct(private Pons $pons, private readonly Group $group, private readonly EntriesRepository $repository, private readonly TokenContainer $token_container,)
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...