ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
Table.php
Go to the documentation of this file.
1 <?php
2 
20 
23 use ilCtrlInterface;
24 use ilLanguage;
30 use ILIAS\Data\URI;
32 
36 class 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';
45  private ilLanguage $lng;
48 
49  protected array $components = [];
50 
51  public function __construct(
52  private ilADNNotificationGUI $calling_gui,
53  ) {
54  global $DIC;
55  $this->ui_factory = $DIC['ui.factory'];
56  $this->ui_renderer = $DIC['ui.renderer'];
57  $this->ctrl = $DIC['ilCtrl'];
58  $this->lng = $DIC['lng'];
59 
60  $this->url_builder = $this->initURIBuilder();
61  $columns = $this->initColumns();
62  $actions = $this->initActions();
63  $data_retrieval = new DataRetrieval(
64  (new ilObjAdministrativeNotificationAccess())->hasUserPermissionTo('write')
65  );
66 
67  $this->components[] = $this->ui_factory->table()->data(
68  $this->lng->txt('notifications'),
69  $columns,
70  $data_retrieval
71  )->withActions($actions)->withRequest(
72  $DIC->http()->request()
73  );
74  }
75 
76  private function initURIBuilder(): URLBuilder
77  {
78  $url_builder = new URLBuilder(
80  );
81 
82  // these are the query parameters this instance is controlling
83  $query_params_namespace = ['msg', 'notifications'];
85  $query_params_namespace,
87  );
88 
89  return $url_builder;
90  }
91 
92  protected function initColumns(): array
93  {
94  return [
95  'title' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_title')),
96  'type' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_type')),
97  'languages' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_languages')),
98  'type_during_event' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_type_during_event')),
99  'event_start' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_event_date_start')),
100  'event_end' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_event_date_end')),
101  'display_start' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_display_date_start')),
102  'display_end' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_display_date_end'))
103  ];
104  }
105 
106  protected function initActions(): array
107  {
108  return [
109  self::ACTION_EDIT => $this->ui_factory->table()->action()->single(
110  $this->lng->txt("btn_edit"),
111  $this->url_builder->withURI($this->getURI(ilADNNotificationGUI::CMD_EDIT)),
113  ),
114  self::ACTION_DELETE => $this->ui_factory->table()->action()->standard(
115  $this->lng->txt("btn_delete"),
116  $this->url_builder->withURI($this->getURI(ilADNNotificationGUI::CMD_CONFIRM_DELETE)),
118  )->withAsync(true),
119  self::ACTION_RESET => $this->ui_factory->table()->action()->standard(
120  $this->lng->txt("btn_reset"),
121  $this->url_builder->withURI($this->getURI(ilADNNotificationGUI::CMD_RESET)),
123  ),
124  self::ACTION_DUPLICATE => $this->ui_factory->table()->action()->single(
125  $this->lng->txt("btn_duplicate"),
126  $this->url_builder->withURI($this->getURI(ilADNNotificationGUI::CMD_DUPLICATE)),
128  ),
129  ];
130  }
131 
136  protected function getURI(string $command): URI
137  {
138  return new URI(
139  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget(
140  $this->calling_gui,
141  $command
142  )
143  );
144  }
145 
146  public function getHTML(): string
147  {
148  return $this->ui_renderer->render($this->components);
149  }
150 
151  public function getUrlBuilder(): URLBuilder
152  {
153  return $this->url_builder;
154  }
155 
156  public function getIdToken(): URLBuilderToken
157  {
158  return $this->id_token;
159  }
160 
161 }
__construct(private ilADNNotificationGUI $calling_gui,)
Definition: Table.php:51
acquireParameters(array $namespace, string ... $names)
Definition: URLBuilder.php:138
getURI(string $command)
Unfortunately, I have not yet found an easier way to generate this URI.
Definition: Table.php:136
global $DIC
Definition: shib_login.php:26
Builds data types.
Definition: Factory.php:35
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilChatroomConfigFileHandler .
URLBuilder.
Definition: URLBuilder.php:40