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