| ... |
... |
@@ -45,14 +45,11 @@ |
| 45 |
45 |
#end |
| 46 |
46 |
(% class="gallery" %)((( |
| 47 |
47 |
## Only display the upload form if they have edit permission on targetAttachDocument |
| 48 |
|
- #attachmentPicker_displayUploadForm($targetDocument, $targetAttachDocument, $options) |
| 49 |
|
- #attachmentPicker_displayAttachmentGalleryEmptyValue($targetDocument, $targetAttachDocument, $options, $currentValue) |
| 50 |
|
- #if ("$!services.temporaryAttachments" != '') |
| 51 |
|
- #set ($unsortedAttachments = $services.temporaryAttachments.listAllAttachments($targetAttachDocument)) |
| 52 |
|
- #set ($sortedAttachments = $collectiontool.sort($unsortedAttachments, "${options.sortAttachmentsBy}")) |
| 53 |
|
- #else |
| 54 |
|
- #set ($sortedAttachments = $collectiontool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") ) |
|
48 |
+ #if ($xwiki.hasAccessLevel('edit',$xcontext.user,${targetAttachDocument.fullName})) |
|
49 |
+ #attachmentPicker_displayUploadForm($targetDocument, $targetAttachDocument, $options) |
| 55 |
55 |
#end |
|
51 |
+ #attachmentPicker_displayAttachmentGalleryEmptyValue($targetDocument, $targetAttachDocument, $options, $currentValue) |
|
52 |
+ #set ($sortedAttachments = $collectiontool.sort($targetAttachDocument.getAttachmentList(), "${options.sortAttachmentsBy}") ) |
| 56 |
56 |
#foreach ($attachment in $sortedAttachments) |
| 57 |
57 |
#set ($extension = $attachment.getFilename()) |
| 58 |
58 |
#set ($extension = $extension.substring($mathtool.add($extension.lastIndexOf('.'), 1)).toLowerCase()) |
| ... |
... |
@@ -72,46 +72,18 @@ |
| 72 |
72 |
* @param $currentValue the currently selected file, used for determining if the box should be highlighted as the current value |
| 73 |
73 |
*# |
| 74 |
74 |
#macro (attachmentPicker_displayAttachmentBox $attachment $targetDocument $targetAttachDocument, $options $currentValue) |
| 75 |
|
- #set ($hasTemporaryAttachment = "$!services.temporaryAttachments" != '') |
| 76 |
|
- #set ($canEdit = $xwiki.hasAccessLevel('edit', $xcontext.user, ${targetAttachDocument.fullName})) |
| 77 |
|
- #set ($isTemporaryAttachment = false) |
| 78 |
|
- #if(!$hasTemporaryAttachment) |
| 79 |
|
- #set ($canDeleteAttachment = $canEdit) |
|
72 |
+ #if ($options.displayImage && $attachment.isImage()) |
|
73 |
+ #set ($cssClass = 'gallery_image') |
| 80 |
80 |
#else |
| 81 |
|
- #set ($isTemporaryAttachment = $services.temporaryAttachments.temporaryAttachmentExists($attachment)) |
| 82 |
|
- ## TODO: Update once it is made possible to delete temporary attachments (see XWIKI-20225). |
| 83 |
|
- #set ($canDeleteAttachment = !$isTemporaryAttachment && $canEdit) |
|
75 |
+ #set ($cssClass = '') |
| 84 |
84 |
#end |
| 85 |
|
- #set ($cssClasses = []) |
| 86 |
|
- #if ($options.displayImage && $attachment.isImage()) |
| 87 |
|
- #set ($discard = $cssClasses.add('gallery_image')) |
| 88 |
|
- #end |
| 89 |
|
- #if ($isTemporaryAttachment) |
| 90 |
|
- #set ($discard = $cssClasses.add('temporary_attachment')) |
| 91 |
|
- #end |
| 92 |
|
- #attachmentPicker_displayStartFrame({'value' : $attachment.filename, 'text' : $attachment.filename, 'cssClass' : "${stringtool.join($cssClasses, ' ')}"} $currentValue) |
|
77 |
+ #attachmentPicker_displayStartFrame({'value' : $attachment.filename, 'text' : $attachment.filename, 'cssClass' : "$!{cssClass}"} $currentValue) |
| 93 |
93 |
#attachmentPicker_displayAttachmentDetails($attachment $options) |
| 94 |
94 |
#set ($returnURL = $escapetool.url($doc.getURL('view', $request.queryString))) |
| 95 |
95 |
#set ($deleteURL = $targetAttachDocument.getAttachmentURL($attachment.filename, 'delattachment', "xredirect=${returnURL}&form_token=$!{services.csrf.getToken()}") ) |
| 96 |
96 |
#set ($viewURL = $targetAttachDocument.getAttachmentURL($attachment.filename) )##{'name' : 'download', 'url' : $viewURL, 'rel' : '__blank'} |
| 97 |
|
- #set ($selectURL = $targetDocument.getURL(${options.get('docAction')}, $escapetool.url({ |
| 98 |
|
- "${options.get('classname')}_${options.get('object')}_${options.get('property')}": ${attachment.filename}, |
| 99 |
|
- 'form_token': $!{services.csrf.getToken()} |
| 100 |
|
- }))) |
| 101 |
|
- ## Delete action is only proposed for users with the edit right on the document. |
| 102 |
|
- ## If the temporary attachment is available, the delete action is only allowed for non-temporary attachments. |
| 103 |
|
- #set ($attachmentActions = [{'name' : 'select', 'url' : $selectURL}]) |
| 104 |
|
- #if($canDeleteAttachment) |
| 105 |
|
- #set ($discard = $attachmentActions.add({'name' : 'delete', 'url' : $deleteURL})) |
| 106 |
|
- #end |
| 107 |
|
- #define($additionalContent) |
| 108 |
|
- #if ($isTemporaryAttachment) |
| 109 |
|
- #set ($titleMessage = $services.localization.render('attachment.attachmentSelector.attachmentBox.temporaryAttachmentTitle')) |
| 110 |
|
- #set ($titleMessage = $services.rendering.escape($titleMessage, 'xwiki/2.1')) |
| 111 |
|
- (% title="$titleMessage" %)$services.icon.render('clock')(%%) |
| 112 |
|
- #end |
| 113 |
|
- #end |
| 114 |
|
- #attachmentPicker_displayEndFrame ($attachmentActions $additionalContent) |
|
82 |
+ #set ($selectURL = $targetDocument.getURL(${options.get('docAction')}, "${options.get('classname')}_${options.get('object')}_${options.get('property')}=${attachment.filename}&form_token=$!{services.csrf.getToken()}")) |
|
83 |
+ #attachmentPicker_displayEndFrame ([{'name' : 'select', 'url' : $selectURL}, {'name' : 'delete', 'url' : $deleteURL}]) |
| 115 |
115 |
#end |
| 116 |
116 |
|
| 117 |
117 |
#** |
| ... |
... |
@@ -123,9 +123,7 @@ |
| 123 |
123 |
*# |
| 124 |
124 |
#macro (attachmentPicker_displayStartFrame $boxOptions $currentValue) |
| 125 |
125 |
(% class="gallery_attachmentbox $!{boxOptions.cssClass} #if ("$!{boxOptions.value}" == $currentValue) current#{end}" %)((( |
| 126 |
|
- (% class="gallery_attachmenttitle" title="$services.rendering.escape($!{boxOptions.value}, 'xwiki/2.1')" %)((( |
| 127 |
|
- $services.rendering.escape($boxOptions.text, 'xwiki/2.1') |
| 128 |
|
- ))) |
|
95 |
+ (% class="gallery_attachmenttitle" title="$!{boxOptions.value}" %)((($boxOptions.text))) |
| 129 |
129 |
(% class="gallery_attachmentframe" %)((( |
| 130 |
130 |
#end |
| 131 |
131 |
|
| ... |
... |
@@ -141,13 +141,13 @@ |
| 141 |
141 |
## Compute the attachment reference because there's no getter. |
| 142 |
142 |
#set ($attachmentReference = $services.model.createAttachmentReference($attachment.document.documentReference, |
| 143 |
143 |
$attachment.filename)) |
| 144 |
|
- #set ($attachmentStringReference = $services.rendering.escape($services.model.serialize($attachmentReference, 'default'), 'xwiki/2.1')) |
|
111 |
+ #set ($attachmentStringReference = $services.model.serialize($attachmentReference, 'default')) |
| 145 |
145 |
#if ($attachment.isImage() && $options.displayImage) |
| 146 |
146 |
## We add the version to the query string in order to invalidate the cache when an image attachment is replaced. |
| 147 |
147 |
#set ($queryString = $escapetool.url({'version': $attachment.version})) |
| 148 |
148 |
[[[[image:${attachmentStringReference}||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]] |
| 149 |
149 |
#else |
| 150 |
|
- * (% 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()(% %) |
| 151 |
151 |
* v$attachment.getVersion() (#dynamicsize($attachment.longSize)) |
| 152 |
152 |
* $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')}]) |
| 153 |
153 |
* (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:${attachmentStringReference}||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%) |
| ... |
... |
@@ -167,9 +167,8 @@ |
| 167 |
167 |
* <dt>rel</dt> |
| 168 |
168 |
* <dd>an optional parameter to be used in the "rel" HTML attribute; for example "__blank" can be used to open the link in a new tab/window</dd> |
| 169 |
169 |
* </dl> |
| 170 |
|
- * @param $additionalContent optional additional content that does not follow the structure of the actions |
| 171 |
171 |
*# |
| 172 |
|
-#macro (attachmentPicker_displayEndFrame $actions $additionalContent) |
|
138 |
+#macro (attachmentPicker_displayEndFrame $actions) |
| 173 |
173 |
)))## attachmentframe |
| 174 |
174 |
(% class="gallery_actions" %)((( |
| 175 |
175 |
#foreach ($action in $actions) |
| ... |
... |
@@ -176,7 +176,6 @@ |
| 176 |
176 |
#set( $actionname = $services.localization.render("${translationPrefix}.actions.${action.name}") ) |
| 177 |
177 |
[[${actionname}>>path:${action.url}||class="tool ${action.name}" title="${actionname}" #if($action.rel) rel="${action.rel}"#end]]## |
| 178 |
178 |
#end |
| 179 |
|
- $!additionalContent |
| 180 |
180 |
)))## actions |
| 181 |
181 |
)))## attachmentbox |
| 182 |
182 |
#end |
| ... |
... |
@@ -333,10 +333,8 @@ |
| 333 |
333 |
$!targetDocument.use($targetDocument.getObject($options.classname, $options.object))## |
| 334 |
334 |
#attachmentPicker_displayAttachmentGallery($targetDocument, $targetAttachDocument, $options) |
| 335 |
335 |
|
| 336 |
|
- #set ($cancelLinkName = $services.rendering.escape($services.rendering.escape($services.localization.render("${translationPrefix}.cancel"), 'xwiki/2.1'), 'xwiki/2.1')) |
| 337 |
|
- #set ($cancelLinkTarget = $services.rendering.escape($services.model.serialize($targetDocument), 'xwiki/2.1')) |
| 338 |
338 |
(% class="gallery_buttons buttons" %)((( |
| 339 |
|
- (% class="buttonwrapper secondary" %)[[$cancelLinkName>>$cancelLinkTarget||class="button secondary" id="attachment-picker-close"]] |
|
302 |
+ (% class="buttonwrapper secondary" %)[[$services.localization.render("${translationPrefix}.cancel")>>${targetDocument}||class="button secondary" id="attachment-picker-close"]] |
| 340 |
340 |
))) |
| 341 |
341 |
#end |
| 342 |
342 |
{{/velocity}} |