aboutsummaryrefslogtreecommitdiff
path: root/app/views/files/flat.php
blob: 6033822a735c01af04e0ca8725d25b5607ec476e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
$show_downloads = in_array(Config::get()->DISPLAY_DOWNLOAD_COUNTER, ['always', 'flat']);
$vue_files = [];
foreach ($files as $file) {
    if ($file->isVisible($GLOBALS['user']->id)) {
        $vue_files[] = FilesystemVueDataManager::getFileVueData($file, $file->getFolderType(), $last_visitdate);
    }
}
$vue_files = array_values(SimpleCollection::createFromArray($vue_files)->orderBy('chdate desc')->toArray());

$topFolder = new StandardFolder();
$vue_topFolder = [
    'description' => $topFolder->getDescriptionTemplate(),
    'additionalColumns' => $topFolder->getAdditionalColumns(),
];
if ($vue_topFolder['description'] instanceof Flexi\Template) {
    $vue_topFolder['description'] = $vue_topFolder['description']->render();
}
$vue_topFolder['buttons'] = '<span class="multibuttons">';
$vue_topFolder['buttons'] .= Studip\Button::create(_('Herunterladen'), 'download', [
    'data-activates-condition' => 'table.documents tr[data-permissions*=d] :checkbox:checked'
]);
if ($topFolder->isWritable($GLOBALS['user']->id)) {
    $vue_topFolder['buttons'] .= Studip\Button::create(_('Verschieben'), 'move', [
        'formaction'  => $controller->url_for('file/choose_destination/move/bulk'),
        'data-dialog' => 'size=auto',
        'data-activates-condition' => 'table.documents tr[data-permissions*=w] :checkbox:checked'
    ]);
}
$vue_topFolder['buttons'] .= Studip\Button::create(_('Kopieren'), 'copy', [
    'formaction'  => $controller->url_for('file/choose_destination/copy/bulk'),
    'data-dialog' => 'size=auto',
    'data-activates-condition' => 'table.documents tr[data-permissions*=r] :checkbox:checked'
]);
if ($topFolder->isWritable($GLOBALS['user']->id)) {
    $vue_topFolder['buttons'] .= Studip\Button::create(_('Löschen'), 'delete', [
        'data-confirm'             => _('Soll die Auswahl wirklich gelöscht werden?'),
        'data-activates-condition' => 'table.documents tr[data-permissions*=w] :checkbox:checked'
    ]);
}
$vue_topFolder['buttons'] .= '</span>';
foreach ($topFolder->getAdditionalActionButtons() as $button) {
    $vue_topFolder['buttons'] .= $button;
}
?>
<form method="post" action="<?= htmlReady($form_action ?? '') ?>">
    <?= CSRFProtection::tokenTag() ?>
    <?= Studip\VueApp::create('FilesTable')
            ->withProps([
                    'allow_filter'  => !empty($enable_table_filter),
                    'files'         => $vue_files,
                    'initial_sort'  => ['sortedBy' => 'chdate', 'sortDirection' => 'desc'],
                    'pagination'    => $pagination_html ?? '',
                    'showdownloads' => $show_downloads,
                    'table_title'   => $table_title ?? '',
                    'topfolder'     => $vue_topFolder,
            ]) ?>
</form>
<?
if (!empty($show_default_sidebar)) {
    if (!empty($enable_table_filter)) {
        $widget = new SidebarWidget();
        $widget->setId('table-view-filter');
        $widget->setTitle(_('Filter'));
        $widget->addElement(new WidgetElement('<div></div>'));
        Sidebar::get()->addWidget($widget);
    }

    $views = new ViewsWidget();
    $views->addLink(
        _('Ordneransicht'),
        $controller->url_for((isset($range_type) ? $range_type . '/' : '') . 'files/index'),
        null,
        [],
        'index'
    );
    $views->addLink(
        _('Alle Dateien'),
        $controller->url_for((isset($range_type) ? $range_type . '/' : '') . 'files/flat'),
        null,
        [],
        'flat'
    )->setActive(true);
    Sidebar::get()->addWidget($views);
}