... |
... |
@@ -1,17 +1,21 @@ |
1 |
1 |
{{velocity output="false"}} |
|
2 |
+#set ($translationPrefix = 'xe.attachmentSelector') |
|
3 |
+ |
2 |
2 |
#if ($request.xaction == 'postUpload') |
3 |
3 |
#set ($targetDocument = $xwiki.getDocument($request.get('docname'))) |
4 |
4 |
#set ($targetAttachDocument = $xwiki.getDocument($request.get('targetdocname'))) |
5 |
5 |
|
6 |
6 |
#set ($fieldname = $request.get('fieldname')) |
|
9 |
+ #set ($comment = $services.localization.render("${translationPrefix}.postUpload.comment", [$fieldname])) |
7 |
7 |
#set ($docAction = $request.get('docAction')) |
8 |
8 |
#set ($attachmentList = $targetAttachDocument.getAttachmentList()) |
9 |
9 |
#if ($attachmentList && $attachmentList.size() > 0) |
10 |
|
- #set ($sortedAttachments = $sorttool.sort($attachmentList, 'date:desc')) |
|
13 |
+ #set ($sortedAttachments = $collectiontool.sort($attachmentList, 'date:desc')) |
11 |
11 |
#set ($lastAttachment = $sortedAttachments.get(0)) |
12 |
12 |
#end |
13 |
13 |
$response.sendRedirect($targetDocument.getURL($docAction, $escapetool.url({ |
14 |
14 |
$fieldname: $lastAttachment.filename, |
|
18 |
+ 'comment': $comment, |
15 |
15 |
'form_token': $request.form_token |
16 |
16 |
}))) |
17 |
17 |
#stop |
... |
... |
@@ -22,7 +22,6 @@ |
22 |
22 |
## |
23 |
23 |
## Macros |
24 |
24 |
## |
25 |
|
-#set ($translationPrefix = 'xe.attachmentSelector') |
26 |
26 |
#set ($attachmentPickerDocName = 'XWiki.AttachmentSelector') |
27 |
27 |
|
28 |
28 |
$xwiki.ssx.use($attachmentPickerDocName) |
... |
... |
@@ -46,7 +46,7 @@ |
46 |
46 |
#attachmentPicker_displayUploadForm($targetDocument, $targetAttachDocument, $options) |
47 |
47 |
#end |
48 |
48 |
#attachmentPicker_displayAttachmentGalleryEmptyValue($targetDocument, $targetAttachDocument, $options, $currentValue) |
49 |
|
- #set ($sortedAttachments = $sorttool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") ) |
|
52 |
+ #set ($sortedAttachments = $collectiontool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") ) |
50 |
50 |
#foreach ($attachment in $sortedAttachments) |
51 |
51 |
#set ($extension = $attachment.getFilename()) |
52 |
52 |
#set ($extension = $extension.substring($mathtool.add($extension.lastIndexOf('.'), 1)).toLowerCase()) |
... |
... |
@@ -76,7 +76,10 @@ |
76 |
76 |
#set ($returnURL = $escapetool.url($doc.getURL('view', $request.queryString))) |
77 |
77 |
#set ($deleteURL = $targetAttachDocument.getAttachmentURL($attachment.filename, 'delattachment', "xredirect=${returnURL}&form_token=$!{services.csrf.getToken()}") ) |
78 |
78 |
#set ($viewURL = $targetAttachDocument.getAttachmentURL($attachment.filename) )##{'name' : 'download', 'url' : $viewURL, 'rel' : '__blank'} |
79 |
|
- #set ($selectURL = $targetDocument.getURL(${options.get('docAction')}, "${options.get('classname')}_${options.get('object')}_${options.get('property')}=${attachment.filename}&form_token=$!{services.csrf.getToken()}")) |
|
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 |
+ }))) |
80 |
80 |
#attachmentPicker_displayEndFrame ([{'name' : 'select', 'url' : $selectURL}, {'name' : 'delete', 'url' : $deleteURL}]) |
81 |
81 |
#end |
82 |
82 |
|
... |
... |
@@ -89,7 +89,9 @@ |
89 |
89 |
*# |
90 |
90 |
#macro (attachmentPicker_displayStartFrame $boxOptions $currentValue) |
91 |
91 |
(% class="gallery_attachmentbox $!{boxOptions.cssClass} #if ("$!{boxOptions.value}" == $currentValue) current#{end}" %)((( |
92 |
|
- (% class="gallery_attachmenttitle" title="$!{boxOptions.value}" %)((($boxOptions.text))) |
|
98 |
+ (% class="gallery_attachmenttitle" title="$services.rendering.escape($!{boxOptions.value}, 'xwiki/2.1')" %)((( |
|
99 |
+ $services.rendering.escape($boxOptions.text, 'xwiki/2.1') |
|
100 |
+ ))) |
93 |
93 |
(% class="gallery_attachmentframe" %)((( |
94 |
94 |
#end |
95 |
95 |
|
... |
... |
@@ -105,16 +105,16 @@ |
105 |
105 |
## Compute the attachment reference because there's no getter. |
106 |
106 |
#set ($attachmentReference = $services.model.createAttachmentReference($attachment.document.documentReference, |
107 |
107 |
$attachment.filename)) |
108 |
|
- #set ($attachmentStringReference = $services.model.serialize($attachmentReference, 'default')) |
|
116 |
+ #set ($attachmentStringReference = $services.rendering.escape($services.model.serialize($attachmentReference, 'default'), 'xwiki/2.1')) |
109 |
109 |
#if ($attachment.isImage() && $options.displayImage) |
110 |
110 |
## We add the version to the query string in order to invalidate the cache when an image attachment is replaced. |
111 |
111 |
#set ($queryString = $escapetool.url({'version': $attachment.version})) |
112 |
|
- [[[[image:$attachmentStringReference||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]] |
|
120 |
+ [[[[image:${attachmentStringReference}||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]] |
113 |
113 |
#else |
114 |
|
- * (% class="mime" %){{html wiki=false clean=false}}#mimetypeimg($attachment.getMimeType().toLowerCase() $attachment.getFilename().toLowerCase()){{/html}}(%%) (% class="filename" %)$attachment.getFilename()(% %) |
|
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')(% %) |
115 |
115 |
* v$attachment.getVersion() (#dynamicsize($attachment.longSize)) |
116 |
116 |
* $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')}]) |
117 |
|
- * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:$attachmentStringReference||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%) |
|
125 |
+ * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:${attachmentStringReference}||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%) |
118 |
118 |
#end |
119 |
119 |
#end |
120 |
120 |
#end |
... |
... |
@@ -282,7 +282,7 @@ |
282 |
282 |
#end |
283 |
283 |
#set ($options = { |
284 |
284 |
'classname' : ${request.get('classname')}, |
285 |
|
- 'object' : $!{mathtool.toInteger($request.object)}, |
|
293 |
+ 'object' : $!{numbertool.toNumber($request.object).intValue()}, |
286 |
286 |
'property' : ${request.property}, |
287 |
287 |
'displayImage' : ${displayImage}, |
288 |
288 |
'docAction' : ${docAction}, |
... |
... |
@@ -296,7 +296,7 @@ |
296 |
296 |
#attachmentPicker_displayAttachmentGallery($targetDocument, $targetAttachDocument, $options) |
297 |
297 |
|
298 |
298 |
(% class="gallery_buttons buttons" %)((( |
299 |
|
- (% class="buttonwrapper secondary" %)[[$services.localization.render("${translationPrefix}.cancel")>>$targetDocument||class="button secondary" id="attachment-picker-close"]] |
|
307 |
+ (% class="buttonwrapper secondary" %)[[$services.localization.render("${translationPrefix}.cancel")>>${targetDocument}||class="button secondary" id="attachment-picker-close"]] |
300 |
300 |
))) |
301 |
301 |
#end |
302 |
302 |
{{/velocity}} |