 | Rename all pages in a space |
| Type | Snippet |
| Developed by | Vincent Massol |
| License | GNU Lesser General Public License 2.1 |
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
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}}
Screen copy of the result page with the velocity Code in XWiki Syntax 2.0:
