Changes for page Attachments

Last modified by Ludovic Dubost on 2024/07/22 15:50

From version 8.1
edited by Ludovic Dubost
on 2018/11/30 15:24
Change comment: Migrated property [async_enabled] from class [XWiki.WikiMacroClass]
To version 15.1
edited by Ludovic Dubost
on 2022/08/01 13:49
Change comment: Migrated property [defaultCategories] from class [XWiki.WikiMacroClass]

Summary

Details

Page properties
Content
... ... @@ -1,17 +1,21 @@
1 1  {{velocity output="false"}}
2 +#set ($translationPrefix = 'xe.attachmentSelector')
3 +
2 2  #if ($request.xaction == 'postUpload')
3 3   #set ($targetDocument = $xwiki.getDocument($request.get('docname')))
4 4   #set ($targetAttachDocument = $xwiki.getDocument($request.get('targetdocname')))
5 5  
6 6   #set ($fieldname = $request.get('fieldname'))
9 + #set ($comment = $services.localization.render("${translationPrefix}.postUpload.comment", [$fieldname]))
7 7   #set ($docAction = $request.get('docAction'))
8 8   #set ($attachmentList = $targetAttachDocument.getAttachmentList())
9 9   #if ($attachmentList && $attachmentList.size() > 0)
10 - #set ($sortedAttachments = $sorttool.sort($attachmentList, 'date:desc'))
13 + #set ($sortedAttachments = $collectiontool.sort($attachmentList, 'date:desc'))
11 11   #set ($lastAttachment = $sortedAttachments.get(0))
12 12   #end
13 13   $response.sendRedirect($targetDocument.getURL($docAction, $escapetool.url({
14 14   $fieldname: $lastAttachment.filename,
18 + 'comment': $comment,
15 15   'form_token': $request.form_token
16 16   })))
17 17   #stop
... ... @@ -22,7 +22,6 @@
22 22  ##
23 23  ## Macros
24 24  ##
25 -#set ($translationPrefix = 'xe.attachmentSelector')
26 26  #set ($attachmentPickerDocName = 'XWiki.AttachmentSelector')
27 27  
28 28  $xwiki.ssx.use($attachmentPickerDocName)
... ... @@ -46,7 +46,7 @@
46 46   #attachmentPicker_displayUploadForm($targetDocument, $targetAttachDocument, $options)
47 47   #end
48 48   #attachmentPicker_displayAttachmentGalleryEmptyValue($targetDocument, $targetAttachDocument, $options, $currentValue)
49 - #set ($sortedAttachments = $sorttool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") )
52 + #set ($sortedAttachments = $collectiontool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") )
50 50   #foreach ($attachment in $sortedAttachments)
51 51   #set ($extension = $attachment.getFilename())
52 52   #set ($extension = $extension.substring($mathtool.add($extension.lastIndexOf('.'), 1)).toLowerCase())
... ... @@ -109,12 +109,12 @@
109 109   #if ($attachment.isImage() && $options.displayImage)
110 110   ## We add the version to the query string in order to invalidate the cache when an image attachment is replaced.
111 111   #set ($queryString = $escapetool.url({'version': $attachment.version}))
112 - [[[[image:$attachmentStringReference||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]]
115 + [[[[image:${attachmentStringReference}||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]]
113 113   #else
114 114   * (% class="mime" %){{html wiki=false clean=false}}#mimetypeimg($attachment.getMimeType().toLowerCase() $attachment.getFilename().toLowerCase()){{/html}}(%%) (% class="filename" %)$attachment.getFilename()(% %)
115 115   * v$attachment.getVersion() (#dynamicsize($attachment.longSize))
116 116   * $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')}])
117 - * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:$attachmentStringReference||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%)
120 + * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:${attachmentStringReference}||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%)
118 118   #end
119 119   #end
120 120  #end
... ... @@ -282,7 +282,7 @@
282 282   #end
283 283   #set ($options = {
284 284   'classname' : ${request.get('classname')},
285 - 'object' : $!{mathtool.toInteger($request.object)},
288 + 'object' : $!{numbertool.toNumber($request.object).intValue()},
286 286   'property' : ${request.property},
287 287   'displayImage' : ${displayImage},
288 288   'docAction' : ${docAction},
... ... @@ -296,7 +296,7 @@
296 296   #attachmentPicker_displayAttachmentGallery($targetDocument, $targetAttachDocument, $options)
297 297  
298 298   (% class="gallery_buttons buttons" %)(((
299 - (% class="buttonwrapper secondary" %)[[$services.localization.render("${translationPrefix}.cancel")>>$targetDocument||class="button secondary" id="attachment-picker-close"]]
302 + (% class="buttonwrapper secondary" %)[[$services.localization.render("${translationPrefix}.cancel")>>${targetDocument}||class="button secondary" id="attachment-picker-close"]]
300 300   )))
301 301  #end
302 302  {{/velocity}}
XWiki.JavaScriptExtension[0]
Code
... ... @@ -173,10 +173,7 @@
173 173   this.dialog.closeDialog();
174 174   }.bindAsEventListener(this),
175 175   onFailure : function(response) {
176 - var failureReason = response.statusText;
177 - if (response.statusText == '' /* No response */ || response.status == 12031 /* In IE */) {
178 - failureReason = 'Server not responding';
179 - }
176 + var failureReason = response.statusText || 'Server not responding';
180 180   if (targetElement._x_notif) {
181 181   targetElement._x_notif.replace(new XWiki.widgets.Notification("$services.localization.render('core.widgets.confirmationBox.notification.failed')" + failureReason, "error"));
182 182   } else {
... ... @@ -183,9 +183,6 @@
183 183   new XWiki.widgets.Notification(this.interactionParameters.failureMessageText + failureReason, "error");
184 184   }
185 185   },
186 - on1223 : function(response) {
187 - response.request.options.onSuccess(response);
188 - },
189 189   on0 : function(response) {
190 190   response.request.options.onFailure(response);
191 191   },
XWiki.StyleSheetExtension[0]
Code
... ... @@ -140,9 +140,6 @@
140 140   ## Make this box twice as large as the others
141 141   width: ${uploadBoxSize}px;
142 142  }
143 -* html .gallery_upload {
144 - width: ${mathtool.add($uploadBoxSize, 2)}px;
145 -}
146 146  .gallery_upload, .gallery_upload:hover {
147 147   background-color: $theme.backgroundSecondaryColor;
148 148  }
XWiki.WikiMacroClass[0]
Cached
... ... @@ -1,0 +1,1 @@
1 +No
Asynchronous rendering
... ... @@ -1,0 +1,1 @@
1 +No
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 = ${doc.getObject($classname).number})
38 38   #if ("$!{object}" == '')
... ... @@ -138,7 +138,7 @@
138 138   #if ($hasTargetDoc)
139 139   #set ($queryString.targetdocname = $targetdoc.fullName)
140 140   #end
141 - (% class="buttonwrapper" %)[[$buttontext>>$xcontext.macro.doc.fullName||queryString="$escapetool.url($queryString)"
140 + (% class="buttonwrapper" %)[[$buttontext>>${xcontext.macro.doc.fullName}||queryString="$escapetool.url($queryString)"
142 142   class="attachment-picker-start button" title="$buttontext"]](%%)##
143 143   #end
144 144  #end
XWiki.WikiMacroParameterClass[0]
Parameter type
... ... @@ -1,0 +1,1 @@
1 +org.xwiki.model.reference.DocumentReference
XWiki.WikiMacroParameterClass[10]
Parameter type
... ... @@ -1,0 +1,1 @@
1 +org.xwiki.model.reference.AttachmentReference
XWiki.WikiMacroParameterClass[18]
Parameter type
... ... @@ -1,0 +1,1 @@
1 +org.xwiki.model.reference.DocumentReference