ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
BookingTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use Generator;
28use ILIAS\UI\Factory as UIFactory;
29use ILIAS\Data\Factory as DataFactory;
31use Psr\Http\Message\ServerRequestInterface as ServerRequestInterface;
32use ILIAS\UI\Renderer as Renderer;
33use ilLanguage;
34use ilObjUser;
35use ilCtrl;
38
40{
41 public const ACTION_TOKEN = 'action';
42 public const ID_TOKEN = 'id';
43 public const TABLE_NS = 'ch_booking_table';
44
45 public const ACTION_TOKEN_NS = self::TABLE_NS . '_' . self::ACTION_TOKEN;
46
47 public const ID_TOKEN_NS = self::TABLE_NS . '_' . self::ID_TOKEN;
48
49
51
52 protected readonly ilLanguage $lng;
53 protected readonly ilObjUser $user;
54 protected readonly ilCtrl $ctrl;
55 protected readonly UIFactory $ui_factory;
56 protected readonly DataFactory $data_factory;
57 protected readonly ServerRequestInterface $http_request;
59
60
62 {
63 global $DIC;
64
65 $this->provider = $provider;
66
67 $this->lng = $DIC->language();
68 $this->user = $DIC->user();
69 $this->ctrl = $DIC->ctrl();
70
71 $this->http_request = $DIC->http()->request();
72 $this->ui_factory = $DIC->ui()->factory();
73 $this->data_factory = new DataFactory();
74 $this->ui_renderer = $DIC->ui()->renderer();
75 }
76
77 public function getRows(
78 DataRowBuilder $row_builder,
79 array $visible_column_ids,
81 Order $order,
82 ?array $filter_data,
83 ?array $additional_parameters
84 ): Generator {
85 $records = $this->provider->limitData($range, $order);
86 foreach ($records as $row) {
87 $id = $row['id'];
88 $records_row = $row_builder->buildDataRow($id, $row);
89 if (count($row['booking_participant']->getItems()) === 0) {
90 $records_row = $records_row
91 ->withDisabledAction('confirmCancelBooking')
92 ->withDisabledAction('confirmDeleteBooking')
93 ->withDisabledAction('sendMail');
94 }
95 yield $records_row;
96 }
97 }
98
99 public function getTotalRowCount(?array $filter_data, ?array $additional_parameters): ?int
100 {
101 return count($this->provider->getData());
102 }
103
104 public function get(): Data
105 {
106 return $this->ui_factory
107 ->table()
108 ->data(
109 $this,
110 $this->lng->txt('cal_ch_ch'),
111 $this->getColumns(),
112 )
113 ->withId(self::class)
114 ->withActions($this->getActions())
115 ->withRequest($this->http_request);
116 }
117
118
122 protected function getActions(): array
123 {
124 $uri_command_handler = $this->data_factory->uri(
125 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
126 ilConsultationHoursGUI::class,
127 'handleBookingTableActions'
128 )
129 );
130
131 [
132 $url_builder,
133 $action_parameter_token,
134 $row_id_token
135 ] =
136 (new URLBuilder($uri_command_handler))->acquireParameters(
137 [self::TABLE_NS],
138 self::ACTION_TOKEN,
139 self::ID_TOKEN
140 );
141
142 return [
143 'edit' => $this->ui_factory->table()->action()->standard(
144 $this->lng->txt('edit'),
145 $url_builder->withParameter($action_parameter_token, 'edit'),
146 $row_id_token
147 ),
148 'searchUsersForAppointments' => $this->ui_factory->table()->action()->standard(
149 $this->lng->txt('cal_ch_assign_participants'),
150 $url_builder->withParameter($action_parameter_token, 'searchUsersForAppointments'),
151 $row_id_token
152 ),
153 'confirmCancelBooking' => $this->ui_factory->table()->action()->single(
154 $this->lng->txt('cal_ch_cancel_booking'),
155 $url_builder->withParameter($action_parameter_token, 'confirmCancelBooking'),
156 $row_id_token
157 )->withAsync(true),
158 'confirmDeleteBooking' => $this->ui_factory->table()->action()->single(
159 $this->lng->txt('cal_ch_delete_booking'),
160 $url_builder->withParameter($action_parameter_token, 'confirmDeleteBooking'),
161 $row_id_token
162 )->withAsync(true),
163 'confirmDeleteAppointments' => $this->ui_factory->table()->action()->standard(
164 $this->lng->txt('delete'),
165 $url_builder->withParameter($action_parameter_token, 'confirmDeleteAppointments'),
166 $row_id_token
167 )->withAsync(true),
168 'sendMail' => $this->ui_factory->table()->action()->standard(
169 $this->lng->txt('cal_ch_send_mail'),
170 $url_builder->withParameter($action_parameter_token, 'sendMail'),
171 $row_id_token
172 )
173 ];
174 }
175
179 protected function getColumns(): array
180 {
181 if ($this->user->getTimeFormat() === \ilCalendarSettings::TIME_FORMAT_12) {
182 $format = $this->data_factory->dateFormat()->withTime12($this->user->getDateFormat());
183 } else {
184 $format = $this->data_factory->dateFormat()->withTime24($this->user->getDateFormat());
185 }
186
187 return [
188 'booking_start' => $this->ui_factory
189 ->table()
190 ->column()
191 ->date($this->lng->txt('cal_ch_booking_start'), $format)
192 ->withIsSortable(true),
193 'booking_duration' => $this->ui_factory
194 ->table()
195 ->column()
196 ->number($this->lng->txt('cal_ch_minutes'))
197 ->withIsSortable(true),
198 'booking_title' => $this->ui_factory
199 ->table()
200 ->column()
201 ->text($this->lng->txt('title'))
202 ->withIsSortable(true),
203 'booking_participant' => $this->ui_factory
204 ->table()
205 ->column()
206 ->linkListing($this->lng->txt('cal_ch_booking_participants')),
207 'booking_comment' => $this->ui_factory
208 ->table()
209 ->column()
210 ->linkListing($this->lng->txt('cal_ch_booking_col_comments')),
211 'booking_location' => $this->ui_factory
212 ->table()
213 ->column()
214 ->linkListing($this->lng->txt('cal_ch_target_object'))
215 ];
216
217 }
218
219 public function render(): string
220 {
221 return $this->ui_renderer->render(
222 [
223 $this->get()
224 ]
225 );
226 }
227
228}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
readonly ServerRequestInterface $http_request
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
Consultation hours editor.
Class ilCtrl provides processing control methods.
language handling
User class.
buildDataRow(string $id, array $record)
This describes a Data Table.
Definition: Data.php:31
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...
global $DIC
Definition: shib_login.php:26