Changes for page Attachments

Last modified by SuperUwe Trueggelmann on 2026/10/09 12:58

From version 5.1
edited by SuperUwe Trueggelmann
on 2026/10/09 12:58
Change comment: Install extension [org.xwiki.platform:xwiki-platform-attachment-ui/17.10.13]
To version 4.1
edited by SuperNico Laub
on 2025/09/18 17:51
Change comment: Install extension [org.xwiki.platform:xwiki-platform-attachment-ui/17.7.0]

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.superuwe
1 +xwiki:XWiki.supernico
Content
... ... @@ -175,10 +175,8 @@
175 175   (% class="gallery_actions" %)(((
176 176   #foreach ($action in $actions)
177 177   #set( $actionname = $services.localization.render("${translationPrefix}.actions.${action.name}") )
178 - ## Escape the URL so that it cannot break out of the link syntax, whatever its origin.
179 - #set ($actionURL = $services.rendering.escape($action.url, 'xwiki/2.1'))
180 180   [[${services.icon.render($action.icon)}(% class="sr-only"%)${actionname}(%%)>>##
181 - path:${actionURL}||class="tool ${action.name} $!{action.extraCssClass}"##
179 + path:${action.url}||class="tool ${action.name} $!{action.extraCssClass}"##
182 182   title="${actionname}" #if($action.rel) rel="${action.rel}"#end]]##
183 183   #end
184 184   $!additionalContent
... ... @@ -270,10 +270,7 @@
270 270   #_attachmentPicker_displayStartFrame({'cssClass' : "gallery_emptyChoice $!{dcssClass}", 'text' : $services.localization.render("${translationPrefix}.default"), 'value' : "${options.defaultValue}"} $currentValue)
271 271   #_attachmentPicker_displayAttachmentDetails($defaultAttachment $options)
272 272   #set ($returnURL = $escapetool.url($doc.getURL('view', $request.queryString)))
273 - #set ($selectURL = $targetDocument.getURL(${options.get('docAction')}, $escapetool.url({
274 - "${options.get('classname')}_${options.get('object')}_${options.get('property')}": '',
275 - 'form_token': $!{services.csrf.getToken()}
276 - })))
271 + #set ($selectURL = $targetDocument.getURL(${options.get('docAction')}, "${options.get('classname')}_${options.get('object')}_${options.get('property')}=&form_token=$!{services.csrf.getToken()}"))
277 277   #_attachmentPicker_displayEndFrame ([{'name' : 'select', 'url' : $selectURL, 'icon' : 'check', 'extraCssClass' : 'btn btn-xs btn-success'}])
278 278  #end
279 279  {{/velocity}}
XWiki.JavaScriptExtension[0]
Code
... ... @@ -2,7 +2,6 @@
2 2   function uploadTemporaryAttachment() {
3 3   // Require jquery locally until we are able to fully migrate this code away from prototype.
4 4   const form = this.property.up('form');
5 - const propertyReferenceInput = this.property.querySelector('input[type="hidden"].property-reference');
6 6   require(['jquery'], function ($) {
7 7   const data = new FormData();
8 8   const uploadedFile = $('#attachfile')[0].files[0];
... ... @@ -41,7 +41,7 @@
41 41   .prop('type', 'hidden')
42 42   .prop('name', 'uploadedFiles')
43 43   .prop('value', response.fileName))
44 - propertyReferenceInput.value = response.fileName;
43 + $(form).find('input[type="hidden"].property-reference').prop('value', response.fileName);
45 45   this.updateAttachment(response.fileName, response.url);
46 46   this.dialog.closeDialog();
47 47   }.bind(this)).fail(function () {
... ... @@ -168,7 +168,7 @@
168 168   /** AJAX deletion of attachments. */
169 169   onDelete : function(event) {
170 170   event.stop();
171 - const deleteTool = event.target.closest('.btn');
170 + deleteTool = event.element();
172 172   if (!deleteTool.disabled) {
173 173   new XWiki.widgets.ConfirmedAjaxRequest(
174 174   deleteTool.readAttribute('href'),
... ... @@ -211,7 +211,7 @@
211 211   /** Update the property with the selected value without reloading the page. */
212 212   onSelect : function(event) {
213 213   event.stop();
214 - const targetElement = event.target.closest('.btn');
213 + var targetElement = event.element();
215 215   var attachmentName = targetElement.up('.gallery_attachmentbox').down('.gallery_attachmenttitle').title;
216 216   var imageSource = targetElement.up('.gallery_attachmentbox.gallery_image');
217 217   if (imageSource) {
... ... @@ -226,7 +226,7 @@
226 226   if (this.directSave) {
227 227   // save via ajax
228 228   if (!targetElement.disabled) {
229 - new Ajax.Request(targetElement.href, {
228 + new Ajax.Request(event.element().href, {
230 230   onCreate : function() {
231 231   targetElement.disabled = true;
232 232   targetElement._x_notif = new XWiki.widgets.Notification("$services.localization.render('core.widgets.confirmationBox.notification.inProgress')", 'inprogress');
XWiki.WikiMacroClass[0]
Macro code
... ... @@ -121,9 +121,9 @@
121 121   #set ($attachmentResource = '')
122 122   #end
123 123   #if ($displayImage)
124 - (% class="${services.rendering.escape($!cssClass, 'xwiki/2.1')}#if (!$attachment) hidden#end" %)(((#if ("$!{attachmentResource}" != '' || $forceElement)#if($withLink)[[#end[[image:$services.rendering.escape(${attachmentResource}, 'xwiki/2.1')$!{imageParams}]]#if($withLink)>>attach:$services.rendering.escape(${attachmentResource},'xwiki/2.1')||rel=lightbox]]#{end}#end)))##
124 + (% class="$!{cssClass}#if (!$attachment) hidden#end" %)(((#if ("$!{attachmentResource}" != '' || $forceElement)#if($withLink)[[#end[[image:$services.rendering.escape(${attachmentResource}, 'xwiki/2.1')$!{imageParams}]]#if($withLink)>>attach:$services.rendering.escape(${attachmentResource},'xwiki/2.1')||rel=lightbox]]#{end}#end)))##
125 125   #else
126 - (% class="${services.rendering.escape($!cssClass, 'xwiki/2.1')}" %)#if ("$!{attachmentResource}" != '' || $forceElement)#if ($withLink)[[attach:${attachmentResource}||rel=__blank]]#{else}(% class="displayed" %)#if($targetPermView)$!{services.rendering.escape($!{attachmentName}, 'xwiki/2.1')}#{else}Access Denied#{end}(% %)#{end}#end(%%)##
126 + (% class="$!{cssClass}" %)#if ("$!{attachmentResource}" != '' || $forceElement)#if ($withLink)[[attach:${attachmentResource}||rel=__blank]]#{else}(% class="displayed" %)#if($targetPermView)$!{services.rendering.escape($!{attachmentName}, 'xwiki/2.1')}#{else}Access Denied#{end}(% %)#{end}#end(%%)##
127 127   #end
128 128  #end
129 129