 | Offers a convenient way to move/rename all pages from a space into another |
| Type | Snippet |
| Developed by | Gunter Leeb |
| License | GNU Lesser General Public License 2.1 |
It shows also how to receive input from the user.
The rename functionality is available starting XWiki Enterprise 1.0B6. This snippet was tested with XWiki Enterprise 1.0B6. However several bugs have been fixed on the rename feature and we recommend using 1.0 RC1 or above.
Just copy the snippet into a new page.
1 Rename Space
#if($request.space)
#if("doRename"==$request.op)
#set($space=$request.space)
#foreach($item in $xwiki.getSpaceDocsName($request.space))
$xwiki.getDocument("${space}.${item}").rename("${request.newname}.${item.replace('.','_')}")
#end
1.1 Renamed space $space to $request.newname
[Cancel>$doc.fullName]
#end
#if("listRename"==$request.op)
#set($space=$request.space)
1.1 Renaming space $space to $request.newname
#foreach($item in $xwiki.getSpaceDocsName($request.space))
* Renaming $space.$item to ${request.newname}.${item.replace('.','_')}
#end
[Confirm>$doc.fullName?space=$space&newname=$request.newname&op=doRename]
[Cancel>$doc.fullName]
#end
#if("getNewName"==$request.op)
Renaming $request.space
1.1 Renaming ${request.space}
<form method="post" action="$doc.getURL("view", "")" onsubmit="cancelCancelEdit()">
<div class="padded centered">
<input type="hidden" name="space" value="${request.space}" />
<input type="hidden" name="op" value="listRename" />
Enter new name for the space:
<input type="text" name="newname" value="${request.space}" class="panelinput" style="margin:auto;" onfocus="if(this.value=='Title') this.value=''" onblur="if(this.value=='') this.value='Title'"/>
</div>
<div class="padded centered" style="text-align:center;">
<input type="submit" class="button" style="margin:auto;" value="Rename"/>
</div>
</form>
[Cancel>$doc.fullName]
#end
#else
{table}
Space | Action
#foreach($space in $xwiki.spaces)
$space | [Rename>$doc.fullName?space=${space}&op=getNewName]
#end
{table}
#end