Changes for page Down- and Upload LaTeX Templates
Last modified by Guido Kracke on 2021/03/18 11:28
From version 4.1
edited by Guido Kracke
on 2019/10/29 17:33
on 2019/10/29 17:33
Change comment:
There is no comment for this version
To version 5.1
edited by Guido Kracke
on 2019/11/28 11:42
on 2019/11/28 11:42
Change comment:
There is no comment for this version
Summary
-
Objects (1 modified, 0 added, 0 removed)
Details
- ExtensionCode.ExtensionClass[0]
-
- Description
-
... ... @@ -52,7 +52,7 @@ 52 52 LaTeX Templates 53 53 </th> 54 54 <td style="border: 1px solid #ddd;padding: 3px"> 55 - <select id="page" name="page" onchange="onTemplates(this.value)"> 55 + <select id="page" name="page" onchange="onTemplates(this.value)" onload="onTemplates(this.value)"> 56 56 """ 57 57 if (LATEX != null) { 58 58 out << "<option" ... ... @@ -79,7 +79,7 @@ 79 79 Upload from Attachment 80 80 </th> 81 81 <td style="border: 1px solid #ddd;padding: 3px"> 82 - <select id="file" name="file" size=1 onchange="onAttachment(this.value)"> 82 + <select id="file" name="file" size=1 onchange="onAttachment(this.value)" onload="onAttachment(this.value)"> 83 83 """ 84 84 if (file == null || file == "") { 85 85 out << "<option selected></option>" ... ... @@ -191,24 +191,27 @@ 191 191 ZipInputStream zip = new ZipInputStream(att.getContentInputStream(), CHARSET) 192 192 ZipEntry entry = zip.getNextEntry() 193 193 while (entry != null) { 194 - Object template = templates.get(entry.getName()) 195 - if (template == null) { 196 - template = skin.newObject(XCLASS) 197 - template.set("path", entry.getName()) 194 + if (!entry.isDirectory()) { 195 + Object template = templates.get(entry.getName()) 196 + if (template == null) { 197 + template = skin.newObject(XCLASS) 198 + template.set("path", entry.getName()) 199 + } 200 + ByteArrayOutputStream bos = new ByteArrayOutputStream() 201 + byte[] buffer = new byte[2048] 202 + int len = zip.read(buffer) 203 + while (len > 0) { 204 + bos.write(buffer, 0, len) 205 + len = zip.read(buffer) 206 + } 207 + bos.close() 208 + template.set("content", bos.toString(CHARSET_NAME)) 198 198 } 199 - ByteArrayOutputStream bos = new ByteArrayOutputStream() 200 - byte[] buffer = new byte[2048] 201 - int len = zip.read(buffer) 202 - while (len > 0) { 203 - bos.write(buffer, 0, len) 204 - len = zip.read(buffer) 205 - } 206 - bos.close() 207 - template.set("content", bos.toString(CHARSET_NAME)) 208 208 entry = zip.getNextEntry() 209 209 } 210 210 zip.close() 211 211 skin.save() 214 + response.sendRedirect(xwiki.getURL(doc.getFullName())) 212 212 } 213 213 } 214 214 {{/groovy}}