aboutsummaryrefslogtreecommitdiff
path: root/templates/sidebar/clipboard-area.php
blob: 6aa036b30343d52a9323c94c9624d55250963220 (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
<form method="post">
    <?= CSRFProtection::tokenTag() ?>
    <div>
        <select name="selected_clipboard_id" class="clipboard-selector"
                <?= $clipboards ? '' : 'disabled="disabled"' ?>>
            <? if ($clipboards): ?>
                <? foreach ($clipboards as $clipboard): ?>
                    <option value="<?= htmlReady($clipboard->id) ?>"
                            <?= $clipboard->id == $selected_clipboard_id
                              ? 'selected="selected"'
                              : '' ?>>
                        <?= htmlReady($clipboard->name) ?>
                    </option>
                <? endforeach ?>
            <? endif ?>
        </select>
        <? if (!$readonly): ?>

            <input class="clipboard-name invisible" type="text" name="clipboard_name" value="">

            <?= Icon::create('edit', 'clickable')->asImg(
                '20px',
                [
                    'class' => 'middle clipboard-edit-button'
                           . (
                               $clipboards ? '' : ' invisible'
                           ),
                    'onClick' => "STUDIP.Clipboard.toggleEditButtons('"
                             . htmlReady($clipboard_widget_id)
                             . "');"
                ]
            ) ?>

            <?= Icon::create('accept', 'clickable')->asImg(
                '20px',
                [
                    'class' => 'middle clipboard-edit-accept invisible',
                    'onClick' => "STUDIP.Clipboard.rename(
                        {
                            'clipboard_id': '" . htmlReady($selected_clipboard_id) ."',
                            'widget_id': '" . htmlReady($clipboard_widget_id) . "'
                        });"
                ]
            ) ?>

            <?= Icon::create('decline', 'clickable')->asImg(
                '20px',
                [
                    'class' => 'middle clipboard-edit-cancel invisible',
                    'onClick' => "STUDIP.Clipboard.toggleEditButtons('"
                             . htmlReady($clipboard_widget_id)
                             . "');"
                ]
            ) ?>

            <?= Icon::create('trash', 'clickable')->asImg(
                '20px',
                [
                    'class' => 'middle clipboard-remove-button'
                           . (
                               $clipboards ? '' : ' invisible'
                           )
                ]
            ) ?>
        <? endif ?>
    </div>
    <div class="clipboard-area-container">
        <? if ($clipboards): ?>
            <? foreach ($clipboards as $clipboard): ?>
                <table id="Clipboard_<?= htmlReady($clipboard->id) ?>"
                       class="clipboard-area <?= $clipboard->id != $selected_clipboard_id
                                               ? 'invisible'
                                               : '' ?>"
                       data-id="<?= htmlReady($clipboard->id) ?>">
                    <? $items = $clipboard->getContent(false) ?>
                    <? if ($items): ?>
                        <? foreach ($items as $item): ?>
                            <?
                            $checkbox_id = sprintf(
                                'item_%1$s_%2$s_%3$s',
                                $clipboard->id,
                                $item['range_type'],
                                $item['range_id']
                            )
                            ?>
                            <? if ($special_item_template): ?>
                                <?= $this->render_partial(
                                    $special_item_template,
                                    [
                                        'item' => $item,
                                        'draggable_items' => $draggable_items,
                                        'readonly' => $readonly,
                                        'checkbox_id' => $checkbox_id
                                    ]
                                ) ?>
                            <? else: ?>
                                <tr class="clipboard-item <?= $draggable_items
                                                            ? 'draggable'
                                                            : '' ?>"
                                    data-range_id="<?= htmlReady($item['range_id']) ?>">
                                    <td class="item-name">
                                        <label>
                                            <input type="checkbox"
                                                   name="selected_clipboard_items[]"
                                                   title="<?= _('Diesen Eintrag auswählen.') ?>"
                                                   value="<?= htmlReady($item['id']) ?>"
                                                   <?= in_array($item['id'], $selected_clipboard_items)
                                                     ? 'checked="checked"'
                                                     : (!$selected_clipboard_items
                                                      ? 'checked="checked"'
                                                      : '') ?>
                                                   >
                                            <?= htmlReady($item['name']) ?>
                                        </label>
                                    </td>
                                    <? if (!$readonly): ?>
                                        <td class="item-actions">
                                        <?= Icon::create('trash', 'clickable')->asImg(
                                            '16px',
                                            [
                                                'class' => 'text-bottom clipboard-item-remove-button'
                                            ]
                                        ) ?>
                                        </td>
                                    <? endif ?>
                                </tr>
                            <? endif ?>
                        <? endforeach ?>
                    <? endif ?>
                    <tr class="empty-clipboard-message <?= $items ? 'invisible' : '' ?>">
                        <td>
                        <?= htmlReady($empty_clipboard_string) ?>
                        </td>
                    </tr>
                    <? if ($special_item_template): ?>
                        <?= $this->render_partial(
                            $special_item_template,
                            [
                                'item' => null,
                                'draggable_items' => $draggable_items
                            ]
                        ) ?>
                    <? else: ?>
                        <tr class="clipboard-item <?= $draggable_items
                                                    ? 'draggable'
                                                    : ''
                                                  ?> clipboard-item-template invisible"
                            data-range_id="">
                            <td class="item-name">
                                <input type="checkbox"
                                       name="selected_clipboard_items[]"
                                       value=""
                                       class="item-id">
                            </td>
                            <? if (!$readonly): ?>
                                <td class="item-actions">
                                    <?= Icon::create('trash', 'clickable')->asImg(
                                        '16px',
                                        [
                                            'class' => 'text-bottom clipboard-item-remove-button'
                                        ]
                                    ) ?>
                                </td>
                            <? endif ?>
                        </tr>
                    <? endif ?>
                </table>
            <? endforeach ?>
        <? endif ?>
        <table id="Clipboard_CLIPBOARD_ID"
               class="clipboard-area clipboard-template invisible"
               data-id="CLIPBOARD_ID">
            <tr class="empty-clipboard-message">
                <td>
                <?= htmlReady($empty_clipboard_string) ?>
                </td>
            </tr>
            <? if ($special_item_template): ?>
                <?= $this->render_partial(
                    $special_item_template,
                    [
                        'item' => null,
                        'draggable_items' => $draggable_items
                    ]
                ) ?>
            <? else: ?>
                <tr class="clipboard-item <?= $draggable_items
                                            ? 'draggable'
                                            : ''
                                          ?> clipboard-item-template invisible"
                    data-range_id="">
                    <td>
                        <input type="checkbox"
                               name="clipboard_selected_items[]"
                               value="">
                    </td>
                    <td>
                        <?= Icon::create('trash', 'clickable')->asImg(
                            '16px',
                            [
                                'class' => 'text-bottom clipboard-item-remove-button'
                            ]
                        ) ?>
                    </td>
                </tr>
            <? endif ?>
        </table>
    </div>
    <? if ($readonly): ?>
        <?= \Studip\Button::create(
            $apply_button_title,
            'clipboard_update_session_special_action',
            [
                'class' => 'apply-button'
            ]
        ) ?>
    <? endif ?>
</form>