Changes for page Attachments

Last modified by Sebastian Marsching on 2024/01/08 23:13

From version 4.1
edited by Sebastian Marsching
on 2022/08/02 11:45
Change comment: Migrated property [defaultCategories] from class [XWiki.WikiMacroClass]
To version 1.1
edited by Sebastian Marsching
on 2022/01/09 00:04
Change comment: Install extension [org.xwiki.platform:xwiki-platform-attachment-ui/13.10.2]

Summary

Details

Page properties
Content
... ... @@ -79,10 +79,7 @@
79 79   #set ($returnURL = $escapetool.url($doc.getURL('view', $request.queryString)))
80 80   #set ($deleteURL = $targetAttachDocument.getAttachmentURL($attachment.filename, 'delattachment', "xredirect=${returnURL}&form_token=$!{services.csrf.getToken()}") )
81 81   #set ($viewURL = $targetAttachDocument.getAttachmentURL($attachment.filename) )##{'name' : 'download', 'url' : $viewURL, 'rel' : '__blank'}
82 - #set ($selectURL = $targetDocument.getURL(${options.get('docAction')}, $escapetool.url({
83 - "${options.get('classname')}_${options.get('object')}_${options.get('property')}": ${attachment.filename},
84 - 'form_token': $!{services.csrf.getToken()}
85 - })))
82 + #set ($selectURL = $targetDocument.getURL(${options.get('docAction')}, "${options.get('classname')}_${options.get('object')}_${options.get('property')}=${attachment.filename}&form_token=$!{services.csrf.getToken()}"))
86 86   #attachmentPicker_displayEndFrame ([{'name' : 'select', 'url' : $selectURL}, {'name' : 'delete', 'url' : $deleteURL}])
87 87  #end
88 88  
... ... @@ -95,9 +95,7 @@
95 95   *#
96 96  #macro (attachmentPicker_displayStartFrame $boxOptions $currentValue)
97 97   (% class="gallery_attachmentbox $!{boxOptions.cssClass} #if ("$!{boxOptions.value}" == $currentValue) current#{end}" %)(((
98 - (% class="gallery_attachmenttitle" title="$services.rendering.escape($!{boxOptions.value}, 'xwiki/2.1')" %)(((
99 - $services.rendering.escape($boxOptions.text, 'xwiki/2.1')
100 - )))
95 + (% class="gallery_attachmenttitle" title="$!{boxOptions.value}" %)((($boxOptions.text)))
101 101   (% class="gallery_attachmentframe" %)(((
102 102  #end
103 103  
... ... @@ -113,13 +113,13 @@
113 113   ## Compute the attachment reference because there's no getter.
114 114   #set ($attachmentReference = $services.model.createAttachmentReference($attachment.document.documentReference,
115 115   $attachment.filename))
116 - #set ($attachmentStringReference = $services.rendering.escape($services.model.serialize($attachmentReference, 'default'), 'xwiki/2.1'))
111 + #set ($attachmentStringReference = $services.model.serialize($attachmentReference, 'default'))
117 117   #if ($attachment.isImage() && $options.displayImage)
118 118   ## We add the version to the query string in order to invalidate the cache when an image attachment is replaced.
119 119   #set ($queryString = $escapetool.url({'version': $attachment.version}))
120 120   [[[[image:${attachmentStringReference}||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]]
121 121   #else
122 - * (% 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')(% %)
117 + * (% class="mime" %){{html wiki=false clean=false}}#mimetypeimg($attachment.getMimeType().toLowerCase() $attachment.getFilename().toLowerCase()){{/html}}(%%) (% class="filename" %)$attachment.getFilename()(% %)
123 123   * v$attachment.getVersion() (#dynamicsize($attachment.longSize))
124 124   * $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')}])
125 125   * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:${attachmentStringReference}||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%)
XWiki.JavaScriptExtension[0]
Code
... ... @@ -173,7 +173,10 @@
173 173   this.dialog.closeDialog();
174 174   }.bindAsEventListener(this),
175 175   onFailure : function(response) {
176 - var failureReason = response.statusText || 'Server not responding';
176 + var failureReason = response.statusText;
177 + if (response.statusText == '' /* No response */ || response.status == 12031 /* In IE */) {
178 + failureReason = 'Server not responding';
179 + }
177 177   if (targetElement._x_notif) {
178 178   targetElement._x_notif.replace(new XWiki.widgets.Notification("$services.localization.render('core.widgets.confirmationBox.notification.failed')" + failureReason, "error"));
179 179   } else {
... ... @@ -180,6 +180,9 @@
180 180   new XWiki.widgets.Notification(this.interactionParameters.failureMessageText + failureReason, "error");
181 181   }
182 182   },
186 + on1223 : function(response) {
187 + response.request.options.onSuccess(response);
188 + },
183 183   on0 : function(response) {
184 184   response.request.options.onFailure(response);
185 185   },
XWiki.StyleSheetExtension[0]
Code
... ... @@ -140,6 +140,9 @@
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 +}
143 143  .gallery_upload, .gallery_upload:hover {
144 144   background-color: $theme.backgroundSecondaryColor;
145 145  }
XWiki.WikiMacroClass[0]
Macro code
... ... @@ -45,18 +45,9 @@
45 45   #set ($displayImage = false)
46 46  #end
47 47  #if ($displayImage)
48 - #set ($alt = '')
49 - #set ($width = '')
50 - #set ($height = '')
51 - #if ($xcontext.macro.params.alternateText)
52 - #set ($alt = "$services.rendering.escape($!{xcontext.macro.params.alternateText}, 'xwiki/2.1')")
53 - #end
54 - #if ($xcontext.macro.params.width)
55 - #set ($width = "$services.rendering.escape($!{xcontext.macro.params.width}, 'xwiki/2.1')")
56 - #end
57 - #if ($xcontext.macro.params.height)
58 - #set ($height = "$services.rendering.escape($!{xcontext.macro.params.height}, 'xwiki/2.1')")
59 - #end
48 + #set ($alt = "$!{xcontext.macro.params.alternateText}")
49 + #set ($width = "$!{xcontext.macro.params.width}")
50 + #set ($height = "$!{xcontext.macro.params.height}")
60 60   #set ($imageParams = '')
61 61   #if ("${width}" != '')
62 62   #set($imageParams = "$!{imageParams} width=${width}")
... ... @@ -121,9 +121,9 @@
121 121   #set ($attachmentResource = '')
122 122   #end
123 123   #if ($displayImage)
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)))##
115 + (% class="$!{cssClass}#if (!$attachment) hidden#end" %)(((#if ("$!{attachmentResource}" != '' || $forceElement)#if($withLink)[[#end[[image:${attachmentResource}$!{imageParams}]]#if($withLink)>>attach:${attachmentResource}||rel=lightbox]]#{end}#end)))##
125 125   #else
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(%%)##
117 + (% class="$!{cssClass}" %)#if ("$!{attachmentResource}" != '' || $forceElement)#if ($withLink)[[attach:${attachmentResource}||rel=__blank]]#{else}(% class="displayed" %)#if($targetPermView)$!{attachmentName}#{else}Access Denied#{end}(% %)#{end}#end(%%)##
127 127   #end
128 128  #end
129 129  
... ... @@ -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')"]](%%)##
140 + (% class="buttonwrapper" %)[[$buttontext>>${xcontext.macro.doc.fullName}||queryString="$escapetool.url($queryString)"
141 + class="attachment-picker-start button" title="$buttontext"]](%%)##
152 152   #end
153 153  #end
154 154  {{/velocity}}