Extensions Wiki » Extensions » Rename Space

Rename Space

Last modified by Andreea Popescu on 2014/08/20 10:36
cogRename all pages in a space
TypeSnippet
Developed by

Vincent Massol

LicenseGNU Lesser General Public License 2.1

Description

This script uses the rename feature on page (it just loops over all pages in a space) and thus has the same limitations as the standard rename.
The rights on the renamed space are the default rights. This script does not keep rights on the space

Code in XWiki Syntax 2.0

Works in XWiki versions 2.3 and above.
{{velocity}}
= Rename space =

#if($request.action == 'rename')
  #if($request.from && $request.to)
    Renamings:
    #foreach($item in $xwiki.getSpaceDocsName($request.from))
      #set ($fromReference = $services.model.createDocumentReference("", $request.from, $item))
      #set ($toReference = $services.model.createDocumentReference("", $request.to, $item))
      * Renamed [$services.model.serialize($fromReference)] to [$services.model.serialize($toReference)]
      #set($ok = $xwiki.getDocument($fromReference).rename($toReference))
    #end
  #end
#end

{{html wiki='true'}}
<form action="$doc.getURL()" method="post">
  <input type="hidden" name="action" value="rename" />
  Source space:
  <select name="from">
    <option value="">please select</option>
    #foreach($space in $xwiki.getSpaces())
    <option value="$escapetool.xml($space)">$escapetool.xml($space)</option>
    #end
  </select>
<div>New space: <input name="to" value=""/></div>
<div><input type="submit" value="Rename"/></div>
</form>
{{/html}}
{{/velocity}}

Result

Screen copy of the result page with the velocity Code in XWiki Syntax 2.0:

renameSpace.png

Tags:
Created by VincentMassol on 2007/09/24 17:09

Download XWiki

My Recent Modifications

Get Connected