ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Table.php
Go to the documentation of this file.
1 <?php
2 
20 
25 use ILIAS\Data\URI;
27 
31 class Table
32 {
35  private \ilCtrlInterface $ctrl;
36  private \ilLanguage $lng;
39 
40  protected array $components = [];
41 
42  public function __construct(
43  private \ilADNNotificationGUI $calling_gui,
44  ) {
45  global $DIC;
46  $this->ui_factory = $DIC['ui.factory'];
47  $this->ui_renderer = $DIC['ui.renderer'];
48  $this->ctrl = $DIC['ilCtrl'];
49  $this->lng = $DIC['lng'];
50 
51  $this->url_builder = $this->initURIBuilder();
52  $columns = $this->initColumns();
53  $actions = $this->initActions();
54  $data_retrieval = new DataRetrieval();
55 
56  $this->components[] = $this->ui_factory->table()->data(
57  $data_retrieval,
58  $this->lng->txt('notifications'),
59  $columns,
60  )->withActions($actions)->withRequest(
61  $DIC->http()->request()
62  );
63  }
64 
65  private function initURIBuilder(): URLBuilder
66  {
67  $url_builder = new URLBuilder(
69  );
70 
71  // these are the query parameters this instance is controlling
72  $query_params_namespace = ['msg', 'notifications'];
74  $query_params_namespace,
76  );
77 
78  return $url_builder;
79  }
80 
81  protected function initColumns(): array
82  {
83  return [
84  'title' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_title')),
85  'type' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_type')),
86  'languages' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_languages')),
87  'type_during_event' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_type_during_event')),
88  'event_start' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_event_date_start')),
89  'event_end' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_event_date_end')),
90  'display_start' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_display_date_start')),
91  'display_end' => $this->ui_factory->table()->column()->text($this->lng->txt('msg_display_date_end'))
92  ];
93  }
94 
95  protected function initActions(): array
96  {
97  $actions = [
98  'edit' => $this->ui_factory->table()->action()->single(
99  $this->lng->txt("btn_edit"),
100  $this->url_builder->withURI($this->getURI(\ilADNNotificationGUI::CMD_EDIT)),
102  ),
103  'delete' => $this->ui_factory->table()->action()->standard(
104  $this->lng->txt("btn_delete"),
105  $this->url_builder->withURI($this->getURI(\ilADNNotificationGUI::CMD_CONFIRM_DELETE)),
107  )->withAsync(true),
108  'reset' => $this->ui_factory->table()->action()->standard(
109  $this->lng->txt("btn_reset"),
110  $this->url_builder->withURI($this->getURI(\ilADNNotificationGUI::CMD_RESET)),
112  ),
113  'duplicate' => $this->ui_factory->table()->action()->single(
114  $this->lng->txt("btn_duplicate"),
115  $this->url_builder->withURI($this->getURI(\ilADNNotificationGUI::CMD_DUPLICATE)),
117  ),
118  ];
119 
120  return $actions;
121  }
122 
127  protected function getURI(string $command): URI
128  {
129  return new URI(
130  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget(
131  $this->calling_gui,
132  $command
133  )
134  );
135  }
136 
137  public function getHTML(): string
138  {
139  return $this->ui_renderer->render($this->components);
140  }
141 
142  public function getUrlBuilder(): URLBuilder
143  {
144  return $this->url_builder;
145  }
146 
147  public function getIdToken(): URLBuilderToken
148  {
149  return $this->id_token;
150  }
151 
152 }
Class ilADNNotificationGUI ilADNNotificationGUI: ilObjAdministrativeNotificationGUI ilADNNotificati...
__construct(private \ilADNNotificationGUI $calling_gui,)
Definition: Table.php:42
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:127
global $DIC
Definition: shib_login.php:22
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
URLBuilder.
Definition: URLBuilder.php:40