aboutsummaryrefslogtreecommitdiff
path: root/app/views/file/choose_file.php
blob: 1b59a9d195092edd98be458a678eea4a7f47047f (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
$options = [];
if (Request::get('from_plugin')) {
    $options['from_plugin'] = Request::get('from_plugin');
}
if (Request::get('to_plugin')) {
    $options['to_plugin'] = Request::get('to_plugin');
}
if (Request::get('to_folder_id')) {
    $options['to_folder_id'] = Request::get('to_folder_id');
}
?>

<div style="text-align: center; margin-bottom: 20px;">
    <?= _('Kopieren nach') ?>
    <?= Icon::create('folder-full', Icon::ROLE_INFO)->asImg(['class' => 'text-bottom']) ?>
    <?= htmlReady($to_folder_name) ?>
</div>

<? if ($filesystemplugin && $filesystemplugin->hasSearch()) : ?>
    <form action="<?= $controller->url_for('file/choose_file/' . $top_folder->parent_id) ?>" class="default" data-dialog style="margin-bottom: 50px;" id="file_search">
    <? foreach ($options as $key => $value) : ?>
        <input type="hidden" name="<?= htmlReady($key) ?>" value="<?= htmlReady($value) ?>">
    <? endforeach; ?>
        <? $request_parameter = Request::getArray('parameter') ?>
        <input type="text" name="search" value="<?= htmlReady(Request::get('search')) ?>"
               placeholder="<?= _('Suche nach ...') ?>" style="max-width: 100%">

    <? foreach ((array) $filesystemplugin->getSearchParameters() as $parameter) : ?>
        <label>
        <? if ($parameter['type'] === 'text'): ?>
            <?= htmlReady($parameter['label']) ?>
            <input type="text" name="parameter[<?= htmlReady($parameter['name']) ?>]"
                   value="<?= htmlReady($request_parameter[$parameter['name']]) ?>"
                   placeholder="<?= htmlReady($parameter['placeholder']) ?>">
        <? elseif ($parameter['type'] === 'select'): ?>
            <?= htmlReady($parameter['label']) ?>
            <select name="parameter[<?= htmlReady($parameter['name']) ?>]">
            <? foreach ($parameter['options'] as $index => $option) : ?>
                <option value="<?= htmlReady($index) ?>" <? if ($index === $request_parameter[$parameter['name']]) echo 'selected'; ?>>
                    <?= htmlReady($option) ?>
                </option>
            <? endforeach; ?>
            </select>
        <? elseif ($parameter['type'] === 'checkbox'): ?>
            <input type="checkbox" name="parameter[<?= htmlReady($parameter['name']) ?>]" value="1"
                   <? if ($request_parameter[$parameter['name']]) echo 'checked'; ?>>
            <?= htmlReady($parameter['label']) ?>
        <? endif; ?>
        </label>
    <? endforeach; ?>
    </form>

<? endif; ?>

<? if ($top_folder): ?>
<table class="default">
    <colgroup>
        <col style="width: 36px;">
        <col>
    </colgroup>
    <thead>
        <tr>
            <th><?= _('Typ') ?></th>
            <th><?= _('Name') ?></th>
        </tr>
    </thead>
<? if ($top_folder->parent_id && ($top_folder->parent_id !== $top_folder->id)) : ?>
    <tbody>
        <tr>
            <td colspan="2">
                <a href="<?= $controller->url_for('file/choose_file/' . $top_folder->parent_id, $options) ?>" title="<?= _('Ein Verzeichnis nach oben wechseln') ?>" data-dialog>
                    <?= _('Ein Verzeichnis nach oben wechseln') ?>
                </a>
            </td>
        </tr>
    </tbody>
<? endif ?>
<? if (count($top_folder->getSubfolders()) + count($top_folder->getFiles()) === 0): ?>
    <tbody>
        <tr>
            <td colspan="2" class="empty">
                <?= _('Dieser Ordner ist leer') ?>
            </td>
        </tr>
    </tbody>
<? else : ?>
    <? if (count($top_folder->getSubfolders()) > 0) : ?>
        <tbody>
        <? foreach ($top_folder->getSubfolders() as $subfolder) : ?>
            <? if (!$subfolder->isVisible($GLOBALS['user']->id)) continue; ?>
            <tr>
                <td class="document-icon" data-sort-value="0">
                <? if ($subfolder->isReadable($GLOBALS['user']->id)) : ?>
                    <a href="<?= $controller->link_for('file/choose_file/' . $subfolder->id, $options) ?>" data-dialog>
                <? endif ?>
                <? if (!empty($is_empty)): ?>
                    <?= Icon::create('folder-empty')->asImg(24) ?>
                <? else: ?>
                    <?= Icon::create('folder-full')->asImg(24) ?>
                <? endif; ?>
                <? if ($subfolder->isReadable($GLOBALS['user']->id)) : ?>
                    </a>
                <? endif ?>
                </td>
                <td>
                <? if ($subfolder->isReadable($GLOBALS['user']->id)) : ?>
                    <a href="<?= $controller->link_for('file/choose_file/' . $subfolder->id, $options) ?>" data-dialog>
                        <?= htmlReady($subfolder->name) ?>
                    </a>
                <? else: ?>
                    <?= htmlReady($subfolder->name) ?>
                <? endif ?>
                <? if ($subfolder->description): ?>
                    <small class="responsive-hidden"><?= htmlReady($subfolder->description) ?></small>
                <? endif; ?>
                </td>
            </tr>
        <? endforeach; ?>
        </tbody>
    <? endif ?>
    <? if (count($top_folder->getFiles()) > 0) : ?>
        <tbody>
        <? foreach ($top_folder->getFiles() as $file) : ?>
            <tr>
                <td class="document-icon" data-sort-value="1">
                <? if ($file->isDownloadable()): ?>
                    <form action="<?= $controller->link_for('file/choose_file/' . $top_folder->id, $options) ?>" method="post" data-dialog>
                        <input type="hidden" name="file_id" value="<?= htmlReady($file->getId()) ?>">
                        <a href="#" onclick="jQuery(this).closest('form').submit(); return false;">
                            <?= FileManager::getIconForMimeType($file->getMimetype())->asImg(24) ?>
                        </a>
                    </form>
                <? else: ?>
                    <?= FileManager::getIconForMimeType($file->getMimetype(), Icon::ROLE_INACTIVE)->asImg(24) ?>
                <? endif ?>
                </td>
                <td>
                <? if ($file->isDownloadable()) : ?>
                    <form action="<?= $controller->link_for('file/choose_file/' . $top_folder->id, $options) ?>" method="post" data-dialog>
                        <input type="hidden" name="file_id" value="<?= htmlReady($file->getId()) ?>">
                        <a href="#" onclick="jQuery(this).closest('form').submit(); return false;">
                            <?= htmlReady($file->getFilename()) ?>
                            <? if ($file->getDescription()) : ?>
                                <div style="color: grey; font-size: 0.8em;"><?= htmlReady($file->getDescription()) ?></div>
                            <? endif ?>
                        </a>
                    </form>
                <? else: ?>
                    <?= htmlReady($file->getFilename()) ?>
                    <? if ($file->getDescription()): ?>
                        <div style="color: grey; font-size: 0.8em;"><?= htmlReady($file->getDescription()) ?></div>
                    <? endif ?>
                <? endif; ?>
                </td>
            </tr>
        <? endforeach; ?>
        </tbody>
    <? endif ?>
<? endif ?>
</table>
<? endif ?>

<?php
$options = [];
if (Request::get('to_plugin')) {
    $options['to_plugin'] = Request::get('to_plugin');
}
?>
<footer data-dialog-button>
    <?= Studip\LinkButton::create(
        _('Zurück'),
        $controller->action_url('add_files_window/' . Request::get('to_folder_id'), $options),
        ['data-dialog' => 1]
    ) ?>
<? if ($filesystemplugin && $filesystemplugin->hasSearch()) : ?>
    <?= Studip\Button::create(
        _('Suche starten'),
        'startsearch',
        ['form' => 'file_search']
    ) ?>
<? endif ?>
</footer>