Changes for page Attachments

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

From version 6.1
edited by teamwire004
on 2024/07/12 12:45
Change comment: Migrated property [type] from class [XWiki.WikiMacroParameterClass]
To version 9.1
edited by teamwire005
on 2025/05/06 07:37
Change comment: Migrated property [featureMandatory] from class [XWiki.WikiMacroParameterClass]

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.teamwire004
1 +XWiki.teamwire005
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 = $sorttool.sort($attachmentList, 'date:desc'))
13 + #set ($sortedAttachments = $collectiontool.sort($attachmentList, 'date:desc'))
14 14   #set ($lastAttachment = $sortedAttachments.get(0))
15 15   #end
16 16   $response.sendRedirect($targetDocument.getURL($docAction, $escapetool.url({
... ... @@ -47,7 +47,12 @@
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 - #set ($sortedAttachments = $sorttool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") )
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
51 51   #foreach ($attachment in $sortedAttachments)
52 52   #set ($extension = $attachment.getFilename())
53 53   #set ($extension = $extension.substring($mathtool.add($extension.lastIndexOf('.'), 1)).toLowerCase())
... ... @@ -140,12 +140,12 @@
140 140   #if ($attachment.isImage() && $options.displayImage)
141 141   ## We add the version to the query string in order to invalidate the cache when an image attachment is replaced.
142 142   #set ($queryString = $escapetool.url({'version': $attachment.version}))
143 - [[[[image:$attachmentStringReference||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]]
148 + [[[[image:${attachmentStringReference}||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]]
144 144   #else
145 145   * (% 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')(% %)
146 146   * v$attachment.getVersion() (#dynamicsize($attachment.longSize))
147 147   * $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')}])
148 - * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:$attachmentStringReference||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%)
153 + * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:${attachmentStringReference}||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%)
149 149   #end
150 150   #end
151 151  #end
... ... @@ -315,7 +315,7 @@
315 315   #end
316 316   #set ($options = {
317 317   'classname' : ${request.get('classname')},
318 - 'object' : $!{mathtool.toInteger($request.object)},
323 + 'object' : $!{numbertool.toNumber($request.object).intValue()},
319 319   'property' : ${request.property},
320 320   'displayImage' : ${displayImage},
321 321   'docAction' : ${docAction},
... ... @@ -331,7 +331,7 @@
331 331   #set ($cancelLinkName = $services.rendering.escape($services.rendering.escape($services.localization.render("${translationPrefix}.cancel"), 'xwiki/2.1'), 'xwiki/2.1'))
332 332   #set ($cancelLinkTarget = $services.rendering.escape($services.model.serialize($targetDocument), 'xwiki/2.1'))
333 333   (% class="gallery_buttons buttons" %)(((
334 - (% class="buttonwrapper secondary" %)[[$services.localization.render("${translationPrefix}.cancel")>>$targetDocument||class="button secondary" id="attachment-picker-close"]]
339 + (% class="buttonwrapper secondary" %)[[$cancelLinkName>>$cancelLinkTarget||class="button secondary" id="attachment-picker-close"]]
335 335   )))
336 336  #end
337 337  {{/velocity}}
XWiki.StyleSheetExtension[0]
Code
... ... @@ -27,7 +27,7 @@
27 27  .gallery_attachmentbox {
28 28   background: $theme.pageContentBackgroundColor;
29 29   border: 1px solid $theme.borderColor;
30 - border-radius: 5px;
30 + border-radius: 8px;
31 31   float: left;
32 32   margin: ${boxMargin}px;
33 33   overflow: hidden;
... ... @@ -49,7 +49,7 @@
49 49  .gallery_attachmenttitle {
50 50   background: $theme.backgroundSecondaryColor;
51 51   border-bottom: 1px dotted $theme.borderColor;
52 - border-radius: 5px 5px 0px 0px;
52 + border-radius: 8px 8px 0px 0px;
53 53   font-size: 85%;
54 54   padding: 3px ${boxPadding}px;
55 55   overflow: hidden;
XWiki.WikiMacroClass[0]
Macro code
... ... @@ -3,7 +3,6 @@
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')##
7 7  ## Integrates the optional Lightbox widget (from http://extensions.xwiki.org/xwiki/bin/view/Extension/Lightbox+Application )
8 8  #if ($xwiki.exists('XWiki.Lightbox'))
9 9   $xwiki.jsx.use('XWiki.Lightbox')
... ... @@ -32,7 +32,7 @@
32 32  #end
33 33  #set ($classname = "$!{xcontext.macro.params.classname}")
34 34  #set ($property = "$!{xcontext.macro.params.property}")
35 -#set ($object = $mathtool.toInteger("$!{xcontext.macro.params.object}"))
34 +#set ($object = $numbertool.toNumber("$!{xcontext.macro.params.object}").intValue())
36 36  #if ("$!{object}" != $!{xcontext.macro.params.object})
37 37   #set ($object = ${targetdoc.getObject($classname).number})
38 38   #if ("$!{object}" == '')
... ... @@ -147,8 +147,9 @@
147 147   #if ($hasTargetDoc)
148 148   #set ($queryString.targetdocname = $targetdoc.fullName)
149 149   #end
150 - (% class="buttonwrapper" %)[[$buttontext>>$xcontext.macro.doc.fullName||queryString="$escapetool.url($queryString)"
151 - class="attachment-picker-start button" title="$buttontext"]](%%)##
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')"]](%%)##
152 152   #end
153 153  #end
154 154  {{/velocity}}