%PDF- %PDF-
Direktori : /home/waritko/jetty-distribution-9.4.21.v20190926/webapps/ROOT/templates/ |
Current File : //home/waritko/jetty-distribution-9.4.21.v20190926/webapps/ROOT/templates/createinline.vm |
## --------------------------------------------------------------------------------------------------------- ## This template is called by the create action which binds some context variables as it executes, based on ## the request and the current document. These variables can be used in this template: ## * $spaceReference - the space reference of the new document, read from the "spaceReference" parameter ## * $name - the name to use for the new document, read from the "name" parameter ## * $isSpace - true if we are creating a non-terminal document ($name is the space name), false if we are ## creating a terminal document ($name is the document name). Determined by the create action ## * $availableTemplateProviders - list of template provider documents available from the current space ## ## Note: Make sure to use these bindings instead of directly using the request parameters, as the bindings ## also consider backwards compatibility and convert older "space" and "page" parameters if they are passed. ## --------------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------------- ## This template can be passed a parent document reference in parameter (using the "parent" parameter). ## If a parent parameter is passed, use it to set the parent when creating the new page. ## If no parent parameter was passed, the create action will determine it to be the current document if it ## exists or the Main space's webhome if the current document does not exist. ## --------------------------------------------------------------------------------------------------------- #set ($parent = "$!request.getParameter('parent')") ## --------------------------------------------------------------------------------------------------------- ## This parent can be passed a title for the document to create (using the "title" parameter). ## The title is used to automatically compute a page name, which can then be customized by the user. ## If no title is given, the page name (if set) will be used as title. ## --------------------------------------------------------------------------------------------------------- #if ("$!request.title" != '') #set ($title = "$!request.title") #else #set ($title = "$!name") #end ## --------------------------------------------------------------------------------------------------------- ## Get the passed template provider, if any ## --------------------------------------------------------------------------------------------------------- #set($templateProvider = "$!request.templateprovider") ## Get the template as well, since in case template provider is missing, template should be used, ## to allow creation from template directly, without necessarily going through template provider. #set($template = "$!request.template") ## --------------------------------------------------------------------------------------------------------- ## If there was an exception creating the page because of invalid space, notify. ## Should set the other variables only if there is no exception. Otherwise, if there's an exception other than the ## 11016 one, nothing will be displayed, depending on the other passed parameters. ## --------------------------------------------------------------------------------------------------------- #set($exception = $createException) ## check if the exception is about the non-allowed spaces for template #if("$!exception" != '' && $exception.code == 11016) <div class="box errormessage"> #set($allowedSpaces = $createAllowedSpaces) #if ($allowedSpaces.size() == 1) $services.localization.render('core.create.template.allowedspace.inline', [$templateProvider, $allowedSpaces.get(0)]) #else $services.localization.render('core.create.template.allowedspaces.inline', [$templateProvider, $allowedSpaces.toString()]) #end </div> #end ## check if the exception is about the document which already exists #if("$!exception" != '' && $exception.code == 11002) <div class='box errormessage'> ## Use the 'existingDocumentReference' context binding set by the create action for this case. $services.localization.render('core.create.page.error.docalreadyexists', ["${existingDocumentReference}", $xwiki.getURL($existingDocumentReference, 'view', ''), $xwiki.getURL($existingDocumentReference, 'edit', '') ] ) </div> #end ## check if the exception is about the document having a path too long #template('hierarchy_macros.vm') #if("$!exception" != '' && $exception.code == 11017) #set ($options = {}) #set ($documentReference = $services.model.resolveDocument($tooLongPath)) <div class='box errormessage'> $services.localization.render('core.create.page.error.docpathtoolong', ["<p>#hierarchy($documentReference, $options)</p>", $doc.getLocalReferenceMaxLength(), $tooLongPath.length() ] ) </div> #end ## --------------------------------------------------------------------------------------------------------- ## Determine if we need to do extra checks for a deprecated, pre-NestedSpaces request to create a space. ## --------------------------------------------------------------------------------------------------------- #set ($deprecatedSpaceCreate = "$!request.tocreate" == 'space') ## --------------------------------------------------------------------------------------------------------- ## Note: The list of available template providers is computed in the action and set on the context under ## the "availableTemplateProviders" binding. ## --------------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------------- ## Macro for displaying the available types and templates and changing target space rules accordingly ## --------------------------------------------------------------------------------------------------------- #macro (displayTypes) #if ($template == '') #set ($blankTerminalState = !$isSpace) #set ($options = [ { 'name': $services.localization.render('core.create.type.default'), 'options': [ { 'name': $services.localization.render('core.create.type.blank'), 'value': 'blank', 'description': $services.localization.render('core.create.type.blank.description'), 'icon': 'file-white', 'data': { 'type': 'blank', 'terminal' : "$blankTerminalState" } } ] }]) #if ($xwiki.exists($services.model.createDocumentReference('', 'XWiki', 'OfficeImporter')) && "$!services.officemanager.serverState" == 'Connected') ## TODO: handle this use case with an extension point #set ($discard = $options[0].options.add({ 'name': $services.localization.render('office.createForm.type.name'), 'value': 'office', 'description': $services.localization.render('office.createForm.type.description'), 'icon': 'file-word', 'data': { 'type':'office' } })) #end #if (!$availableTemplateProviders.isEmpty()) #set ($templateOptions = []) #set ($discard = $options.add({'name': $services.localization.render('core.create.type.templates'), 'options': $templateOptions})) #foreach($tpdoc in $availableTemplateProviders) #set ($tpobj = $tpdoc.getObject('XWiki.TemplateProviderClass')) #set ($tpdocRef = $services.model.serialize($tpdoc.documentReference, 'local')) ## ## Extract and save in data-* attributes list of allowed spaces to be used in the JavaScript validation of the spaceReference input. ## #set($jsAllowedSpacesArray = '[]')## Reset any previous value #set($allowedSpaces = $tpobj.getValue('creationRestrictions')) #if($allowedSpaces.size() == 0) ## Backwards compatibility for Template Providers created before 8.3M2. #set($allowedSpaces = $tpobj.getValue('spaces')) #end ## Reset to an empty list when no restrictions are set. #if ("$!allowedSpaces" == '') #set ($allowedSpaces = []) #end #if($allowedSpaces.size() > 0) #set($jsAllowedSpacesArray = $jsontool.serialize($allowedSpaces)) #end ## Compute the error message. #set ($templateProviderName = $services.localization.render($tpobj.getValue('name'))) #if($allowedSpaces.isEmpty()) #set($message = '') #elseif($allowedSpaces.size() == 1) #set($message = $services.localization.render('core.create.template.allowedspace.inline', [$templateProviderName, $jsAllowedSpacesArray])) #else #set($message = $services.localization.render('core.create.template.allowedspaces.inline', [$templateProviderName, $jsAllowedSpacesArray])) #end ## ## Determine if the creation restrictions are just suggestions ## #set ($restrictionsAreSuggestions = ($tpobj.getValue('creationRestrictionsAreSuggestions') == 1)) ## ## Determine if it's a terminal page template ## #set ($isTerminalProvider = $tpobj.getValue('terminal')) ## Check if this is an old template provider that has not been migrated (the 'type' property has not been ## replaced by the 'terminal' property). #set ($type = $tpobj.getValue('type')) #if ("$!isTerminalProvider" == '' && ("$!type" != '' || $type == '')) ## This must be an old template provider because the 'terminal' property is not set (or it was set to '---' ## from the UI) and the 'type' property is still present. #if ($type == 'space') #set ($isTerminalProvider = false) #else ## 'page' or '' both resolve to true, for backwards compatibility reasons. #set ($isTerminalProvider = true) #end #else #set ($isTerminalProvider = ($isTerminalProvider == 1)) #end ## ## Display the template provider field option in the form. ## #set ($inputId = "xwiki-create-form-${velocityCount}") #set ($icon = $tpobj.getValue('icon')) #if ("$!icon" == '') #set($icon = 'file-white') #end #set ($discard = $templateOptions.add({ 'name': $services.localization.render($tpobj.getValue('name')), 'value': "$tpdocRef", 'description': $services.localization.render($tpobj.getValue('description')), 'icon': $icon, 'data': { 'allowed-spaces': $jsAllowedSpacesArray, 'allowed-spaces-message': $message, 'restrictions-are-suggestions': $restrictionsAreSuggestions, 'type': 'template', 'terminal' : $isTerminalProvider } })) #end #end <dt> <label>$services.localization.render('core.create.type')</label> <span class="xHint">$escapetool.xml($services.localization.render('core.create.type.hint'))</span> </dt> #set ($defaultValue = $request.type) #if ("$!defaultValue" == '') #if ($recommendedTemplateProviders.size() > 0) #set ($defaultValue = $services.model.serialize($recommendedTemplateProviders[0].documentReference, 'local')) #else #set ($defaultValue = 'blank') #end #end <dd>#xwikiSelect('type', $options, $defaultValue, false, 'xwiki-select-adaptable-medium', '', true)</dd> #else <input type="hidden" name="template" value="$escapetool.xml($template)" /> #end #end #set ($discard = $xwiki.jsfx.use('js/xwiki/create.js', {'forceSkinAction': true})) ## --------------------------------------------------------------------------------------------------------- ## Macro used to extract a wiki's homepage reference. ## --------------------------------------------------------------------------------------------------------- #macro (getWikiHomePageReference $wiki $return) #set ($_wikiHomePageReference = $services.wiki.getById($wiki).mainPageReference) #if (!$_wikiHomePageReference) #set ($wikiReference = $services.model.createWikiReference($wiki)) #set ($_wikiHomePageReference = $services.model.resolveDocument('', 'default', $wikiReference)) #end #set ($return = $NULL) #setVariable("$return" $_wikiHomePageReference) #end ## --------------------------------------------------------------------------------------------------------- ## Display the form. ## --------------------------------------------------------------------------------------------------------- ## FIXME: Using the 'container' class when displayed in an ajax call by clicking on a Wanted Link so that it looks good (proper margins) in the popup. <form action="$doc.getURL('create')" method="post" id="create" class="xform #if($request.ajax)container#end"> ## Deprecated: Pass along any received page parent. <input type='hidden' name='parent' value="$!{escapetool.xml($parent)}"/> ## The "templateprovider" field is needed by the CreateAction, even empty. ## By the past, it was "xwiki/create.js" which created this field, but it was causing problems when the user sent the ## form before the JavaScript code was executed. <input type="hidden" name="templateprovider" id="templateprovider" value="" /> <div class='row'> ## Hide the first column when displayed in an AJAX call by clicking on a Wanted Link (because we know the target ## location from the link reference) or when the current document is new (because the create action uses the location ## of the current document as target in this case). #if (!$request.ajax && !$doc.isNew()) ## Determine the parent reference for the new document. #set ($parentReference = $spaceReference) #if (!$parentReference) ## No parent reference specified. ## We keep this code although we tested above that the current document is not new because in the future we may ## want to support changing the target location even if the current document is new. #if ($doc.isNew()) ## Encourage the user to create the current document. #set ($parentReference = $doc.documentReference.parent) #if ($doc.documentReference.name == 'WebHome') #set ($parentReference = $parentReference.parent) #end #else #getWikiHomePageReference($doc.wiki $homeReference) #if ($doc.documentReference.equals($homeReference) || $deprecatedSpaceCreate) ## Encourage the user to create top level documents from the home page. #set ($parentReference = $doc.documentReference.wikiReference) #else ## Encourage the user to create a child or sibling of the current document. #set ($parentReference = $doc.documentReference.lastSpaceReference) #end #end #end ## Display the location picker. <div class='col-xs-12 col-lg-6'> #template('locationPicker_macros.vm') #locationPicker({ 'id': 'target', 'title': { 'label': 'core.create.title', 'hint': 'core.create.title.hint', 'name': 'title', 'value': $title, 'placeholder': 'core.create.name.placeholder' }, 'preview': { 'label': 'core.create.locationPreview.label', 'hint': 'core.create.locationPreview.hint' }, 'parent': { 'label': 'core.create.spaceReference.label', 'hint': 'core.create.spaceReference.hint', 'name': 'spaceReference', 'reference': $parentReference, 'placeholder': 'core.create.spaceReference.placeholder' }, 'name': { 'label': 'core.create.name.label', 'hint': 'core.create.name.hint', 'name': 'name', 'value': $name, 'placeholder': 'core.create.name.placeholder' } }) </div> #else ## First column is hidden. ## Pass along the known values as hidden inputs. ## <input type='hidden' name='title' value="$!{escapetool.xml($title)}"/> <input type='hidden' id='name' name='name' value="$!{escapetool.xml($name)}" /> #set ($spaceReferenceLocalString = $services.model.serialize($spaceReference, 'local')) <input type='hidden' id='spaceReference' name='spaceReference' value="$!{escapetool.xml($spaceReferenceLocalString)}" /> #end ## FIXME: When displayed in an ajax call by clicking on a Wanted Link, the responsive classes consider the calling document (large screen) ## as the viewport and not the popup (small screen), so we can not use them since they create problems instead of fixing them. <div class='#if(!$request.ajax)col-xs-12 col-lg-6#end'> <dl> ## --------------------------------------------------------------------------------------------------------- ## Page type ## --------------------------------------------------------------------------------------------------------- #displayTypes() ## --------------------------------------------------------------------------------------------------------- ## Terminal page - Advanced users ## --------------------------------------------------------------------------------------------------------- #set ($hidden = '') #if (!($isAdvancedUser || $isSuperAdmin) || $deprecatedSpaceCreate) #set ($hidden = 'hidden') #end <dt class="$hidden"> <input type="checkbox" id="terminal" name="tocreate" value="terminal" #if(!$isSpace)checked="checked"#end/> <label for="terminal">$services.localization.render('core.create.terminal.label')</label> ## Hidden input used to ensure that an unchecked terminal checkbox means non-terminal and that the default is not used by mistake. <input type="hidden" name="tocreate" value="nonterminal" /> </dt> <dd class="$hidden"> <span class="xHint">$services.localization.render('core.create.terminal.hint')</span> </dd> </dl> </div> </div> <div class='buttons'> <span class='buttonwrapper'> <input type='submit' class='button' value="$services.localization.render('create')"/> </span> <span class="buttonwrapper"> <a class="secondary button" href="$doc.getURL()">$services.localization.render('cancel')</a> </span> </div> </form>