Version 8.1 by Vincent Massol on 2013/10/15

Hide last authors
Vincent Massol 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 (((
Marius Dumitru Florea 7.1 9 **$services.localization.render('platform.appwithinminutes.wizardStepHelpTitle')** $services.localization.render('platform.appwithinminutes.wizardStepHelpDescription')
Vincent Massol 5.1 10 (% class="steps vertical" %)
Vincent Massol 1.1 11 #foreach($index in [1, 2, 3])
Marius Dumitru Florea 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")
Vincent Massol 1.1 14 #end
15 )))
16 <form action="" method="post" class="xform wizard-body">
Marius Dumitru Florea 7.1 17 ; <label for="appName">$services.localization.render('platform.appwithinminutes.appNameLabel')</label>
18 (% class="xHint" %)$services.localization.render('platform.appwithinminutes.appNameHint')
Vincent Massol 1.1 19 : <input type="text" id="appName" name="appName" />
20 #appWizardFooter(1)
21 </form>
22 {{/html}}
23 #end
24
Vincent Massol 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
Vincent Massol 1.1 34 #macro(processStep)
Vincent Massol 5.1 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
Vincent Massol 1.1 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)
Vincent Massol 5.1 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 == '')
Marius Dumitru Florea 7.1 66 (% class="xErrorMsg" %)$services.localization.render('platform.appwithinminutes.appNameInvalidClassNameError')
Vincent Massol 5.1 67 #end
68 #set($appHomeRef = $services.model.createDocumentReference($doc.wiki, $appName, 'WebHome'))
69 #set($appClassRef = $services.model.createDocumentReference($doc.wiki, $appName, "$!{className}Class"))
Vincent Massol 1.1 70 #end
Marius Dumitru Florea 6.1 71 #set($appHomeURL = $stringtool.removeEnd($xwiki.getDocument($appHomeRef).getExternalURL(), 'WebHome'))
Marius Dumitru Florea 7.1 72 ; $services.localization.render('platform.appwithinminutes.appNamePreviewHomePageUrlLabel')
Vincent Massol 5.1 73 : {{{$!appHomeURL}}}
Marius Dumitru Florea 7.1 74 ; $services.localization.render('platform.appwithinminutes.appNamePreviewDataSpaceLabel')
Vincent Massol 1.1 75 : {{{$doc.wiki}}} » {{{$appName}}}
Marius Dumitru Florea 7.1 76 ; $services.localization.render('platform.appwithinminutes.appNamePreviewClassReferenceLabel')
Vincent Massol 5.1 77 : {{{$appClassRef.wikiReference.name}}} » {{{$appClassRef.lastSpaceReference.name}}} » {{{$appClassRef.name}}}
78 #if($appDescriptor || $xwiki.exists($appHomeRef) || $xwiki.exists($appClassRef))
Vincent Massol 1.1 79
Marius Dumitru Florea 7.1 80 {{warning}}$services.localization.render('platform.appwithinminutes.appNameIsUsedWarning'){{/warning}}
Vincent Massol 1.1 81 #end
82 #end
83 {{/velocity}}
84
85 {{velocity}}
86 #if("$!request.appName" != '')
Vincent Massol 8.1 87 #if($xcontext.action == 'get')
Vincent Massol 1.1 88 #validateAppName($request.appName)
Vincent Massol 5.1 89 #else
90 ## CSRF protection is not needed because this step only redirects to the next one passing data in the query string.
Vincent Massol 1.1 91 #processStep()
92 #end
93 #else
94 #showStep()
95 #end
96 {{/velocity}}

Get Connected