aboutsummaryrefslogtreecommitdiff
path: root/app/views/oer/mymaterial/edit.php
blob: 38fb5b6f6df8346b4f4912d5ebd4d6a562360595 (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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<?php
/**
 * @var Oer_MymaterialController $controller
 * @var OERMaterial $material
 * @var string $usersearch
 * @var string $tagsearch
 */
?>
<form action="<?= $controller->edit($material->isNew() ? '' : $material) ?>"
      method="post"
      class="default"
      onsubmit="$(window).off('beforeunload')"
      data-secure
      enctype="multipart/form-data">
    <?= CSRFProtection::tokenTag() ?>
    <div class="oercampus_editmaterial">
        <fieldset>
            <legend><?= _('Grunddaten') ?></legend>

            <label>
                <span class="required"><?= _('Name') ?></span>
                <input type="text"
                       name="data[name]"
                       class="oername"
                       required
                       value="<?= htmlReady($material['name'] ?: $template['name'] ?? '') ?>"
                       @keyup="editName"
                       maxlength="64">
            </label>


            <div>
                <?= _('Vorschau') ?>
            </div>

            <div class="hgroup" @drop.prevent="dropImage">
                <label for="oer_logo_uploader">
                    <article class="contentbox" :title="name">
                        <header>
                            <h1>
                                <studip-icon shape="file"
                                             class="text-bottom"></studip-icon>
                                <div class="title">{{ name }}</div>
                            </h1>
                        </header>
                        <div class="image"
                             :style="{
                             backgroundImage: logo_url ? `url(${logo_url})` : null,
                             backgroundSize: customlogo ? null : '60% auto'}"></div>
                    </article>
                </label>

                <div>
                    <label class="file-upload logo_file"
                           data-oldurl="<?= htmlReady(!empty($_SESSION['NEW_OER']['image_tmp_name']) ? URLHelper::getURL("dispatch.php/oer/mymaterial/show_tmp_image") : $material->getLogoURL()) ?>"
                           data-customlogo="<?= !empty($_SESSION['NEW_OER']['image_tmp_name']) || $material['front_image_content_type'] ? 1 : 0 ?>">
                        <?= _('Vorschau-Bilddatei (optional)') ?>
                        <input type="file"
                               name="image"
                               id="oer_logo_uploader"
                               accept="image/*"
                               @change="editImage">
                    </label>

                    <? if ($material['front_image_content_type']) : ?>
                        <label>
                            <input type="checkbox" name="delete_front_image" value="1">
                            <?= _('Vorschaubild löschen') ?>
                        </label>
                    <? endif ?>
                </div>

            </div>




            <? if (empty($_SESSION['NEW_OER']['tmp_name'])) : ?>
                <label class="file drag-and-drop"
                       data-filename="<?= htmlReady($material['filename']) ?>"
                       data-filesize="<?= htmlReady(!$material->isNew() && file_exists($material->getFilePath()) ? filesize($material->getFilePath()) : "") ?>"
                       @drop.prevent="dropFile">
                    <?= _('Datei (gerne auch eine ZIP-Datei) auswählen') ?>
                    <input type="file" name="file" id="oer_file" @change="editFile">
                    <div v-if="filename">
                        <span>{{ filename }}</span>
                        <span>{{ filesize }}</span>
                    </div>
                </label>
            <? endif ?>

            <label>
                <?= _('Beschreibung') ?>
                <textarea
                        name="data[description]"><?= htmlReady($material['description'] ?: $template['description'] ?? '') ?></textarea>
            </label>

            <label>
                <input type="hidden" name="data[draft]" value="0">
                <input type="checkbox" name="data[draft]" value="1"<?= $material['draft'] ? " checked" : "" ?>>
                <?= _('Entwurf (nicht veröffentlicht)') ?>
            </label>

            <label>
                <?= _('Kategorie') ?>
                <select name="data[category]">
                    <? if ($material->isNew()) : ?>
                        <option value="auto"><?= _('Automatisch erkennen') ?></option>
                    <? endif ?>
                    <option value="audio"<?= $material['category'] === "audio" ? " selected" : "" ?>>
                        <?= _('Audio') ?>
                    </option>
                    <option value="video"<?= $material['category'] === "video" ? " selected" : "" ?>>
                        <?= _('Video') ?>
                    </option>
                    <option value="presentation"<?= $material['category'] === "presentation" ? " selected" : "" ?>>
                        <?= _('Folien') ?>
                    </option>
                    <option value="elearning"<?= $material['category'] === "elearning" ? " selected" : "" ?>>
                        <?= _('Lernmodule') ?>
                    </option>
                    <option value=""<?= !$material['category'] && !$material->isNew() ? " selected" : "" ?>
                            title="<?= _('Fehlt eine Kategorie? Kein Problem, arbeiten Sie stattdessen mit Schlagwörtern. Die sind viel flexibler.') ?>">
                        <?= _('Ohne Kategorie') ?>
                    </option>
                </select>
            </label>

            <label>
                <?= _('Vorschau-URL (optional)') ?>
                <input type="url" name="data[player_url]" pattern="^https?://.*"
                       value="<?= htmlReady($material['player_url'] ?: $template['player_url'] ?? '') ?>">
            </label>

            <? if (!$material->isNew()) : ?>
                <div>
                    <h4><?= _('Autoren') ?></h4>
                    <ul class="clean autoren<?= count($material->users) > 1 ? " multiple" : "" ?>">
                        <? foreach ($material->users as $materialuser) : ?>
                            <li>
                                <? if ($materialuser['external_contact']) : ?>
                                    <? $user = $materialuser['oeruser'] ?>
                                    <? $image = $user['avatar'] ?>
                                    <label>
                                        <? if (count($material->users) > 1) : ?>
                                            <input type="checkbox" name="remove_users[]"
                                                   value="1_<?= htmlReady($user->getId()) ?>">
                                        <? endif ?>
                                        <div>
                                            <span class="avatar" style="background-image: url('<?= $image ?>');"></span>
                                            <span class="author_name">
                                            <?= htmlReady($user['name']) ?>
                                        </span>
                                            <? if (count($material->users) > 1) : ?>
                                                <?= Icon::create('trash')->asImg(['class' => 'text-bottom', 'title' => _('Person als Autor entfernen.')]) ?>
                                            <? endif ?>
                                        </div>
                                    </label>
                                <? else : ?>
                                    <? $user = User::find($materialuser['user_id']) ?>
                                    <? $image = Avatar::getAvatar($materialuser['user_id'])->getURL(Avatar::SMALL) ?>
                                    <label>
                                        <? if (count($material->users) > 1) : ?>
                                            <input type="checkbox" name="remove_users[]"
                                                   value="0_<?= htmlReady($user->getId()) ?>">
                                        <? endif ?>
                                        <div>
                                            <span class="avatar" style="background-image: url('<?= $image ?>');"></span>
                                            <span class="author_name">
                                                <?= htmlReady($user ? $user->getFullName() : _('unbekannt')) ?>
                                            </span>
                                            <? if (count($material->users) > 1) : ?>
                                                <?= Icon::create('trash')->asImg(['class' => 'text-bottom', 'title' => _('Person als Autor/Autorin entfernen.')]) ?>
                                            <? endif ?>
                                        </div>
                                    </label>
                                <? endif ?>
                            </li>
                        <? endforeach ?>
                        <li>
                            <quicksearch name="new_user"
                                         searchtype="<?= htmlReady($usersearch) ?>"
                                         placeholder="<?= _('Person hinzufügen') ?>"></quicksearch>
                        </li>
                    </ul>
                </div>
            <? endif ?>

            <div class="oer_tags_container">
                <?= _('Themen (am besten mindestens 5)') ?>
                <?
                $tags = [];
                foreach ($material->getTopics() as $tag) {
                    $tags[] = $tag['name'];
                }
                if (!empty($template['tags'])) {
                    foreach ((array)$template['tags'] as $tag) {
                        $tags[] = $tag;
                    }
                }
                ?>

                <ul class="clean oer_tags" data-defaulttags="<?= htmlReady(json_encode($tags)) ?>">
                    <li v-for="(tag, index) in displayTags" :key="`tag-${index}`">
                        #
                        <quicksearch name="tags[]"
                                     searchtype="<?= htmlReady($tagsearch) ?>"
                                     v-model="tag"
                                     :autocomplete="true"
                                     :keep-value="true"
                        ></quicksearch>
                        <button class="as-link"
                           @click.prevent="removeTag(index)"
                           title="<?= _('Thema aus der Liste streichen') ?>"
                        >
                            <studip-icon shape="trash" class="text-bottom"></studip-icon>
                        </button>

                    </li>
                </ul>
                <a href="#" @click.prevent="addTag">
                    <studip-icon shape="add" class="text-bottom"></studip-icon>
                    <?= _('Thema hinzufügen') ?>
                </a>
            </div>

            <div class="level_filter" style="margin-top: 13px; max-width: 682px;">
                <?= _('Niveau') ?>

                <input type="hidden" id="difficulty_start" name="data[difficulty_start]"
                       value="<?= htmlReady($material['difficulty_start']) ?>">
                <input type="hidden" id="difficulty_end" name="data[difficulty_end]"
                       value="<?= htmlReady($material['difficulty_end']) ?>">

                <div class="level_labels">
                    <div><?= _('Leicht') ?></div>
                    <div><?= _('Schwer') ?></div>
                </div>
                <div style="display: flex; justify-content: space-between;">
                    <? for ($i = 1; $i <= 12; $i++) : ?>
                        <div><?= ($i < 10 ? "&nbsp;" : "") . $i ?></div>
                    <? endfor ?>
                </div>
                <div id="difficulty_slider_edit" style="margin-left: 5px; margin-right: 9px;"></div>
            </div>

            <? if (!empty($template['module_id'])) : ?>
                <input type="hidden"
                       name="module_id"
                       value="<?= htmlReady($template['module_id']) ?>">
            <? endif ?>

            <? if (Config::get()->OERCAMPUS_ENABLE_TWILLO && TwilloConnector::getTwilloUserID()) : ?>
                <input type="hidden" name="publish_on_twillo" value="0">
                <label style="margin-top: 20px;">
                    <input type="checkbox"
                           name="publish_on_twillo"
                           value="1"<?= $material['published_id_on_twillo'] ? " checked" : "" ?>>
                    <?= _('Auf twillo.de veröffentlichen') ?>
                </label>
            <? endif ?>
        </fieldset>

        <? if (!Config::get()->OER_DISABLE_LICENSE) : ?>
            <? $license = $material->isNew()
                ? License::findDefault()
                : $material->license;
            ?>
            <fieldset class="oer_license_selector">
                <legend><?= _('Lizenz') ?></legend>
                <?=
                    _('Ich erkläre mich bereit, dass meine Lernmaterialien unter der angegebenen Lizenz an alle Nutzenden freigegeben werden. Ich bestätige zudem, dass ich das Recht habe, diese Dateien frei zu veröffentlichen, weil entweder ich selbst sie angefertigt habe, oder sie von anderen Quellen mit kompatibler Lizenz stammen.')
                ?>

                <div>
                    <select class="licenses_selector" name="data[license_identifier]">
                        <? foreach (License::findBySQL("1 ORDER BY name ASC") as $l) : ?>
                        <option value="<?= htmlReady($l->id) ?>" <?= $l->id === $license->id ? " selected" : "" ?>>
                            <?= htmlReady($l['name']) ?>
                        </option>
                        <? endforeach ?>
                    </select>
                </div>
            </fieldset>

        <? endif ?>
        <? if (!empty($template['redirect_url'])) : ?>
            <input type="hidden"
                   name="redirect_url"
                   value="<?= htmlReady($template['redirect_url']) ?>">
        <? endif ?>
    </div>

    <div data-dialog-button>
        <?= \Studip\Button::create($material->isNew() ? _('Hochladen') : _('Speichern'), "save") ?>
    </div>
</form>