Изменения документа Создание разделов по шаблону

Редактировал(а) Alexey Semenihin 24.06.2025

От версии 3.1
отредактировано Alexey Semenihin
на 23.04.2025
Изменить комментарий: К данной версии нет комментариев
К версии 2.1
отредактировано Alexey Semenihin
на 23.04.2025
Изменить комментарий: Загрузить новое вложение Инструкция пользователя Xwiki.docx

Сводка

Подробности

Свойства страницы
Содержимое
... ... @@ -1,206 +1,0 @@
1 -{{velocity}}
2 -=== Прикрепите вложения и используйте кнопки для навигации ===
3 -#set($spaceRef = $doc.documentReference.lastSpaceReference.name)
4 -#set($pageName = $doc.documentReference.name)
5 -#set($docFullName = "${spaceRef}.${pageName}")
6 -#set($attachments = $doc.getAttachmentList())
7 -#set($itemsPerPage = 1)
8 -#set($totalPages = ($attachments.size() + $itemsPerPage - 1) / $itemsPerPage)
9 -#set($currentPage = 1)
10 -#if("$!request.page" != "")
11 - #set($currentPage = $mathtool.toInteger($request.page))
12 -#end
13 -#set($startIndex = ($currentPage - 1) * $itemsPerPage)
14 -#set($endIndex = $startIndex + $itemsPerPage - 1)
15 -#if($endIndex >= $attachments.size())
16 - #set($endIndex = $attachments.size() - 1)
17 -#end
18 -{{html}}
19 -<div class="navigation-controls">
20 - #if($attachments && !$attachments.isEmpty())
21 - <!-- Выпадающий список для выбора вложения -->
22 - <div class="attachment-selector">
23 - <label for="attachment-select">Выберите вложение:</label>
24 - <select id="attachment-select">
25 - #foreach($attachment in $attachments)
26 - <option value="$attachment.filename" #if($velocityCount == $currentPage)selected#end>
27 - $attachment.filename
28 - </option>
29 - #end
30 - </select>
31 - </div>
32 - <!-- Пагинация -->
33 - <div class="pagination-controls">
34 - #if($currentPage > 1)
35 - #set($prevPage = $currentPage - 1)
36 - <a href="$doc.getURL('view', "page=${prevPage}")" class="btn btn-primary">Назад</a>
37 - #else
38 - <span class="btn btn-disabled">Назад</span>
39 - #end
40 -
41 - <span class="page-info">Страница $currentPage из $totalPages</span>
42 -
43 - #if($currentPage < $totalPages)
44 - #set($nextPage = $currentPage + 1)
45 - <a href="$doc.getURL('view', "page=${nextPage}")" class="btn btn-primary">Далее</a>
46 - #else
47 - <span class="btn btn-disabled">Далее</span>
48 - #end
49 - </div>
50 - #else
51 - <div class="no-attachments-message">
52 - Нет прикрепленных вложений. Пожалуйста, добавьте файлы для просмотра.
53 - </div>
54 - #end
55 -</div>
56 -{{/html}}
57 -#if($attachments && !$attachments.isEmpty())
58 - #foreach($i in [$startIndex..$endIndex])
59 - #set($attachment = $attachments.get($i))
60 - #set($filename = $attachment.filename)
61 - #set($fileurl = $doc.getAttachmentURL($filename, "download"))
62 - #set($fileExtension = $filename.substring($filename.lastIndexOf('.') + 1).toLowerCase())
63 -
64 - === Документ: $filename ===
65 -
66 - {{html}}
67 - <div class="document-viewer-container" id="document-viewer">
68 - #if($fileExtension == 'pdf')
69 - <!-- PDF Viewer -->
70 - <iframe
71 - id="document-frame"
72 - src="/resources/pdfjs/web/viewer.html?file=${escapetool.url($fileurl)}"
73 - width="100%"
74 - height="600px">
75 - </iframe>
76 - #elseif($fileExtension == 'doc' || $fileExtension == 'docx' || $fileExtension == 'ppt' || $fileExtension == 'pptx' || $fileExtension == 'xls' || $fileExtension == 'xlsx')
77 - <!-- Office Viewer -->
78 - #set($officeViewerUrl = "${doc.getURL('view')}?xpage=office&attachment=${escapetool.url($filename)}")
79 - <iframe
80 - id="document-frame"
81 - src="$officeViewerUrl"
82 - width="100%"
83 - height="600px">
84 - </iframe>
85 - #else
86 - <div class="unsupported-format">
87 - Формат файла (${fileExtension}) не поддерживается для просмотра.
88 - <a href="${fileurl}">Скачать файл</a>
89 - </div>
90 - #end
91 - </div>
92 - {{/html}}
93 - #end
94 -#else
95 - {{html}}
96 - <div class="no-attachments-message">
97 - Нет доступных вложений для отображения.
98 - </div>
99 - {{/html}}
100 -#end
101 -{{html}}
102 -<style>
103 - .navigation-controls {
104 - display: flex;
105 - flex-direction: column;
106 - gap: 15px;
107 - margin-bottom: 20px;
108 - }
109 - .attachment-selector {
110 - display: flex;
111 - align-items: center;
112 - gap: 10px;
113 - }
114 - .attachment-selector select {
115 - padding: 8px;
116 - border-radius: 4px;
117 - min-width: 300px;
118 - }
119 - .document-viewer-container {
120 - margin: 20px 0;
121 - border: 1px solid #eee;
122 - padding: 10px;
123 - background: #f9f9f9;
124 - }
125 - .pagination-controls {
126 - margin: 20px 0;
127 - display: flex;
128 - justify-content: center;
129 - align-items: center;
130 - gap: 20px;
131 - }
132 - .btn {
133 - padding: 8px 16px;
134 - border-radius: 4px;
135 - text-decoration: none;
136 - }
137 - .btn-primary {
138 - background-color: #3366cc;
139 - color: white;
140 - }
141 - .btn-disabled {
142 - background-color: #eee;
143 - color: #999;
144 - cursor: not-allowed;
145 - }
146 - .page-info {
147 - font-weight: bold;
148 - }
149 - .unsupported-format {
150 - padding: 20px;
151 - text-align: center;
152 - color: #666;
153 - }
154 - .no-attachments-message {
155 - padding: 20px;
156 - text-align: center;
157 - color: #666;
158 - font-style: italic;
159 - border: 1px dashed #ccc;
160 - background-color: #f5f5f5;
161 - }
162 -</style>
163 -<script>
164 -//<![CDATA[
165 -document.addEventListener('DOMContentLoaded', function() {
166 - const select = document.getElementById('attachment-select');
167 - const viewerContainer = document.getElementById('document-viewer');
168 -
169 - if (select && viewerContainer) {
170 - select.addEventListener('change', function() {
171 - const filename = this.value;
172 - const fileExtension = filename.split('.').pop().toLowerCase();
173 - const fileurl = "${doc.getURL('download')}" + "/" + encodeURIComponent(filename);
174 - const pdfViewerUrl = "/resources/pdfjs/web/viewer.html?file=" + encodeURIComponent(fileurl);
175 - const baseUrl = "${doc.getURL('view')}";
176 -
177 - let viewerHtml = '';
178 -
179 - if (fileExtension === 'pdf') {
180 - viewerHtml = '<iframe id="document-frame" ' +
181 - 'src="' + pdfViewerUrl + '" ' +
182 - 'width="100%" height="600px"></iframe>';
183 - } else if (['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx'].indexOf(fileExtension) >= 0) {
184 - viewerHtml = '<iframe id="document-frame" ' +
185 - 'src="' + baseUrl + '?xpage=office&attachment=' + encodeURIComponent(filename) + '" ' +
186 - 'width="100%" height="600px"></iframe>';
187 - } else {
188 - viewerHtml = '<div class="unsupported-format">' +
189 - 'Формат файла (' + fileExtension + ') не поддерживается для просмотра. ' +
190 - '<a href="' + fileurl + '">Скачать файл</a></div>';
191 - }
192 -
193 - viewerContainer.innerHTML = viewerHtml;
194 -
195 - // Обновляем заголовок документа
196 - const titleElement = viewerContainer.previousElementSibling;
197 - if (titleElement && titleElement.tagName === 'H3') {
198 - titleElement.textContent = 'Документ: ' + filename;
199 - }
200 - });
201 - }
202 -});
203 -//]]>
204 -</script>
205 -{{/html}}
206 -{{/velocity}}