From version 3.1
edited by Manuel Smeria
on 2018/04/02 09:44
To version 4.1
edited by Paul Panțiru
on 2019/03/20 12:01
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.ManuelSmeria
1 +xwiki:XWiki.ppantiru
ExtensionCode.ExtensionClass[0]
Is allowed namespaces empty
... ... @@ -1,0 +1,1 @@
1 +No
Authors
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.lucaa
1 +xwiki:XWiki.lucaa xwiki:XWiki.ppantiru
Description
... ... @@ -34,3 +34,43 @@
34 34  {{info}}
35 35  Also keep in mind that the script only works for terminal pages.
36 36  {{/info}}
37 +
38 +{{info}}
39 +Ana updated script that also works for nested documents can be found below.
40 +{{/info}}
41 +
42 +{{code}}
43 +{{velocity}}
44 +#if ("$!request.documentsToFix" != "")
45 + #set($documentsList = $request.getParameterValues('documentsToFix'))
46 + #foreach($page in $documentsList)
47 + #calculateNewPages()
48 + * renaming $page : $xwiki.getDocument($pageReference).rename($newPageReference)
49 + #end
50 +#else
51 + #set($pagesWithSlash = $services.query.xwql("from XWikiSpace as space where doc.space = space.reference and (((doc.name <> 'WebHome' and lower(doc.name) like '%/%') or(doc.name <> 'WebHome' and lower(doc.name) like '%\\%')) or ((doc.name = 'WebHome' and lower(space.name) like '%/%') or (doc.name = 'WebHome' and lower(space.name) like '%\\%')))").execute())
52 +
53 + {{html}}
54 + <form action="" method="post">
55 + <ul>
56 + #foreach($page in $pagesWithSlash)
57 + #calculateNewPages()
58 + <li> <input type="checkbox" name="documentsToFix" value="$escapetool.xml($services.model.serialize($pageReference, 'default'))">$page -> $services.model.serialize($newPageReference, 'default')</input></li>
59 + #end
60 + </ul>
61 + <input type="submit" class="button" value="Rename" />
62 + </form>
63 + {{/html}}
64 +#end
65 +
66 +#macro(calculateNewPages)
67 + #set($pageReference = $services.model.resolveDocument($page))
68 + #set($spaceArray = [])
69 + #foreach($sp in $pageReference.getSpaceReferences())
70 + #set($auxSpace = $sp.name.replaceAll('/', ' ').replaceAll('\\', ' '))
71 + #set($discard = $spaceArray.add($auxSpace))
72 + #end
73 + #set($newPageReference = $services.model.createDocumentReference($pageReference.wikiReference.name, $spaceArray, $pageReference.name.replaceAll('/', ' ').replaceAll('\\', ' ')))
74 +#end
75 +{{/velocity}}
76 +{{/code}}
Recommended
... ... @@ -1,0 +1,1 @@
1 +No
Show installed count
... ... @@ -1,0 +1,1 @@
1 +Yes

Get Connected