Código fuente wiki de $services.localization.render('platform.appwithinminutes.appNamePageTitle')
Versión 2.1 por Administrator el 2024/06/05 19:09
Ocultar los últimos autores
| author | version | line-number | content |
|---|---|---|---|
| |
?.? | 1 | {{include reference="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 | #set($appName = $request.appName) | ||
| 37 | #getAppDescriptor($appName) | ||
| 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. | ||
| 45 | #set($className = "#toXMLName($appName)") | ||
| 46 | #set($classRef = $services.model.createDocumentReference($doc.wiki, "${className}Code", "${className}Class")) | ||
| 47 | #end | ||
| 48 | #set($queryString = 'wizard=true') | ||
| 49 | #if(!$xwiki.exists($classRef)) | ||
| 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)") | ||
| 54 | #end | ||
| 55 | $response.sendRedirect($xwiki.getURL($classRef, 'edit', $queryString)) | ||
| 56 | #end | ||
| 57 | |||
| 58 | #macro(validateAppName $appName) | ||
| 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 == '') | ||
| 70 | (% class="xErrorMsg" %)$services.localization.render('platform.appwithinminutes.appNameInvalidClassNameError') | ||
| 71 | #end | ||
| 72 | #set($appHomeRef = $services.model.createDocumentReference($doc.wiki, $appName, 'WebHome')) | ||
| 73 | #set($appClassRef = $services.model.createDocumentReference($doc.wiki, "$!{className}Code", "$!{className}Class")) | ||
| 74 | #end | ||
| 75 | #set($appHomeURL = $stringtool.removeEnd($xwiki.getDocument($appHomeRef).getExternalURL(), 'WebHome')) | ||
| 76 | ; $services.localization.render('platform.appwithinminutes.appNamePreviewHomePageUrlLabel') | ||
| 77 | : {{{$!appHomeURL}}} | ||
| 78 | ; $services.localization.render('platform.appwithinminutes.appNamePreviewDataSpaceLabel') | ||
| 79 | : {{{$appHomeRef.wikiReference.name}}} » {{{$appHomeRef.lastSpaceReference.name}}} | ||
| 80 | ; $services.localization.render('platform.appwithinminutes.appNamePreviewCodeSpaceLabel') | ||
| 81 | : {{{$appClassRef.wikiReference.name}}} » {{{$appClassRef.lastSpaceReference.name}}} | ||
| 82 | ; $services.localization.render('platform.appwithinminutes.appNamePreviewClassReferenceLabel') | ||
| 83 | : {{{$appClassRef.wikiReference.name}}} » {{{$appClassRef.lastSpaceReference.name}}} » {{{$appClassRef.name}}} | ||
| 84 | #if($appDescriptor || $xwiki.exists($appHomeRef) || $xwiki.exists($appClassRef)) | ||
| 85 | |||
| 86 | {{warning}}$services.localization.render('platform.appwithinminutes.appNameIsUsedWarning'){{/warning}} | ||
| 87 | #end | ||
| 88 | #end | ||
| 89 | {{/velocity}} | ||
| 90 | |||
| 91 | {{velocity}} | ||
| 92 | #if("$!request.appName" != '') | ||
| 93 | #if($xcontext.action == 'get') | ||
| 94 | #validateAppName($request.appName) | ||
| 95 | #else | ||
| 96 | ## CSRF protection is not needed because this step only redirects to the next one passing data in the query string. | ||
| 97 | #processStep() | ||
| 98 | #end | ||
| 99 | #else | ||
| 100 | #showStep() | ||
| 101 | #end | ||
| 102 | {{/velocity}} |