Changes for page Attachments
Last modified by Ludovic Dubost on 2024/07/22 15:50
From version 7.1
edited by Ludovic Dubost
on 2018/11/30 15:23
on 2018/11/30 15:23
Change comment:
Migrated property [type] from class [XWiki.WikiMacroParameterClass]
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (3 modified, 0 added, 1 removed)
Details
- Page properties
-
- Content
-
... ... @@ -10,10 +10,7 @@ 10 10 #set ($sortedAttachments = $sorttool.sort($attachmentList, 'date:desc')) 11 11 #set ($lastAttachment = $sortedAttachments.get(0)) 12 12 #end 13 - $response.sendRedirect($targetDocument.getURL($docAction, $escapetool.url({ 14 - $fieldname: $lastAttachment.filename, 15 - 'form_token': $request.form_token 16 - }))) 13 + $response.sendRedirect($targetDocument.getURL($docAction, "$!{fieldname}=$!{lastAttachment.filename}&form_token=$!{escapetool.url($request.get('form_token'))}")) 17 17 #stop 18 18 #end 19 19 {{/velocity}} ... ... @@ -102,19 +102,14 @@ 102 102 *# 103 103 #macro (attachmentPicker_displayAttachmentDetails $attachment $options) 104 104 #if ($attachment) 105 - ## Compute the attachment reference because there's no getter. 106 - #set ($attachmentReference = $services.model.createAttachmentReference($attachment.document.documentReference, 107 - $attachment.filename)) 108 - #set ($attachmentStringReference = $services.model.serialize($attachmentReference, 'default')) 109 109 #if ($attachment.isImage() && $options.displayImage) 110 - ## We add the version to the query string in order to invalidate the cache when an image attachment is replaced. 111 - #set ($queryString = $escapetool.url({'version': $attachment.version})) 112 - [[[[image:$attachmentStringReference||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]] 103 + #set ($attachmentDocument = $attachment.getDocument()) 104 +[[[[image:${attachmentDocument.fullName}@${attachment.filename}||width=160]]>>attach:${attachmentDocument.fullName}@${attachment.filename}||rel="lightbox[attachments]"]] 113 113 #else 114 114 * (% class="mime" %){{html wiki=false clean=false}}#mimetypeimg($attachment.getMimeType().toLowerCase() $attachment.getFilename().toLowerCase()){{/html}}(%%) (% class="filename" %)$attachment.getFilename()(% %) 115 - * v$attachment.getVersion() (#dynamicsize($attachment.l ongSize))107 + * v$attachment.getVersion() (#dynamicsize($attachment.filesize)) 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:$attachment StringReference||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%)109 + * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:${attachment.getDocument()}@${attachment.filename}||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%) 118 118 #end 119 119 #end 120 120 #end ... ... @@ -160,9 +160,9 @@ 160 160 <form action="$targetAttachDocument.getURL('upload')" enctype="multipart/form-data" method="post" id="uploadAttachment" class="uploadAttachment xform"> 161 161 <div class="gallery_upload_input"> 162 162 #if (${options.rawfilter} != '') 163 - <span class="xHint">$ escapetool.xml($services.localization.render("${translationPrefix}.upload.hint", [${options.rawfilter}]))</span>155 + <span class="xHint">$services.localization.render("${translationPrefix}.upload.hint", [${options.rawfilter}])</span> 164 164 #end 165 - <input type="file" name="filepath" id="attachfile" class=" noitems" title="$!{escapetool.xml($options.rawfilter)}"/>157 + <input type="file" name="filepath" id="attachfile" class="attachment" size="30" title="$!{escapetool.xml($options.rawfilter)}"/> 166 166 <input type="hidden" name="xredirect" value="$xwiki.getDocument($attachmentPickerDocName).getURL('get', "xaction=postUpload&docAction=$!{escapetool.url($options.get('docAction'))}&targetdocname=$!{escapetool.url($targetAttachDocument.fullName)}&docname=$!{escapetool.url($targetDocument.fullName)}&fieldname=$!{escapetool.url($options.get('classname'))}_$!{escapetool.url($options.get('object'))}_$!{escapetool.url($options.get('property'))}&form_token=$!{services.csrf.getToken()}")" /> 167 167 <input type="hidden" name="docname" value="$!{escapetool.xml($targetDocument.fullName)}" /> 168 168 <input type="hidden" name="classname" value="$!{escapetool.xml($options.get('classname'))}" /> ... ... @@ -170,27 +170,6 @@ 170 170 <input type="hidden" name="property" value="$!{escapetool.xml($options.get('property'))}" /> 171 171 <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> 172 172 </div> 173 - #if ("$!currentValue" != '' && $currentValue != $options.defaultValue) 174 - <div> 175 - <label> 176 - <input type="checkbox" name="filename" value="$!escapetool.xml($currentValue)" 177 - />$services.localization.render('attachmentSelector.replace', 178 - ["<strong>$!escapetool.xml($currentValue)</strong>"]) 179 - </label> 180 - <span class="xHint">$escapetool.xml($services.localization.render('attachmentSelector.replace.hint'))</span> 181 - </div> 182 - #end 183 - #if ($xwiki.hasEditComment() && $options.versionSummary) 184 - <div> 185 - #if ($xwiki.isEditCommentFieldHidden()) 186 - <input type="hidden" name="comment" value="$!escapetool.xml($request.comment)" /> 187 - #else 188 - <label for="commentinput">$services.localization.render('core.comment')</label> 189 - <input type="text" name="comment" id="commentinput" value="$!escapetool.xml($request.comment)" 190 - title="$services.localization.render('core.comment.tooltip')" /> 191 - #end 192 - </div> 193 - #end 194 194 <div class="buttons"> 195 195 <span class="buttonwrapper"> 196 196 <input type="submit" name="action_upload" class="button " value='$services.localization.render("${translationPrefix}.upload.submit")' title='$services.localization.render("${translationPrefix}.upload.submit")'/> ... ... @@ -234,6 +234,11 @@ 234 234 235 235 {{velocity}} 236 236 #if ($request.docname) 208 + ###if ($request.xpage == 'plain') 209 + ## ## IE6 + XHR + gzip compression = BOOM! 210 + ## ## This disables the automatic gzip compression 211 + ## $response.setContentType('multipart/formdata') 212 + ###end 237 237 #set ($targetDocument = $xwiki.getDocument($request.docname)) 238 238 #if ($request.targetdocname) 239 239 ## Use the target document if it exists. ... ... @@ -289,8 +289,7 @@ 289 289 'defaultValue' : "$!{request.defaultValue}", 290 290 'rawfilter': "$!{rawfilter}", 291 291 'filter': ${filter}, 292 - 'sortAttachmentsBy': ${sortAttachmentsBy}, 293 - 'versionSummary': $request.versionSummary.equals('true') 268 + 'sortAttachmentsBy': ${sortAttachmentsBy} 294 294 }) 295 295 $!targetDocument.use($targetDocument.getObject($options.classname, $options.object))## 296 296 #attachmentPicker_displayAttachmentGallery($targetDocument, $targetAttachDocument, $options)
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -40,7 +40,7 @@ 40 40 * and saves the underlying form (if any) so that any unsaved changes won't be lost. 41 41 */ 42 42 filterFormUpload : function() { 43 - this.gallery.select('.uploadAttachment input [type="file"]').each(function(fileInput) {43 + this.gallery.select('.uploadAttachment input.attachment').each(function(fileInput) { 44 44 fileInput.__allowedExtensions = fileInput.title.toLowerCase().replace(/\s*[,|; ]\s*/g, " ").strip(); 45 45 if (fileInput.__allowedExtensions != '') { 46 46 fileInput.__allowedExtensions = fileInput.__allowedExtensions.split(" "); ... ... @@ -52,7 +52,7 @@ 52 52 event.stop(); 53 53 var uploadForm = event.element(); 54 54 var hasErrors = false; 55 - uploadForm.select('input [type="file"]').each(function(fileInput) {55 + uploadForm.select('input.attachment').each(function(fileInput) { 56 56 if (fileInput.value == '') { 57 57 new XWiki.widgets.Notification("$services.localization.render('xe.attachmentSelector.upload.error.noFile')", 'error'); 58 58 hasErrors = true; ... ... @@ -68,7 +68,7 @@ 68 68 uploadForm.submit(); 69 69 } else { 70 70 // FIXME This fails in HTML5, will deal with it later: 71 - // this.property.down('input').value = uploadForm.down(' input[type="file"]').value;71 + // this.property.down('input').value = uploadForm.down('.attachment').value; 72 72 // uploadForm.xredirect.value = window.location.pathname; 73 73 document.observe('xwiki:document:saved', function() { 74 74 new XWiki.widgets.Notification("$services.localization.render('xe.attachmentSelector.upload.inProgress')", 'inprogress'); ... ... @@ -117,11 +117,6 @@ 117 117 if (this.gallery.down('.gallery_emptyChoice')) { 118 118 this.gallery.down('.gallery_emptyChoice').addClassName('current'); 119 119 } 120 - // Disable the replace feature because there's no selection. 121 - var fileNameInput = this.gallery.down('input[type="checkbox"][name="filename"]'); 122 - fileNameInput.disabled = true; 123 - // Empty the displayed selected file name. 124 - fileNameInput.up('label').down('strong').update(''); 125 125 if (!this.directSave) { 126 126 this.property.down('input').value = this.defaultValue; 127 127 } ... ... @@ -275,7 +275,11 @@ 275 275 ); 276 276 dialog.shortcuts.close.keys = []; 277 277 dialog.showDialog(); 278 - dialog.dialog.down().setStyle({position: "fixed"}); 273 + if (window.browser.isIE6x) { 274 + dialog.dialog.down().setStyle({position: "absolute"}); 275 + } else { 276 + dialog.dialog.down().setStyle({position: "fixed"}); 277 + } 279 279 dialog.dialog.setStyle({top: document.viewport.getScrollOffsets().top + "px", position: "absolute"}); 280 280 dialog.dialogBox.setStyle({overflow: "hidden", width: "80%", margin: "0 10%"}); 281 281 new Ajax.Updater(loading.up(), url, {
- XWiki.StyleSheetExtension[0]
-
- Code
-
... ... @@ -10,6 +10,11 @@ 10 10 #set ($imgSize = $mathtool.sub($boxSize, $mathtool.mul($boxPadding, 2))) 11 11 #set ($actionsHeight = 20) 12 12 #set ($actionsWidth = 16) 13 +#macro (__css3 $rule) 14 + ${rule}; 15 + -moz-${rule}; 16 + -webkit-${rule}; 17 +#end 13 13 /*--------------------------------------------------------*/ 14 14 /* Attachment picker layout fixes */ 15 15 .attachment-picker p { ... ... @@ -27,7 +27,7 @@ 27 27 .gallery_attachmentbox { 28 28 background: $theme.pageContentBackgroundColor; 29 29 border: 1px solid $theme.borderColor; 30 - border-radius: 5px ;35 + #__css3('border-radius: 5px') 31 31 float: left; 32 32 margin: ${boxMargin}px; 33 33 overflow: hidden; ... ... @@ -34,11 +34,19 @@ 34 34 position: relative; 35 35 width: ${boxSize}px; 36 36 } 42 +/* Broken IE6 box model, add the border width to the total width. */ 43 +* html .gallery_attachmentbox { 44 + width: ${mathtool.add($boxSize, 2)}px; 45 +} 37 37 .gallery .current { 38 38 background-color: $theme.highlightColor; 39 39 border-width: 3px; 40 40 margin: 3px; 41 41 } 51 +/* Broken IE6 box model, add the border width to the total width. */ 52 +* html .gallery .current { 53 + width: ${mathtool.add($boxSize, 6)}px; 54 +} 42 42 .gallery .current .gallery_attachmenttitle { 43 43 font-weight: bold; 44 44 } ... ... @@ -49,7 +49,7 @@ 49 49 .gallery_attachmenttitle { 50 50 background: $theme.backgroundSecondaryColor; 51 51 border-bottom: 1px dotted $theme.borderColor; 52 - border-radius: 5px 5px 0px 0px ;65 + #__css3('border-radius: 5px 5px 0px 0px') 53 53 font-size: 85%; 54 54 padding: 3px ${boxPadding}px; 55 55 overflow: hidden; ... ... @@ -153,29 +153,24 @@ 153 153 background-repeat: no-repeat; 154 154 padding-left: 16px; 155 155 } 156 -.gallery_upload .gallery_attachmentframe{157 - height: auto;169 +.gallery_upload form { 170 + height: ${imgSize}px; 158 158 } 159 -.gallery_upload _input {160 - margin-bottom:10px;172 +.gallery_upload .xHint { 173 + text-transform: none !important; 161 161 } 162 -.gallery_upload input[type="file"] { 163 - font-size: 86%; 175 +.gallery_upload input.attachment { 176 + font-size: 83.3%; 177 + margin: 0; /* Overrides viewers/attachments.css */ 178 + padding: 0; /* Overrides viewers/attachments.css */ 164 164 width: ${mathtool.sub($uploadBoxSize, $mathtool.mul($boxPadding, 2))}px; 165 165 } 166 166 .gallery_upload .buttonwrapper { 167 167 margin: 0; 168 168 } 169 -.gallery_upload .button, 170 -.gallery_upload label { 171 - font-size: 86%; 184 +.gallery_upload .button { 185 + font-size: .65em; 172 172 } 173 -.gallery_upload input[type="checkbox"] { 174 - vertical-align: text-bottom; 175 -} 176 -.gallery_upload label[for="commentinput"] { 177 - margin-top: 10px; 178 -} 179 179 180 180 /* ------------------------------------ */ 181 181 /* Buttons on top: */
- XWiki.WikiMacroClass[0]
-
- Macro code
-
... ... @@ -123,24 +123,7 @@ 123 123 ## 1. Edit the current page 124 124 ## 2. View the target attachment page. (can be the same page) 125 125 #macro (attachmentPicker_displayButton) 126 - #if ($hasEdit && $targetPermView) 127 - #set ($queryString = { 128 - 'docname': $doc.fullName, 129 - 'classname': $classname, 130 - 'property': $property, 131 - 'object': $object, 132 - 'savemode': $savemode, 133 - 'defaultValue': $defaultValue, 134 - 'filter': $filter, 135 - 'displayImage': $displayImage, 136 - 'versionSummary': $xcontext.macro.params.versionSummary.equals('true') 137 - }) 138 - #if ($hasTargetDoc) 139 - #set ($queryString.targetdocname = $targetdoc.fullName) 140 - #end 141 - (% class="buttonwrapper" %)[[$buttontext>>$xcontext.macro.doc.fullName||queryString="$escapetool.url($queryString)" 142 - class="attachment-picker-start button" title="$buttontext"]](%%)## 143 - #end 126 + #if ($hasEdit && $targetPermView)(% class="buttonwrapper" %)[[${buttontext}>>${xcontext.macro.doc.fullName}||queryString="#if ($hasTargetDoc)targetdocname=${escapetool.url($targetdoc.fullName)}&#{end}docname=${escapetool.url($doc.fullName)}&classname=${classname}&property=${property}&object=${object}&savemode=${savemode}&defaultValue=$escapetool.url($defaultValue)&filter=$!{filter}&displayImage=${displayImage}" class="attachment-picker-start button" title="${buttontext}"]](%%)#end 144 144 #end 145 145 {{/velocity}} 146 146 - Default category
-
... ... @@ -1,1 +1,0 @@ 1 -Development
- XWiki.WikiMacroParameterClass[19]
-
- Parameter default value
-
... ... @@ -1,1 +1,0 @@ 1 -false - Parameter description
-
... ... @@ -1,1 +1,0 @@ 1 -Whether to allow the user to enter a version summary that will be recorded in the history. An automatic message is used when no version summary is provided or if the version summary input is not displayed. - Parameter mandatory
-
... ... @@ -1,1 +1,0 @@ 1 -No - Parameter name
-
... ... @@ -1,1 +1,0 @@ 1 -versionSummary