Changes for page Attachments

Last modified by teamwire005 on 2025/05/06 07:37

From version 8.1
edited by teamwire005
on 2024/12/03 08:27
Change comment: Install extension [org.xwiki.platform:xwiki-platform-attachment-ui/15.10.14]
To version 7.1
edited by teamwire004
on 2024/07/12 13:05
Change comment: Install extension [org.xwiki.platform:xwiki-platform-attachment-ui/15.10.10]

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.teamwire005
1 +XWiki.teamwire004
Content
... ... @@ -10,7 +10,7 @@
10 10   #set ($docAction = $request.get('docAction'))
11 11   #set ($attachmentList = $targetAttachDocument.getAttachmentList())
12 12   #if ($attachmentList && $attachmentList.size() > 0)
13 - #set ($sortedAttachments = $collectiontool.sort($attachmentList, 'date:desc'))
13 + #set ($sortedAttachments = $sorttool.sort($attachmentList, 'date:desc'))
14 14   #set ($lastAttachment = $sortedAttachments.get(0))
15 15   #end
16 16   $response.sendRedirect($targetDocument.getURL($docAction, $escapetool.url({
... ... @@ -47,12 +47,7 @@
47 47   ## Only display the upload form if they have edit permission on targetAttachDocument
48 48   #attachmentPicker_displayUploadForm($targetDocument, $targetAttachDocument, $options)
49 49   #attachmentPicker_displayAttachmentGalleryEmptyValue($targetDocument, $targetAttachDocument, $options, $currentValue)
50 - #if ("$!services.temporaryAttachments" != '')
51 - #set ($unsortedAttachments = $services.temporaryAttachments.listAllAttachments($targetAttachDocument))
52 - #set ($sortedAttachments = $collectiontool.sort($unsortedAttachments, "${options.sortAttachmentsBy}"))
53 - #else
54 - #set ($sortedAttachments = $collectiontool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") )
55 - #end
50 + #set ($sortedAttachments = $sorttool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") )
56 56   #foreach ($attachment in $sortedAttachments)
57 57   #set ($extension = $attachment.getFilename())
58 58   #set ($extension = $extension.substring($mathtool.add($extension.lastIndexOf('.'), 1)).toLowerCase())
... ... @@ -145,12 +145,12 @@
145 145   #if ($attachment.isImage() && $options.displayImage)
146 146   ## We add the version to the query string in order to invalidate the cache when an image attachment is replaced.
147 147   #set ($queryString = $escapetool.url({'version': $attachment.version}))
148 - [[[[image:${attachmentStringReference}||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]]
143 + [[[[image:$attachmentStringReference||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]]
149 149   #else
150 150   * (% class="mime" %){{html wiki=false clean=false}}#mimetypeimg($attachment.getMimeType().toLowerCase() $attachment.getFilename().toLowerCase()){{/html}}(%%) (% class="filename" %)$services.rendering.escape($attachment.getFilename(), 'xwiki/2.1')(% %)
151 151   * v$attachment.getVersion() (#dynamicsize($attachment.longSize))
152 152   * $services.localization.render('core.viewers.attachments.author', [$!{xwiki.getUserName($attachment.author, false)}]) $services.localization.render('core.viewers.attachments.date', [$!{xwiki.formatDate($attachment.date, 'dd/MM/yyyy hh:mm')}])
153 - * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:${attachmentStringReference}||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%)
148 + * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:$attachmentStringReference||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%)
154 154   #end
155 155   #end
156 156  #end
... ... @@ -320,7 +320,7 @@
320 320   #end
321 321   #set ($options = {
322 322   'classname' : ${request.get('classname')},
323 - 'object' : $!{numbertool.toNumber($request.object).intValue()},
318 + 'object' : $!{mathtool.toInteger($request.object)},
324 324   'property' : ${request.property},
325 325   'displayImage' : ${displayImage},
326 326   'docAction' : ${docAction},
... ... @@ -336,7 +336,7 @@
336 336   #set ($cancelLinkName = $services.rendering.escape($services.rendering.escape($services.localization.render("${translationPrefix}.cancel"), 'xwiki/2.1'), 'xwiki/2.1'))
337 337   #set ($cancelLinkTarget = $services.rendering.escape($services.model.serialize($targetDocument), 'xwiki/2.1'))
338 338   (% class="gallery_buttons buttons" %)(((
339 - (% class="buttonwrapper secondary" %)[[$cancelLinkName>>$cancelLinkTarget||class="button secondary" id="attachment-picker-close"]]
334 + (% class="buttonwrapper secondary" %)[[$services.localization.render("${translationPrefix}.cancel")>>$targetDocument||class="button secondary" id="attachment-picker-close"]]
340 340   )))
341 341  #end
342 342  {{/velocity}}
XWiki.WikiMacroClass[0]
Macro code
... ... @@ -3,6 +3,7 @@
3 3  $xwiki.ssfx.use('js/xwiki/widgets/modalPopup.css', true)##
4 4  $xwiki.jsx.use($xcontext.macro.doc.fullName)##
5 5  $xwiki.ssx.use($xcontext.macro.doc.fullName)##
6 +$xwiki.jsfx.use('js/scriptaculous/builder.js')##
6 6  ## Integrates the optional Lightbox widget (from http://extensions.xwiki.org/xwiki/bin/view/Extension/Lightbox+Application )
7 7  #if ($xwiki.exists('XWiki.Lightbox'))
8 8   $xwiki.jsx.use('XWiki.Lightbox')
... ... @@ -31,7 +31,7 @@
31 31  #end
32 32  #set ($classname = "$!{xcontext.macro.params.classname}")
33 33  #set ($property = "$!{xcontext.macro.params.property}")
34 -#set ($object = $numbertool.toNumber("$!{xcontext.macro.params.object}").intValue())
35 +#set ($object = $mathtool.toInteger("$!{xcontext.macro.params.object}"))
35 35  #if ("$!{object}" != $!{xcontext.macro.params.object})
36 36   #set ($object = ${targetdoc.getObject($classname).number})
37 37   #if ("$!{object}" == '')
... ... @@ -146,9 +146,8 @@
146 146   #if ($hasTargetDoc)
147 147   #set ($queryString.targetdocname = $targetdoc.fullName)
148 148   #end
149 - #set ($linkLabel = $services.rendering.escape($services.rendering.escape($buttontext, 'xwiki/2.1'), 'xwiki/2.1'))
150 - (% class="buttonwrapper" %)[[$linkLabel>>${xcontext.macro.doc.fullName}||queryString="$escapetool.url($queryString)"
151 - class="attachment-picker-start button" title="$services.rendering.escape($buttontext, 'xwiki/2.1')"]](%%)##
150 + (% class="buttonwrapper" %)[[$buttontext>>$xcontext.macro.doc.fullName||queryString="$escapetool.url($queryString)"
151 + class="attachment-picker-start button" title="$buttontext"]](%%)##
152 152   #end
153 153  #end
154 154  {{/velocity}}