Depuis la version 1.1 >
modifié par Administrator
sur 2013/06/04 10:05
À la version < 6.1 >
modifié par superadmin
sur 2021/12/12 21:39
>
Commentaire de modification : Migrated property [priority] from class [XWiki.WikiMacroClass]

Résumé

Détails

Icon Propriétés de la Page
Auteur du document
... ... @@ -1,1 +1,1 @@
1 -XWiki.Admin
1 +XWiki.superadmin
Contenu
... ... @@ -1,9 +1,12 @@
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,7 +10,11 @@
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, "$!{fieldname}=$!{lastAttachment.filename}&form_token=$!{escapetool.url($request.get('form_token'))}"))
16 + $response.sendRedirect($targetDocument.getURL($docAction, $escapetool.url({
17 + $fieldname: $lastAttachment.filename,
18 + 'comment': $comment,
19 + 'form_token': $request.form_token
20 + })))
14 14   #stop
15 15  #end
16 16  {{/velocity}}
... ... @@ -19,7 +19,6 @@
19 19  ##
20 20  ## Macros
21 21  ##
22 -#set ($translationPrefix = 'xe.attachmentSelector')
23 23  #set ($attachmentPickerDocName = 'XWiki.AttachmentSelector')
24 24  
25 25  $xwiki.ssx.use($attachmentPickerDocName)
... ... @@ -99,14 +99,19 @@
99 99   *#
100 100  #macro (attachmentPicker_displayAttachmentDetails $attachment $options)
101 101   #if ($attachment)
108 + ## Compute the attachment reference because there's no getter.
109 + #set ($attachmentReference = $services.model.createAttachmentReference($attachment.document.documentReference,
110 + $attachment.filename))
111 + #set ($attachmentStringReference = $services.model.serialize($attachmentReference, 'default'))
102 102   #if ($attachment.isImage() && $options.displayImage)
103 - #set ($attachmentDocument = $attachment.getDocument())
104 -[[[[image:${attachmentDocument.fullName}@${attachment.filename}||width=160]]>>attach:${attachmentDocument.fullName}@${attachment.filename}||rel="lightbox[attachments]"]]
113 + ## We add the version to the query string in order to invalidate the cache when an image attachment is replaced.
114 + #set ($queryString = $escapetool.url({'version': $attachment.version}))
115 + [[[[image:$attachmentStringReference||width=180 queryString="$queryString"]]>>attach:$attachmentStringReference]]
105 105   #else
106 106   * (% class="mime" %){{html wiki=false clean=false}}#mimetypeimg($attachment.getMimeType().toLowerCase() $attachment.getFilename().toLowerCase()){{/html}}(%%) (% class="filename" %)$attachment.getFilename()(% %)
107 - * v$attachment.getVersion() (#dynamicsize($attachment.filesize))
118 + * v$attachment.getVersion() (#dynamicsize($attachment.longSize))
108 108   * $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')}])
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"]](%%)
120 + * (% class="buttonwrapper" %)[[${services.localization.render("${translationPrefix}.actions.download")}>>attach:$attachmentStringReference||title="$services.localization.render("${translationPrefix}.actions.download")" rel="__blank" class="button"]](%%)
110 110   #end
111 111   #end
112 112  #end
... ... @@ -152,9 +152,9 @@
152 152  <form action="$targetAttachDocument.getURL('upload')" enctype="multipart/form-data" method="post" id="uploadAttachment" class="uploadAttachment xform">
153 153   <div class="gallery_upload_input">
154 154   #if (${options.rawfilter} != '')
155 - <span class="xHint">$services.localization.render("${translationPrefix}.upload.hint", [${options.rawfilter}])</span>
166 + <span class="xHint">$escapetool.xml($services.localization.render("${translationPrefix}.upload.hint", [${options.rawfilter}]))</span>
156 156   #end
157 - <input type="file" name="filepath" id="attachfile" class="attachment" size="30" title="$!{escapetool.xml($options.rawfilter)}"/>
168 + <input type="file" name="filepath" id="attachfile" class="noitems" title="$!{escapetool.xml($options.rawfilter)}"/>
158 158   <input type="hidden" name="xredirect" value="$xwiki.getDocument($attachmentPickerDocName).getURL('get', "xaction=postUpload&amp;docAction=$!{escapetool.url($options.get('docAction'))}&amp;targetdocname=$!{escapetool.url($targetAttachDocument.fullName)}&amp;docname=$!{escapetool.url($targetDocument.fullName)}&amp;fieldname=$!{escapetool.url($options.get('classname'))}_$!{escapetool.url($options.get('object'))}_$!{escapetool.url($options.get('property'))}&amp;form_token=$!{services.csrf.getToken()}")" />
159 159   <input type="hidden" name="docname" value="$!{escapetool.xml($targetDocument.fullName)}" />
160 160   <input type="hidden" name="classname" value="$!{escapetool.xml($options.get('classname'))}" />
... ... @@ -162,6 +162,27 @@
162 162   <input type="hidden" name="property" value="$!{escapetool.xml($options.get('property'))}" />
163 163   <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
164 164   </div>
176 + #if ("$!currentValue" != '' && $currentValue != $options.defaultValue)
177 + <div>
178 + <label>
179 + <input type="checkbox" name="filename" value="$!escapetool.xml($currentValue)"
180 + />$services.localization.render('attachmentSelector.replace',
181 + ["<strong>$!escapetool.xml($currentValue)</strong>"])
182 + </label>
183 + <span class="xHint">$escapetool.xml($services.localization.render('attachmentSelector.replace.hint'))</span>
184 + </div>
185 + #end
186 + #if ($xwiki.hasEditComment() && $options.versionSummary)
187 + <div>
188 + #if ($xwiki.isEditCommentFieldHidden())
189 + <input type="hidden" name="comment" value="$!escapetool.xml($request.comment)" />
190 + #else
191 + <label for="commentinput">$services.localization.render('core.comment')</label>
192 + <input type="text" name="comment" id="commentinput" value="$!escapetool.xml($request.comment)"
193 + title="$services.localization.render('core.comment.tooltip')" />
194 + #end
195 + </div>
196 + #end
165 165   <div class="buttons">
166 166   <span class="buttonwrapper">
167 167   <input type="submit" name="action_upload" class="button " value='$services.localization.render("${translationPrefix}.upload.submit")' title='$services.localization.render("${translationPrefix}.upload.submit")'/>
... ... @@ -205,11 +205,6 @@
205 205  
206 206  {{velocity}}
207 207  #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
213 213   #set ($targetDocument = $xwiki.getDocument($request.docname))
214 214   #if ($request.targetdocname)
215 215   ## Use the target document if it exists.
... ... @@ -265,7 +265,8 @@
265 265   'defaultValue' : "$!{request.defaultValue}",
266 266   'rawfilter': "$!{rawfilter}",
267 267   'filter': ${filter},
268 - 'sortAttachmentsBy': ${sortAttachmentsBy}
295 + 'sortAttachmentsBy': ${sortAttachmentsBy},
296 + 'versionSummary': $request.versionSummary.equals('true')
269 269   })
270 270   $!targetDocument.use($targetDocument.getObject($options.classname, $options.object))##
271 271   #attachmentPicker_displayAttachmentGallery($targetDocument, $targetAttachDocument, $options)
Icon 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.attachment').each(function(fileInput) {
43 + this.gallery.select('.uploadAttachment input[type="file"]').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.attachment').each(function(fileInput) {
55 + uploadForm.select('input[type="file"]').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('.attachment').value;
71 + // this.property.down('input').value = uploadForm.down('input[type="file"]').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,6 +117,11 @@
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('');
120 120   if (!this.directSave) {
121 121   this.property.down('input').value = this.defaultValue;
122 122   }
... ... @@ -270,11 +270,7 @@
270 270   );
271 271   dialog.shortcuts.close.keys = [];
272 272   dialog.showDialog();
273 - if (window.browser.isIE6x) {
274 - dialog.dialog.down().setStyle({position: "absolute"});
275 - } else {
276 - dialog.dialog.down().setStyle({position: "fixed"});
277 - }
278 + dialog.dialog.down().setStyle({position: "fixed"});
278 278   dialog.dialog.setStyle({top: document.viewport.getScrollOffsets().top + "px", position: "absolute"});
279 279   dialog.dialogBox.setStyle({overflow: "hidden", width: "80%", margin: "0 10%"});
280 280   new Ajax.Updater(loading.up(), url, {
Icon XWiki.StyleSheetExtension[0]
Code
... ... @@ -10,11 +10,6 @@
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
18 18  /*--------------------------------------------------------*/
19 19  /* Attachment picker layout fixes */
20 20  .attachment-picker p {
... ... @@ -32,7 +32,7 @@
32 32  .gallery_attachmentbox {
33 33   background: $theme.pageContentBackgroundColor;
34 34   border: 1px solid $theme.borderColor;
35 - #__css3('border-radius: 5px')
30 + border-radius: 5px;
36 36   float: left;
37 37   margin: ${boxMargin}px;
38 38   overflow: hidden;
... ... @@ -39,19 +39,11 @@
39 39   position: relative;
40 40   width: ${boxSize}px;
41 41  }
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 -}
46 46  .gallery .current {
47 47   background-color: $theme.highlightColor;
48 48   border-width: 3px;
49 49   margin: 3px;
50 50  }
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 -}
55 55  .gallery .current .gallery_attachmenttitle {
56 56   font-weight: bold;
57 57  }
... ... @@ -62,7 +62,7 @@
62 62  .gallery_attachmenttitle {
63 63   background: $theme.backgroundSecondaryColor;
64 64   border-bottom: 1px dotted $theme.borderColor;
65 - #__css3('border-radius: 5px 5px 0px 0px')
52 + border-radius: 5px 5px 0px 0px;
66 66   font-size: 85%;
67 67   padding: 3px ${boxPadding}px;
68 68   overflow: hidden;
... ... @@ -166,24 +166,29 @@
166 166   background-repeat: no-repeat;
167 167   padding-left: 16px;
168 168  }
169 -.gallery_upload form {
170 - height: ${imgSize}px;
156 +.gallery_upload .gallery_attachmentframe {
157 + height: auto;
171 171  }
172 -.gallery_upload .xHint {
173 - text-transform: none !important;
159 +.gallery_upload_input {
160 + margin-bottom: 10px;
174 174  }
175 -.gallery_upload input.attachment {
176 - font-size: 83.3%;
177 - margin: 0; /* Overrides viewers/attachments.css */
178 - padding: 0; /* Overrides viewers/attachments.css */
162 +.gallery_upload input[type="file"] {
163 + font-size: 86%;
179 179   width: ${mathtool.sub($uploadBoxSize, $mathtool.mul($boxPadding, 2))}px;
180 180  }
181 181  .gallery_upload .buttonwrapper {
182 182   margin: 0;
183 183  }
184 -.gallery_upload .button {
185 - font-size: .65em;
169 +.gallery_upload .button,
170 +.gallery_upload label {
171 + font-size: 86%;
186 186  }
173 +.gallery_upload input[type="checkbox"] {
174 + vertical-align: text-bottom;
175 +}
176 +.gallery_upload label[for="commentinput"] {
177 + margin-top: 10px;
178 +}
187 187  
188 188  /* ------------------------------------ */
189 189  /* Buttons on top: */
Icon XWiki.WikiMacroClass[0]
Mis en cache
... ... @@ -1,0 +1,1 @@
1 +Non
Rendu asynchrone
... ... @@ -1,0 +1,1 @@
1 +Non
Code de la macro
... ... @@ -123,7 +123,24 @@
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)(% 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
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
127 127  #end
128 128  {{/velocity}}
129 129  
... ... @@ -130,7 +130,7 @@
130 130  {{velocity}}
131 131  #if ("${savemode}" == 'direct')
132 132   (% class="attachment-picker" %)(((#attachmentPicker_displayAttachment($propValue $displayImage $link true) #attachmentPicker_displayButton())))
133 -#elseif ($context.action == 'inline' || $context.action == 'edit')
150 +#elseif ($xcontext.action == 'inline' || $xcontext.action == 'edit')
134 134   (% class="attachment-picker" %)(((##
135 135   #attachmentPicker_displayAttachment($propValue $displayImage false true) #attachmentPicker_displayButton()##
136 136   {{html}}<input type="hidden" name="${classname}_${object}_${property}" value="${propValue}"/>{{/html}}##
Catégorie par défaut
... ... @@ -1,0 +1,1 @@
1 +Development
Icon XWiki.WikiMacroParameterClass[0]
Type du paramètre
... ... @@ -1,0 +1,1 @@
1 +org.xwiki.model.reference.DocumentReference
Icon XWiki.WikiMacroParameterClass[10]
Type du paramètre
... ... @@ -1,0 +1,1 @@
1 +org.xwiki.model.reference.AttachmentReference
Icon XWiki.WikiMacroParameterClass[18]
Type du paramètre
... ... @@ -1,0 +1,1 @@
1 +org.xwiki.model.reference.DocumentReference
Icon XWiki.WikiMacroParameterClass[19]
Valeur par défaut du paramètre
... ... @@ -1,0 +1,1 @@
1 +false
Description du paramètre
... ... @@ -1,0 +1,1 @@
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.
Paramètre obligatoire
... ... @@ -1,0 +1,1 @@
1 +Non
Nom du paramètre
... ... @@ -1,0 +1,1 @@
1 +versionSummary
This wiki is licensed under a Creative Commons 2.0 license
XWiki 13.10 - Documentation - Conditions