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;
29use ilObjUser;
30use ILIAS\Data\Factory as DataFactory;
32
34{
35 public const string COL_ID = 'id';
36 public const string COL_NAME = 'name';
37 public const string COL_TYPE = 'type';
38 public const string COL_SIZE = 'size';
39 public const string COL_DATE = 'date';
40
41 public const string ACTION_DOWNLOAD = 'downloadExportFile';
42 public const string ACTION_DELETE = 'confirmDeleteExportFile';
43
44 public function __construct(
45 protected DataRetrieval $data_retrieval,
46 protected ilLanguage $lng,
47 protected UIFactory $ui_factory,
48 protected HTTP $http,
49 protected ilObjUser $user,
50 protected DataFactory $data_factory
51 ) {
52 }
53
54 public function get(
55 URLBuilder $url_builder,
56 URLBuilderToken $id_token,
57 URLBuilderToken $action_token
58 ): DataTable {
59 $date_format = $this->user->getDateFormat();
60 if ($this->user->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_24) {
61 $date_format = $this->data_factory->dateFormat()->withTime24($date_format);
62 } else {
63 $date_format = $this->data_factory->dateFormat()->withTime12($date_format);
64 }
65
66 $columns = [];
67 $columns[self::COL_TYPE] = $this->ui_factory->table()->column()->text(
68 $this->lng->txt('type')
69 )->withIsSortable(true);
70 $columns[self::COL_SIZE] = $this->ui_factory->table()->column()->text(
71 $this->lng->txt('ps_size')
72 )->withIsSortable(true);
73 $columns[self::COL_DATE] = $this->ui_factory->table()->column()->date(
74 $this->lng->txt('date'),
75 $date_format
76 )->withIsSortable(true);
77
78 $actions = [];
79 $actions[self::ACTION_DOWNLOAD] = $this->ui_factory->table()->action()->single(
80 $this->lng->txt('download'),
81 $url_builder->withParameter($action_token, self::ACTION_DOWNLOAD),
82 $id_token
83 );
84 $actions[self::ACTION_DELETE] = $this->ui_factory->table()->action()->standard(
85 $this->lng->txt('delete'),
86 $url_builder->withParameter($action_token, self::ACTION_DELETE),
87 $id_token
88 );
89
90 return $this->ui_factory->table()->data(
91 $this->data_retrieval,
92 $this->lng->txt('ps_export_files'),
93 $columns
94 )->withActions($actions)->withRequest($this->http->request());
95 }
96}
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
__construct(protected DataRetrieval $data_retrieval, protected ilLanguage $lng, protected UIFactory $ui_factory, protected HTTP $http, protected ilObjUser $user, protected DataFactory $data_factory)
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