ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
Table.php
Go to the documentation of this file.
1<?php
2
20
24use ilLanguage;
32
36class Table
37{
38 public const ACTION_EDIT = 'edit';
39 public const ACTION_DELETE = 'delete';
40 public const ACTION_RESET = 'reset';
41 public const ACTION_DUPLICATE = 'duplicate';
48 private bool $write_access;
49
50 protected array $components = [];
51
52 public function __construct(
53 private ilADNNotificationGUI $calling_gui
54 ) {
55 global $DIC;
56 $this->ui_factory = $DIC['ui.factory'];
57 $this->ui_renderer = $DIC['ui.renderer'];
58 $this->ctrl = $DIC['ilCtrl'];
59 $this->lng = $DIC['lng'];
60
61 $this->url_builder = $this->initURIBuilder();
62 $this->write_access = (new ilObjAdministrativeNotificationAccess())->hasUserPermissionTo('write');
63 $columns = $this->initColumns();
64 $actions = $this->initActions();
65 $data_retrieval = new DataRetrieval(
66 $this->write_access
67 );
68
69 $this->components[] = $this->ui_factory->table()->data(
70 $data_retrieval,
71 $this->lng->txt('msg_table_title'),
72 $columns,
73 )->withActions($actions)->withRequest(
74 $DIC->http()->request()
75 );
76 }
77
78 private function initURIBuilder(): URLBuilder
79 {
82 );
83
84 // these are the query parameters this instance is controlling
85 $query_params_namespace = ['msg', 'notifications'];
87 $query_params_namespace,
89 );
90
91 return $url_builder;
92 }
93
94 protected function initColumns(): array
95 {
96 return [
97 'title' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_title')),
98 'type' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_type')),
99 'languages' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_languages')),
100 'type_during_event' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_type_during_event')),
101 'event_start' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_event_date_start')),
102 'event_end' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_event_date_end')),
103 'display_start' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_display_date_start')),
104 'display_end' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_display_date_end'))
105 ];
106 }
107
108 protected function initActions(): array
109 {
110 if ($this->write_access === false) {
111 return [];
112 }
113
114 return [
115 self::ACTION_EDIT => $this->ui_factory->table()->action()->single(
116 $this->lng->txt("btn_edit"),
117 $this->url_builder->withURI($this->getURI(ilADNNotificationGUI::CMD_EDIT)),
118 $this->id_token
119 ),
120 self::ACTION_DELETE => $this->ui_factory->table()->action()->standard(
121 $this->lng->txt("btn_delete"),
122 $this->url_builder->withURI($this->getURI(ilADNNotificationGUI::CMD_CONFIRM_DELETE)),
123 $this->id_token
124 )->withAsync(true),
125 self::ACTION_RESET => $this->ui_factory->table()->action()->standard(
126 $this->lng->txt("btn_reset"),
127 $this->url_builder->withURI($this->getURI(ilADNNotificationGUI::CMD_RESET)),
128 $this->id_token
129 ),
130 self::ACTION_DUPLICATE => $this->ui_factory->table()->action()->single(
131 $this->lng->txt("btn_duplicate"),
132 $this->url_builder->withURI($this->getURI(ilADNNotificationGUI::CMD_DUPLICATE)),
133 $this->id_token
134 ),
135 ];
136 }
137
142 protected function getURI(string $command): URI
143 {
144 return new URI(
145 ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget(
146 $this->calling_gui,
147 $command
148 )
149 );
150 }
151
152 public function getHTML(): string
153 {
154 return $this->ui_renderer->render($this->components);
155 }
156
157 public function getUrlBuilder(): URLBuilder
158 {
159 return $this->url_builder;
160 }
161
162 public function getIdToken(): URLBuilderToken
163 {
164 return $this->id_token;
165 }
166
167}
getURI(string $command)
@description Unfortunately, I have not yet found an easier way to generate this URI.
Definition: Table.php:142
__construct(private ilADNNotificationGUI $calling_gui)
Definition: Table.php:52
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
acquireParameters(array $namespace, string ... $names)
Definition: URLBuilder.php:138
Class ilADNAbstractGUI.
Class ilADNNotificationGUI @ilCtrl_IsCalledBy ilADNNotificationGUI: ilObjAdministrativeNotificationGU...
Class ilBiblFieldFilterGUI.
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilChatroomConfigFileHandler \ILIAS\Chatroom\classes.
global $DIC
Definition: shib_login.php:26