 | Lists all spaces in a wiki and provides links to delete each space |
| Type | Snippet |
| Developed by | Vincent Massol |
| License | GNU Lesser General Public License 2.1 |
The deletion of a space cannot be reverted. Use this at your own risk. Note that since XWiki 1.2 it's possible to revert page deletions, but only one by one.
This version doesn't require programming rights (just delete rights on pages to be deleted) but will not delete hidden pages.
In XWiki Syntax 2.0:
{{velocity}}
#if ($request.space)
#if ($request.confirm == "1")
#foreach ($item in $xwiki.getSpaceDocsName($request.space))
* Deleting $item $xwiki.getDocument("${request.space}.${item}").delete()\\
#end
#else
[[Confirm delete space ${request.space}>>$doc.fullName?space=${request.space}&confirm=1]]:
#foreach ($item in $xwiki.getSpaceDocsName($request.space))
* $item
#end
#end
#else
|=Space|=Action
#foreach($space in $xwiki.spaces)
|$space|[[Index>>Main.SpaceIndex?space=${space}]] - [[Delete>>$doc.fullName?space=${space}]]
#end
#end
{{/velocity}}
In XWiki Syntax 1.0:
1 Delete Space
#if ($request.space)
#if ($request.confirm == "1")
#foreach ($item in $xwiki.getSpaceDocsName($request.space))
* Deleting $item $xwiki.getDocument("${request.space}.${item}").delete()
#end
#else
[Confirm delete space ${request.space}>$doc.fullName?space=${request.space}&confirm=1]
1.1 List of docs that will be deleted
#foreach ($item in $xwiki.getSpaceDocsName($request.space))
* $item
#end
#end
#else
{table}
Space | Action
#foreach($space in $xwiki.spaces)
$space | [Index>Main.SpaceIndex?space=${space}] - [Delete>$doc.fullName?space=${space}]
#end
{table}
#end
This version requires programming rights and will delete all documents including hidden ones.
XWiki Syntax 2.0
{{velocity}}
#if ($request.space)
#if ($request.confirm == "1")
#foreach ($item in $xwiki.search("select doc.fullName from XWikiDocument doc where doc.space = '$request.space'"))
* Deleting $item $xwiki.getDocument("$item").delete()\\
#end
#else
[[Confirm delete space ${request.space}>>$doc.fullName?space=${request.space}&confirm=1]]:
#foreach ($item in $xwiki.search("select doc.fullName from XWikiDocument doc where doc.space = '$request.space'"))
* $item
#end
#end
#else
|=Space|=Action
#foreach($space in $xwiki.spaces)
|$space|[[Index>>Main.SpaceIndex?space=${space}]] - [[Delete>>$doc.fullName?space=${space}]]
#end
#end
{{/velocity}}
