Wiki source code of CreateForm
Last modified by superadmin on 2025/09/10 13:22
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{template name="display_macros.vm" /}} | ||
| 2 | |||
| 3 | {{include reference="AnnotationCode.Macros" /}} | ||
| 4 | |||
| 5 | {{velocity}} | ||
| 6 | #if(!$annotationReference) | ||
| 7 | {{warning}}$services.localization.render('annotations.action.create.error.notarget'){{/warning}} | ||
| 8 | #else | ||
| 9 | ## pretty dirtish but it's so gonna do the job: don't display this form to users which don't have the right to create annotations, instead send a nice unauthorized message | ||
| 10 | #if(!$services.annotations.canAddAnnotation($annotationReference)) | ||
| 11 | #set($message = $services.localization.render('annotations.action.create.error.unauthorized')) | ||
| 12 | #if ($xcontext.user.equals("XWiki.XWikiGuest")) | ||
| 13 | #set($message = $services.localization.render('annotations.action.create.error.unauthorizedguest')) | ||
| 14 | #end | ||
| 15 | ## unauthorized, with a nice i18n message | ||
| 16 | $response.sendError(401, $message) | ||
| 17 | #end | ||
| 18 | |||
| 19 | {{html}} | ||
| 20 | ## get create a hashmap with request data about the selection | ||
| 21 | #set($annData = {}) | ||
| 22 | #set($dispose = $annData.put("selection", $!request.selection)) | ||
| 23 | #set($dispose = $annData.put("selectionContext", $!request.selectionContext)) | ||
| 24 | #set($dispose = $annData.put("selectionOffset", $!request.selectionOffset)) | ||
| 25 | ## pretend that annotation author is current user, and annotation date is now | ||
| 26 | ##Even if they get sent to the server, the server will overwrite with anything's logged in in there anyway | ||
| 27 | #set($dispose = $annData.put("author", $xcontext.user)) | ||
| 28 | #set($dispose = $annData.put("date", $datetool.date)) | ||
| 29 | ## The annotation creation form is loaded asynchronously so we need to send back also the required JavaScript and CSS | ||
| 30 | ## resources (besides the form HTML). | ||
| 31 | #initRequiredSkinExtensions() | ||
| 32 | #displayCreateBoxFromReference($annotationReference, $annData) | ||
| 33 | #getRequiredSkinExtensions($requiredSkinExtensions) | ||
| 34 | #set ($discard = $response.setHeader('X-XWIKI-HTML-HEAD', $requiredSkinExtensions)) | ||
| 35 | {{/html}} | ||
| 36 | #end | ||
| 37 | {{/velocity}} |