Changes for page Attachments
Last modified by Leon Poon on 2024/03/23 04:26
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (4 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,21 +1,17 @@ 1 1 {{velocity output="false"}} 2 -#set ($translationPrefix = 'xe.attachmentSelector') 3 - 4 4 #if ($request.xaction == 'postUpload') 5 5 #set ($targetDocument = $xwiki.getDocument($request.get('docname'))) 6 6 #set ($targetAttachDocument = $xwiki.getDocument($request.get('targetdocname'))) 7 7 8 8 #set ($fieldname = $request.get('fieldname')) 9 - #set ($comment = $services.localization.render("${translationPrefix}.postUpload.comment", [$fieldname])) 10 10 #set ($docAction = $request.get('docAction')) 11 11 #set ($attachmentList = $targetAttachDocument.getAttachmentList()) 12 12 #if ($attachmentList && $attachmentList.size() > 0) 13 - #set ($sortedAttachments = $ collectiontool.sort($attachmentList, 'date:desc'))10 + #set ($sortedAttachments = $sorttool.sort($attachmentList, 'date:desc')) 14 14 #set ($lastAttachment = $sortedAttachments.get(0)) 15 15 #end 16 16 $response.sendRedirect($targetDocument.getURL($docAction, $escapetool.url({ 17 17 $fieldname: $lastAttachment.filename, 18 - 'comment': $comment, 19 19 'form_token': $request.form_token 20 20 }))) 21 21 #stop ... ... @@ -26,6 +26,7 @@ 26 26 ## 27 27 ## Macros 28 28 ## 25 +#set ($translationPrefix = 'xe.attachmentSelector') 29 29 #set ($attachmentPickerDocName = 'XWiki.AttachmentSelector') 30 30 31 31 $xwiki.ssx.use($attachmentPickerDocName) ... ... @@ -49,7 +49,7 @@ 49 49 #attachmentPicker_displayUploadForm($targetDocument, $targetAttachDocument, $options) 50 50 #end 51 51 #attachmentPicker_displayAttachmentGalleryEmptyValue($targetDocument, $targetAttachDocument, $options, $currentValue) 52 - #set ($sortedAttachments = $ collectiontool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") )49 + #set ($sortedAttachments = $sorttool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") ) 53 53 #foreach ($attachment in $sortedAttachments) 54 54 #set ($extension = $attachment.getFilename()) 55 55 #set ($extension = $extension.substring($mathtool.add($extension.lastIndexOf('.'), 1)).toLowerCase()) ... ... @@ -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 - }))) 79 + #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 - ))) 92 + (% class="gallery_attachmenttitle" title="$!{boxOptions.value}" %)((($boxOptions.text))) 101 101 (% class="gallery_attachmentframe" %)((( 102 102 #end 103 103 ... ... @@ -113,16 +113,16 @@ 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'))108 + #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 - [[[[image:$ {attachmentStringReference}||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]]112 + [[[[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')(% %)114 + * (% 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 - * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:$ {attachmentStringReference}||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%)117 + * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:$attachmentStringReference||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%) 126 126 #end 127 127 #end 128 128 #end ... ... @@ -290,7 +290,7 @@ 290 290 #end 291 291 #set ($options = { 292 292 'classname' : ${request.get('classname')}, 293 - 'object' : $!{ numbertool.toNumber($request.object).intValue()},285 + 'object' : $!{mathtool.toInteger($request.object)}, 294 294 'property' : ${request.property}, 295 295 'displayImage' : ${displayImage}, 296 296 'docAction' : ${docAction}, ... ... @@ -304,7 +304,7 @@ 304 304 #attachmentPicker_displayAttachmentGallery($targetDocument, $targetAttachDocument, $options) 305 305 306 306 (% class="gallery_buttons buttons" %)((( 307 - (% class="buttonwrapper secondary" %)[[$services.localization.render("${translationPrefix}.cancel")>>$ {targetDocument}||class="button secondary" id="attachment-picker-close"]]299 + (% class="buttonwrapper secondary" %)[[$services.localization.render("${translationPrefix}.cancel")>>$targetDocument||class="button secondary" id="attachment-picker-close"]] 308 308 ))) 309 309 #end 310 310 {{/velocity}}
- XWiki.WikiMacroClass[0]
-
- Cached
-
... ... @@ -1,1 +1,0 @@ 1 -No - Asynchronous rendering
-
... ... @@ -1,1 +1,0 @@ 1 -No - Macro code
-
... ... @@ -3,6 +3,7 @@ 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')## 6 6 ## Integrates the optional Lightbox widget (from http://extensions.xwiki.org/xwiki/bin/view/Extension/Lightbox+Application ) 7 7 #if ($xwiki.exists('XWiki.Lightbox')) 8 8 $xwiki.jsx.use('XWiki.Lightbox') ... ... @@ -31,7 +31,7 @@ 31 31 #end 32 32 #set ($classname = "$!{xcontext.macro.params.classname}") 33 33 #set ($property = "$!{xcontext.macro.params.property}") 34 -#set ($object = $ numbertool.toNumber("$!{xcontext.macro.params.object}").intValue())35 +#set ($object = $mathtool.toInteger("$!{xcontext.macro.params.object}")) 35 35 #if ("$!{object}" != $!{xcontext.macro.params.object}) 36 36 #set ($object = ${doc.getObject($classname).number}) 37 37 #if ("$!{object}" == '') ... ... @@ -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 49 + #set ($alt = "$!{xcontext.macro.params.alternateText}") 50 + #set ($width = "$!{xcontext.macro.params.width}") 51 + #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)))##116 + (% 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(%%)##118 + (% 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')"]](%%)## 141 + (% class="buttonwrapper" %)[[$buttontext>>$xcontext.macro.doc.fullName||queryString="$escapetool.url($queryString)" 142 + class="attachment-picker-start button" title="$buttontext"]](%%)## 152 152 #end 153 153 #end 154 154 {{/velocity}}
- XWiki.WikiMacroParameterClass[0]
-
- Parameter type
-
... ... @@ -1,1 +1,0 @@ 1 -org.xwiki.model.reference.DocumentReference
- XWiki.WikiMacroParameterClass[10]
-
- Parameter type
-
... ... @@ -1,1 +1,0 @@ 1 -org.xwiki.model.reference.AttachmentReference
- XWiki.WikiMacroParameterClass[18]
-
- Parameter type
-
... ... @@ -1,1 +1,0 @@ 1 -org.xwiki.model.reference.DocumentReference