19 declare(strict_types=1);
48 public const HOME =
'HOME';
50 private \ILIAS\ResourceStorage\Services
$irss;
69 $this->data_factory = new \ILIAS\Data\Factory();
70 $this->ui_renderer = $DIC->ui()->renderer();
71 $this->
ctrl = $DIC->ctrl();
72 $this->actions = $this->action_builder->getActionProvider()->getSingleActions(
80 if ($this->request->canUserAdministrate()) {
81 foreach ($this->action_builder->getActionProvider()->getTopActions() as $top_action) {
82 if ($top_action->getAction() instanceof
Signal) {
83 $button = $this->ui_factory->button()->shy(
84 $top_action->getLabel(),
86 )->withOnClick($top_action->getAction());
88 $button = $this->ui_factory->button()->shy(
89 $top_action->getLabel(),
90 (string) $top_action->getAction()
97 return $this->ui_factory->dropdown()->standard($buttons);
102 $get_action =
function (
string $path_inside_zip):
string {
103 $this->
ctrl->setParameterByClass(
104 \ilContainerResourceGUI::class,
106 $this->
hash($path_inside_zip)
108 return $this->
ctrl->getLinkTargetByClass(
109 \ilContainerResourceGUI::class,
116 $links[] = $this->ui_factory->link()->standard(
117 $this->
language->txt(
'home_directory'),
122 if ($this->request->getPath() !==
'./') {
123 $directories = array_filter(
124 explode(
'/', $this->request->getPath()),
125 static fn(
string $part) => $part !==
'' 128 foreach ($directories as $i => $directory) {
129 $path_inside_zip = rtrim(
130 implode(
'/', array_slice($directories, 0, $i + 1)),
133 $links[] = $this->ui_factory->link()->standard(
135 $get_action($path_inside_zip)
139 yield $this->ui_factory->divider()->horizontal();
141 yield $this->ui_factory->breadcrumbs($links);
149 yield $this->ui_factory->panel()->standard(
150 $this->
language->txt(
'title_manage_container'),
152 iterator_to_array($this->upload_builder->getDropZone()),
155 )->withActions($dropdown);
165 return $this->ui_factory->table()->data(
166 $this->request->getTitle(),
168 self::F_TITLE => $this->ui_factory->table()->column()->text(
170 )->withIsSortable(
true),
171 self::F_SIZE => $this->ui_factory->table()->column()->text(
173 )->withIsSortable(
true),
174 self::F_MODIFICATION_DATE => $this->ui_factory->table()->column()->date(
175 $this->
language->txt(self::F_MODIFICATION_DATE),
176 $this->data_factory->dateFormat()->germanLong()
177 )->withIsSortable(
true),
178 self::F_TYPE => $this->ui_factory->table()->column()->text(
180 )->withIsSortable(
true),
184 $this->
http->request()
186 $this->action_builder->getActions()
188 new Range(0, $this->request->getItemsPerPage())
194 array $visible_column_ids,
198 ?array $additional_parameters
204 $entries = $this->data_provider->getEntries();
206 $entries = array_slice(
212 foreach ($entries as $entry) {
213 $is_dir = $entry instanceof \ILIAS\components\ResourceStorage\Container\Wrapper\Dir;
214 $path_inside_zip = $entry->getPathInsideZIP();
216 $entry_name = trim((
string) $entry,
'/');
219 $this->
ctrl->setParameterByClass(
220 \ilContainerResourceGUI::class,
222 $this->
hash($path_inside_zip)
225 $action = $this->
ctrl->getLinkTargetByClass(
226 \ilContainerResourceGUI::class,
231 ? $this->ui_renderer->render(
232 $this->ui_factory->link()->standard($entry_name, $action)
237 $this->
hash($entry->getPathInsideZIP()),
239 self::F_TITLE => $title,
240 self::F_SIZE => $is_dir ?
'' : $this->formatSize($entry->getSize()),
241 self::F_TYPE => $is_dir ?
'' : $entry->getMimeType(),
242 self::F_MODIFICATION_DATE => $entry->getModificationDate(),
246 foreach ($this->actions as $key => $single_action) {
247 if ($is_dir && !$single_action->supportsDirectories()) {
248 $data_row = $data_row->withDisabledAction($key);
251 if ($single_action->getSupportedMimeTypes() !== [
'*']) {
253 $data_row = $data_row->withDisabledAction($key);
255 if (isset($regex_storage[$key])) {
256 $regex = $regex_storage[$key];
258 $mime_type_quoted = [];
259 foreach ($single_action->getSupportedMimeTypes() as $mime_type) {
260 $mime_type_quoted[] = str_replace(
'*',
'.*', preg_quote($mime_type,
'/'));
263 $regex_storage[$key] = $regex = implode(
'|', $mime_type_quoted);
265 if (!preg_match(
"/($regex)/", $entry->getMimeType())) {
266 $data_row = $data_row->withDisabledAction($key);
277 $sort_field = array_keys($order->
get())[0];
278 $sort_direction = $order->
get()[$sort_field];
282 $this->data_provider->getViewRequest()->setPage((
int) round($start / $length, 0, PHP_ROUND_HALF_DOWN));
283 $this->data_provider->getViewRequest()->setItemsPerPage($length);
285 switch ($sort_field .
'_' . $sort_direction) {
298 case self::F_MODIFICATION_DATE .
'_' .
Order::ASC:
301 case self::F_MODIFICATION_DATE .
'_' .
Order::DESC:
315 return $this->data_provider->getTotal();
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...
ILIAS Data Factory $data_factory
ILIAS UI Renderer $ui_renderer
Interface Observer Contains several chained tasks and infos about them.
const F_MODIFICATION_DATE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Both the subject and the direction need to be specified when expressing an order. ...
buildDataRow(string $id, array $record)
const BY_CREATION_DATE_ASC
static http()
Fetches the global http state from ILIAS.
This is how the factory for UI elements looks.
initSortingAndOrdering(Range $range, Order $order)
const BY_CREATION_DATE_DESC
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...
ILIAS ResourceStorage Services $irss
__construct(private Request $request, private Factory $ui_factory, private \ilLanguage $language, private Services $http, private TableDataProvider $data_provider, private ActionBuilder $action_builder, private ViewControlBuilder $view_control_builder, private UploadBuilder $upload_builder)
language()
description: > Example for rendring a language glyph.
A simple class to express a naive range of whole positive numbers.