ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 $title = $this->translations_repository->get($entry)->getDefault()?->getTranslation() ?? $entry->getTitle();
71 $row = $row_builder->buildOrderingRow(
72 $this->hash($entry->getId()),
73 [
74 self::COLUMN_TITLE => $title,
75 self::COLUMN_ACTIVE => $entry->isActive() ? $ok : $nok,
76 ]
77 );
78
79 if ($entry->isCore()) {
80 $row = $row->withDisabledAction('delete')
81 ->withDisabledAction('edit')
82 ->withDisabledAction('translate')
83 ->withDisabledAction('move');
84 }
85
86 yield $row;
87 }
88 }
89
90 public function get(): Ordering
91 {
92 $flow = $this->pons->flow();
93 return $this->ui_factory
94 ->table()
95 ->ordering(
96 $this,
97 $flow->getHereAsURI(\ilFooterEntriesGUI::CMD_SAVE_ORDER),
98 $this->group->getTitle(),
99 [
100 self::COLUMN_TITLE => $this->ui_factory->table()->column()->text(
101 $this->translator->translate('title', 'entry')
102 ),
103 self::COLUMN_ACTIVE => $this->ui_factory->table()->column()->statusIcon(
104 $this->translator->translate('active', 'entry')
105 )
106 ],
107 )
108 ->withRequest($this->request)
109 ->withActions(
110 [
111 'edit' => $this->ui_factory->table()->action()->single(
112 $this->translator->translate('edit', 'entry'),
113 $this->url_builder->withURI($flow->getHereAsURI('edit')),
114 $this->id_token
115 )->withAsync(true),
116
117 'toggle_activation' => $this->ui_factory->table()->action()->standard(
118 $this->translator->translate('toggle_activation', 'entry'),
119 $this->url_builder->withURI($flow->getHereAsURI('toggleActivation')),
120 $this->id_token
121 )->withAsync(false),
122
123 'delete' => $this->ui_factory->table()->action()->standard(
124 $this->translator->translate('delete', 'entry'),
125 $this->url_builder->withURI($flow->getHereAsURI('confirmDelete')),
126 $this->id_token
127 )->withAsync(true),
128
129 'move' => $this->ui_factory->table()->action()->standard(
130 $this->translator->translate('move', 'entry'),
131 $this->url_builder->withURI($flow->getHereAsURI('selectMove')),
132 $this->id_token
133 )->withAsync(true),
134
135 'translate' => $this->ui_factory->table()->action()->single(
136 $this->translator->translate('translate', 'group'),
137 $this->url_builder->withURI(
138 $flow->getTranslationAsURI()
139 ),
140 $this->id_token
141 )->withAsync(true),
142 ]
143 );
144 }
145
146
147}
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...