%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/importinline.vm |
##---------------------------------------------------------------------------
## If the Document to which XARs will be attached to doesn't exist, then
## create it.
## Note that the upload action could automatically create it but we want to
## control the creation so that we can set the parent and thus not make it
## orphaned + we set a save comment and make it a minor edit.
##---------------------------------------------------------------------------
#set($importDoc = $xwiki.getDocument('XWiki.XWikiPreferences'))
#if($importDoc.isNew())
$importDoc.setParent('XWiki.WebHome')
$importDoc.save("Creating document to which to attach XAR files to import", true)
#end
##---------------------------------------------------------------------------
#if($request.xredirect)
#set($redirect = $request.xredirect)
#else
#set($redirect = $xwiki.relativeRequestURL)
#end
#if(!$redirect)
#set($redirect = $importDoc.getURL('import', 'section=Import'))
#end
##---------------------------------------------------------------------------
## Import the documents from the selected XAR.
##---------------------------------------------------------------------------
#if("$!{request.action}" == 'import')
<p class="legend">$services.localization.render('import') #if("$!{request.withversions}" == '1')$services.localization.render('export_addhistory')#end</p>
#template("imported.vm")
##---------------------------------------------------------------------------
## Browse the XARs and let the user select a XAR and the list of documents
## to import from that XAR.
##---------------------------------------------------------------------------
#else
#set($baseQueryString = "editor=$!{request.editor}&section=$!{request.section}")
$xwiki.jsfx.use('js/xwiki/importer/import.js', true)##
$xwiki.ssfx.use('js/xwiki/importer/import.css', true)##
$xwiki.jsfx.use('uicomponents/widgets/upload.js', {'forceSkinAction': true, 'language': ${xcontext.locale}})##
$xwiki.ssfx.use('uicomponents/widgets/upload.css', true)##
<div id="import" class="row">
<div id="packagelist" class="col-xs-12 col-sm-6 col-md-6">
<div class="legend">$services.localization.render('core.importer.uploadPackage')</div>
## Let the user upload XAR files.
<form action="$doc.getURL('upload')" enctype="multipart/form-data" method="post" id="AddAttachment">
<div>
## CSRF prevention
<input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
<input type="hidden" name="xredirect" value="$!{escapetool.xml($redirect)}" />
<fieldset id="attachform">
## Temporarily disabled, until we fix attachment name handling
## <div><label id="xwikiuploadnamelabel" for="xwikiuploadname">$services.localization.render('core.viewers.attachments.upload.filename')</label></div>
<div><input id="xwikiuploadname" type="hidden" name="filename" value="" /></div>
<div class="package-upload">
<label for="xwikiuploadfile" class="hidden">$services.localization.render('core.viewers.attachments.upload.file')</label>
<input id="xwikiuploadfile" type="file" name="filepath" class="uploadFileInput noitems" data-max-file-size="$!escapetool.xml($xwiki.getSpacePreference('upload_maxsize'))" />
<span class="buttonwrapper">
<input type="submit" value="Upload" class="button" />
</span>
</div>
</fieldset>
</div>
</form>
<div class="legend">$services.localization.render('core.importer.availablePackages')</div>
<div id="packagelistcontainer">
#template('packagelist.vm')
</div> ## packagelistcontainer
</div> ## packagelist
<div id="packagecontainer" class="col-xs-12 col-sm-6 col-md-6">
#if("$!request.file" != '')
##
## If we get here, it means javascript is not activated on the user's browser (otherwise the attachment link
## click would have been intercepted). We display a basic UI (list of checkboxes) to chose which documents in the archive to import.
##
#set($attach = $doc.getAttachment($request.file))
#if($attach)
#set($package = $services.xar.getXarPackage($attach.contentInputStream, true))
#if(!$package)
#error("There was an error reading the file ${escapetool.xml(${request.file})}. $!xcontext.import_error")
#else
<div class="legend">$services.localization.render('core.importer.availableDocuments')</div>
<div id="packageDescription">
<div class="packageinfos">
<div>
<span class="label">$services.localization.render('core.importer.package')</span>
<span class="filename">$attach.filename</span>
</div>
#if("$!package.packageName" != '')
<div>
<span class="label">$services.localization.render('core.importer.package.description')</span>
<span class="name">$package.packageName</span>
</div>
#end
#if("$!package.packageVersion" != '')
<div>
<span class="label">$services.localization.render('core.importer.package.version')</span>
<span class="version">$package.packageVersion</span>
</div>
#end
#if("$!package.packageAuthor" != '')
<div>
<span class="label">$services.localization.render('core.importer.package.author')</span>
<span class="author">$package.packageAuthor</span>
</div>
#end
#if("$!package.packageLicense" != '')
<div>
<span class="label">$services.localization.render('core.importer.package.licence')</span>
<span class="licence">$package.packageLicense</span>
</div>
#end
</div>
<form action="$!{importaction}" method="post" class="static-importer">
<div>
## CSRF prevention
<input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
<input type="hidden" name="action" value="import" />
<input type="hidden" name="name" value="$!{escapetool.xml($request.file)}" />
<div id="package">
<ul class="xlist package">
<li>
## This hidden input ensures that if no page is selected, the 'pages' parameter is still passed, thus skipping all the documents in the xar
<input type='hidden' name='pages' value=''/>
</li>
## List each page in the package
#macro(displayPageNode $pageNode)
#set($document = $pageNode.reference.name)
## List each locale of the current document
#foreach($locale in $pageNode.locales)
<li class="xitem xhighlight pages">
<div class="xitemcontainer xpagecontainer">
<span class="checkbox">
<input type="checkbox" name="pages"
value="${escapetool.xml($services.model.serialize($locale, 'local'))}#if("$!locale.locale" != ''):${locale.locale}#end" checked />
</span>
<span class="documentName">
<input type="hidden" name="$!{escapetool.xml($services.model.serialize($locale, 'local'))}:$!{escapetool.xml($locale.locale)}" value="$!{escapetool.xml($locale.locale)}" />
$document #if("$!locale.locale" != '') - $locale.locale #end
</span>
<div class="clearfloats"></div>
</div>
</li>
#end
#end
#macro(displaySpaceNode $spaceNode)
#set($spaceReference = $spaceNode.reference)
#set($space = $spaceNode.reference.name)
<li class="xitem xunderline">
<div class="xitemcontainer">
<div class="spacename">$space</div>
<div class="clearfloats"></div>
<div class="pages">
<ul class="xlist pages">
#foreach($node in $spaceNode.children)
#displayNode($node)
#end
</ul>
</div>
</div>
</li>
#end
#macro(displayNode $node)
#if ($node.children.isEmpty())
#displayPageNode($node)
#else
#displaySpaceNode($node)
#end
#end
#foreach($node in $services.model.toTree($package.entries).children)
#displayNode($node)
#end
</ul>
<div class="importOption">
<em>$services.localization.render('core.importer.whenDocumentAlreadyExists')</em>
<div class="historyStrategyOption">
<input type="radio" name="historyStrategy" value="add" checked="checked" />
$services.localization.render('core.importer.addNewVersion')
</div>
<div class="historyStrategyOption">
<input type="radio" name="historyStrategy" value="replace" />
$services.localization.render('core.importer.replaceDocumentHistory')
</div>
<div class="historyStrategyOption">
<input type="radio" name="historyStrategy" value="reset" />
$services.localization.render('core.importer.resetHistory')
</div>
</div>
## TODO: replace with a new API to introduce (impossible to safely test right on a different wiki from velocity without PR)
#if($xwiki.package.hasBackupPackImportRights())
<div class="importOption">
<input type="checkbox" name="importAsBackup" value="true" #if($packager.isBackupPack())checked="checked"#end/>
$services.localization.render('core.importer.importAsBackup')
</div>
#end
<span class="buttonwrapper">
<input class="button" type="submit" value="$services.localization.render('core.importer.import')" />
</span>
</div>
</div>
</form>
</div>
#end ## package is valid
#end ## attachment exists
#end
</div> ## package
<div class="clearfloats"></div>
</div>
#end