Wiki source code of $services.localization.render('platform.appwithinminutes.appNamePageTitle')
Version 11.1 by Guillaume Delhumeau on 2015/06/24
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
9.1 | 1 | {{include reference="AppWithinMinutes.WizardStep"/}} |
![]() |
1.1 | 2 | |
3 | {{velocity output="false"}} | ||
4 | #macro(showStep) | ||
5 | {{html wiki="true"}} | ||
6 | #appWizardHeader(1) | ||
7 | (% class="wizard-help" %) | ||
8 | ((( | ||
![]() |
7.1 | 9 | **$services.localization.render('platform.appwithinminutes.wizardStepHelpTitle')** $services.localization.render('platform.appwithinminutes.wizardStepHelpDescription') |
![]() |
5.1 | 10 | (% class="steps vertical" %) |
![]() |
1.1 | 11 | #foreach($index in [1, 2, 3]) |
![]() |
7.1 | 12 | * (% class="number" %)$index(%%) (% class="name" %)$services.localization.render("platform.appwithinminutes.wizardStep${index}Name")(%%) |
13 | (% class="description" %)$services.localization.render("platform.appwithinminutes.wizardStep${index}Description") | ||
![]() |
1.1 | 14 | #end |
15 | ))) | ||
![]() |
11.1 | 16 | <form action="$doc.getURL()" method="post" class="xform wizard-body"> |
![]() |
7.1 | 17 | ; <label for="appName">$services.localization.render('platform.appwithinminutes.appNameLabel')</label> |
18 | (% class="xHint" %)$services.localization.render('platform.appwithinminutes.appNameHint') | ||
![]() |
1.1 | 19 | : <input type="text" id="appName" name="appName" /> |
20 | #appWizardFooter(1) | ||
21 | </form> | ||
22 | {{/html}} | ||
23 | #end | ||
24 | |||
![]() |
5.1 | 25 | #macro(getAppDescriptor $appName) |
26 | #set($appDescriptorClassName = 'AppWithinMinutes.LiveTableClass') | ||
27 | #set($appDescriptorStatement = "from doc.object($appDescriptorClassName) as obj where doc.space = :space") | ||
28 | #set($appDescriptors = $services.query.xwql($appDescriptorStatement).bindValue('space', $appName).execute()) | ||
29 | #if($appDescriptors.size() > 0) | ||
30 | #set($appDescriptor = $xwiki.getDocument($appDescriptors.get(0))) | ||
31 | #end | ||
32 | #end | ||
33 | |||
![]() |
1.1 | 34 | #macro(processStep) |
![]() |
5.1 | 35 | ## Check if the application already exists. |
![]() |
10.1 | 36 | #set($appName = $request.appName) |
37 | #getAppDescriptor($appName) | ||
![]() |
5.1 | 38 | #if($appDescriptor) |
39 | ## Edit an existing application. Use the configured class name. | ||
40 | #set($classStringRef = $appDescriptor.getObject($appDescriptorClassName).getProperty('class').value) | ||
41 | ## The class string reference is relative to the document holding the application descriptor. | ||
42 | #set($classRef = $services.model.resolveDocument($classStringRef, 'explicit', $appDescriptor.documentReference)) | ||
43 | #else | ||
44 | ## Create a new application. Use the default class name. | ||
![]() |
10.1 | 45 | #set($className = "#toXMLName($appName)") |
46 | #set($classRef = $services.model.createDocumentReference($doc.wiki, "${className}Code", "${className}Class")) | ||
![]() |
5.1 | 47 | #end |
![]() |
1.1 | 48 | #set($queryString = 'wizard=true') |
49 | #if(!$xwiki.exists($classRef)) | ||
![]() |
10.1 | 50 | #set($classTitle = "$appName Class") |
51 | #set($appHomeRef = $services.model.createDocumentReference($doc.wiki, $appName, 'WebHome')) | ||
52 | #set($classParent = $services.model.serialize($appHomeRef)) | ||
53 | #set($queryString = "$queryString&editor=inline&template=AppWithinMinutes.ClassTemplate&parent=$escapetool.url($classParent)&title=$escapetool.url($classTitle)&AppWithinMinutes.MetadataClass_0_dataSpaceName=$escapetool.url($appName)") | ||
![]() |
1.1 | 54 | #end |
55 | $response.sendRedirect($xwiki.getURL($classRef, 'edit', $queryString)) | ||
56 | #end | ||
57 | |||
58 | #macro(validateAppName $appName) | ||
![]() |
5.1 | 59 | #getAppDescriptor("$!appName") |
60 | #if($appDescriptor) | ||
61 | ## Edit an existing application. | ||
62 | #set($appHomeRef = $appDescriptor.documentReference) | ||
63 | #set($classStringRef = $appDescriptor.getObject($appDescriptorClassName).getProperty('class').value) | ||
64 | ## The class string reference is relative to the document holding the application descriptor. | ||
65 | #set($appClassRef = $services.model.resolveDocument($classStringRef, 'explicit', $appDescriptor.documentReference)) | ||
66 | #else | ||
67 | ## Create a new application. | ||
68 | #set($className = "#toXMLName($appName)") | ||
69 | #if($className == '') | ||
![]() |
7.1 | 70 | (% class="xErrorMsg" %)$services.localization.render('platform.appwithinminutes.appNameInvalidClassNameError') |
![]() |
5.1 | 71 | #end |
72 | #set($appHomeRef = $services.model.createDocumentReference($doc.wiki, $appName, 'WebHome')) | ||
![]() |
10.1 | 73 | #set($appClassRef = $services.model.createDocumentReference($doc.wiki, "$!{className}Code", "$!{className}Class")) |
![]() |
1.1 | 74 | #end |
![]() |
6.1 | 75 | #set($appHomeURL = $stringtool.removeEnd($xwiki.getDocument($appHomeRef).getExternalURL(), 'WebHome')) |
![]() |
7.1 | 76 | ; $services.localization.render('platform.appwithinminutes.appNamePreviewHomePageUrlLabel') |
![]() |
5.1 | 77 | : {{{$!appHomeURL}}} |
![]() |
7.1 | 78 | ; $services.localization.render('platform.appwithinminutes.appNamePreviewDataSpaceLabel') |
![]() |
10.1 | 79 | : {{{$appHomeRef.wikiReference.name}}} » {{{$appHomeRef.lastSpaceReference.name}}} |
![]() |
9.1 | 80 | ; $services.localization.render('platform.appwithinminutes.appNamePreviewCodeSpaceLabel') |
![]() |
10.1 | 81 | : {{{$appClassRef.wikiReference.name}}} » {{{$appClassRef.lastSpaceReference.name}}} |
![]() |
7.1 | 82 | ; $services.localization.render('platform.appwithinminutes.appNamePreviewClassReferenceLabel') |
![]() |
5.1 | 83 | : {{{$appClassRef.wikiReference.name}}} » {{{$appClassRef.lastSpaceReference.name}}} » {{{$appClassRef.name}}} |
84 | #if($appDescriptor || $xwiki.exists($appHomeRef) || $xwiki.exists($appClassRef)) | ||
![]() |
1.1 | 85 | |
![]() |
7.1 | 86 | {{warning}}$services.localization.render('platform.appwithinminutes.appNameIsUsedWarning'){{/warning}} |
![]() |
1.1 | 87 | #end |
88 | #end | ||
89 | {{/velocity}} | ||
90 | |||
91 | {{velocity}} | ||
92 | #if("$!request.appName" != '') | ||
![]() |
8.1 | 93 | #if($xcontext.action == 'get') |
![]() |
1.1 | 94 | #validateAppName($request.appName) |
![]() |
5.1 | 95 | #else |
96 | ## CSRF protection is not needed because this step only redirects to the next one passing data in the query string. | ||
![]() |
1.1 | 97 | #processStep() |
98 | #end | ||
99 | #else | ||
100 | #showStep() | ||
101 | #end | ||
![]() |
10.1 | 102 | #set($docextras=[]) |
![]() |
1.1 | 103 | {{/velocity}} |