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 2.1
edited by Sebastian Marsching
on 2022/05/29 22:41
Change comment: Install extension [org.xwiki.platform:xwiki-platform-attachment-ui/14.4]

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.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}}