Wiki source code of CreateForm
Last modified by superadmin on 2019/11/08 17:56
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{include reference="AnnotationCode.Macros" /}} | ||
2 | |||
3 | {{velocity output="false"}} | ||
4 | #if ("$!{request.reference}" != '') | ||
5 | #set($annotationReference = $services.model.resolveDocument($request.reference)) | ||
6 | #elseif("$!{request.wiki}" != '' && "$!{request.space}" != '' && "$!{request.page}" != '') | ||
7 | #set($annotationReference = $services.model.createDocumentReference("$!{request.wiki}", "$!{request.space}", "$!{request.page}")) | ||
8 | #end | ||
9 | {{/velocity}} | ||
10 | |||
11 | {{velocity}} | ||
12 | #if(!$annotationReference) | ||
13 | {{warning}}$services.localization.render('annotations.action.create.error.notarget'){{/warning}} | ||
14 | #else | ||
15 | ## 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 | ||
16 | #if(!$services.annotations.canAddAnnotation($annotationReference)) | ||
17 | #set($message = $services.localization.render('annotations.action.create.error.unauthorized')) | ||
18 | #if ($xcontext.user.equals("XWiki.XWikiGuest")) | ||
19 | #set($message = $services.localization.render('annotations.action.create.error.unauthorizedguest')) | ||
20 | #end | ||
21 | ## unauthorized, with a nice i18n message | ||
22 | $response.sendError(401, $message) | ||
23 | #end | ||
24 | |||
25 | {{html}} | ||
26 | ## get create a hashmap with request data about the selection | ||
27 | #set($annData = {}) | ||
28 | #set($dispose = $annData.put("selection", $!request.selection)) | ||
29 | #set($dispose = $annData.put("selectionContext", $!request.selectionContext)) | ||
30 | #set($dispose = $annData.put("selectionOffset", $!request.selectionOffset)) | ||
31 | ## pretend that annotation author is current user, and annotation date is now | ||
32 | ##Even if they get sent to the server, the server will overwrite with anything's logged in in there anyway | ||
33 | #set($dispose = $annData.put("author", $xcontext.user)) | ||
34 | #set($dispose = $annData.put("date", $datetool.date)) | ||
35 | #displayCreateBoxFromReference($annotationReference, $annData) | ||
36 | {{/html}} | ||
37 | #end | ||
38 | {{/velocity}} |