Changes for page Attachments

Last modified by Thomas Mortagne on 2023/11/06 18:01

From version 20.1
edited by Thomas Mortagne
on 2022/10/31 16:27
Change comment: Install extension [org.xwiki.platform:xwiki-platform-attachment-ui/14.9]
To version 21.1
edited by Thomas Mortagne
on 2022/12/29 11:57
Change comment: Install extension [org.xwiki.platform:xwiki-platform-attachment-ui/14.10.2]

Summary

Details

Page properties
Content
... ... @@ -333,8 +333,10 @@
333 333   $!targetDocument.use($targetDocument.getObject($options.classname, $options.object))##
334 334   #attachmentPicker_displayAttachmentGallery($targetDocument, $targetAttachDocument, $options)
335 335  
336 + #set ($cancelLinkName = $services.rendering.escape($services.rendering.escape($services.localization.render("${translationPrefix}.cancel"), 'xwiki/2.1'), 'xwiki/2.1'))
337 + #set ($cancelLinkTarget = $services.rendering.escape($services.model.serialize($targetDocument), 'xwiki/2.1'))
336 336   (% class="gallery_buttons buttons" %)(((
337 - (% 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"]]
338 338   )))
339 339  #end
340 340  {{/velocity}}
XWiki.JavaScriptExtension[0]
Code
... ... @@ -122,6 +122,13 @@
122 122   new XWiki.widgets.Notification("$services.localization.render('xe.attachmentSelector.upload.error.badExtension')", 'error');
123 123   hasErrors = true;
124 124   }
125 + const beforeUploadEvent = Event.fire(document, 'xwiki:actions:beforeUpload', {
126 + file: fileInput
127 + });
128 +
129 + if (beforeUploadEvent.defaultPrevented) {
130 + hasErrors = true;
131 + }
125 125   }.bind(this));
126 126   if (!hasErrors) {
127 127   if (this.directSave) {
XWiki.WikiMacroClass[0]
Macro code
... ... @@ -159,7 +159,7 @@
159 159  #elseif ($xcontext.action == 'inline' || $xcontext.action == 'edit')
160 160   (% class="attachment-picker" %)(((##
161 161   #attachmentPicker_displayAttachment($propValue $displayImage false true) #attachmentPicker_displayButton()##
162 - {{html}}<input type="hidden" name="${classname}_${object}_${property}" value="${propValue}" class="property-reference"/>{{/html}}##
162 + {{html}}<input type="hidden" name="$escapetool.xml("${classname}_${object}_${property}")" value="$escapetool.xml("${propValue}")" class="property-reference"/>{{/html}}##
163 163   )))
164 164  #else
165 165   #attachmentPicker_displayAttachment($propValue $displayImage $link false)