would be a good code snippet for
code.xwiki.org. Can someone put it
there? Bruno maybe?
Thanks
-Vincent
On Aug 28, 2008, at 1:54 PM, Jean-Vincent Drean wrote:
This feature is not provided in XWiki but here's a
snippet you can
use :
---------------------------------------8
<-----------------------------------
#set ($tagToReplace = "tag1")
#set ($newTag = "tag2")
#set ($taggedDocs = $xwiki.searchDocuments(", BaseObject obj where
doc.fullName=obj.name and obj.className='XWiki.TagClass'"))
#foreach ($taggedDocName in $taggedDocs)
#set ($taglist = "")
#set ($taggedDoc = $xwiki.getDocument($taggedDocName))
#set ($taglist =
$taggedDoc.getObject("XWiki.TagClass").get("tags"))
#if ($taglist.contains($tagToReplace))
$taggedDoc.getObject("XWiki.TagClass").set("tags",
$taglist.replaceAll("(^| +)$tagToReplace( +|$)", "$1$newTag$2"))
* [$taggedDoc.fullName] : replacing tag "$tagToReplace" by
"$newTag"
#set ($discard = $taggedDoc.save())
#end
#end
---------------------------------------8
<-----------------------------------
Note that the regexp is not perfect but it's (ftm) kind of impossible
to use backslashes when writting a regexp in a wiki page (because of
multiple escaping).
On Thu, Aug 28, 2008 at 12:12 PM, Bruno Neves <bneves(a)gedi.pt> wrote:
> Greetings
>
> It's possible to rename a tag present in diferent pages at once, or
> the only way is opening all the pages
> where it is and rename it?
>
> Best regards
> Bruno Neves