ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
TableBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\UI\Factory as UIFactory;
24use ILIAS\UI\Component\Table\Data as DataTable;
25use ilLanguage;
26use ILIAS\HTTP\Services as HTTP;
30use ilObjUser;
31use ILIAS\Data\Factory as DataFactory;
33
35{
36 public const string NAME_COLUMN = 'name';
37 public const string OWNER_COLUMN = 'owner';
38 public const string APPOINTMENTS_COUNT_COLUMN = 'appointments_count';
39 public const string CREATED_ON_COLUMN = 'created_on';
40 public const string ACCEPT_INVITATION_ACTION = 'acceptShared';
41 public const string DECLINE_INVITATION_ACTION = 'declineShared';
42
43 public function __construct(
44 protected DataRetrieval $data_retrieval,
45 protected ilLanguage $lng,
46 protected UIFactory $ui_factory,
47 protected HTTP $http,
48 protected ilObjUser $user,
49 protected DataFactory $data_factory
50 ) {
51 }
52
53 public function get(
54 URLBuilder $url_builder,
55 URLBuilderToken $id_token,
56 URLBuilderToken $action_token
57 ): DataTable {
58 $date_format = $this->user->getDateFormat();
59 if ($this->user->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_24) {
60 $date_format = $this->data_factory->dateFormat()->withTime24($date_format);
61 } else {
62 $date_format = $this->data_factory->dateFormat()->withTime12($date_format);
63 }
64
65 $columns = [];
66 $columns[self::NAME_COLUMN] = $this->ui_factory->table()->column()->text(
67 $this->lng->txt('name')
68 )->withIsSortable(true);
69 $columns[self::OWNER_COLUMN] = $this->ui_factory->table()->column()->text(
70 $this->lng->txt('owner')
71 )->withIsSortable(true);
72 $columns[self::APPOINTMENTS_COUNT_COLUMN] = $this->ui_factory->table()->column()->number(
73 $this->lng->txt('cal_apps')
74 )->withIsSortable(true);
75 $columns[self::CREATED_ON_COLUMN] = $this->ui_factory->table()->column()->date(
76 $this->lng->txt('create_date'),
77 $date_format
78 )->withIsSortable(true);
79
80 $actions = [];
81 $actions[self::ACCEPT_INVITATION_ACTION] = $this->ui_factory->table()->action()->standard(
82 $this->lng->txt('cal_share_accept'),
83 $url_builder->withParameter($action_token, self::ACCEPT_INVITATION_ACTION),
84 $id_token
85 );
86 $actions[self::DECLINE_INVITATION_ACTION] = $this->ui_factory->table()->action()->standard(
87 $this->lng->txt('cal_share_decline'),
88 $url_builder->withParameter($action_token, self::DECLINE_INVITATION_ACTION),
89 $id_token
90 );
91
92 return $this->ui_factory->table()->data(
93 $this->data_retrieval,
94 $this->lng->txt('cal_shared_calendars'),
95 $columns
96 )->withActions($actions)->withRequest($this->http->request());
97 }
98}
__construct(protected DataRetrieval $data_retrieval, protected ilLanguage $lng, protected UIFactory $ui_factory, protected HTTP $http, protected ilObjUser $user, protected DataFactory $data_factory)
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
Class Services.
Definition: Services.php:43
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166
Stores all calendar relevant settings.
language handling
User class.
This describes a Data Table.
Definition: Data.php:33
static http()
Fetches the global http state from ILIAS.
global $lng
Definition: privfeed.php:26