List Virtual Wikis Snippet

Show how to get all the virtual wikis in a wiki farm.

Code

#set($currentwiki = $context.database)
## Switch to main wiki
$context.setDatabase($context.mainWikiName)
## Get all wiki descriptors documents
#set($wikidescriptorlist = $xwiki.searchDocuments(", BaseObject as obj, StringProperty as prop where doc.fullName=obj.name and obj.className='XWiki.XWikiServerClass' and prop.id.id=obj.id and prop.id.name='server'"))
## Re-switch to current wiki
$context.setDatabase($currentwiki)

## Get all wiki names from descriptors documents names
#set($wikinamelist = [])
#set($DESC_PREFIX = "XWiki.XWikiServer")
#set($DESC_PREFIX_SIZE = $DESC_PREFIX.length())
#foreach($wiki in $wikidescriptorlist)
  #set($ok = $wikinamelist.add($wiki.substring($DESC_PREFIX_SIZE).toLowerCase()))
#end

## Add main wiki if there is no descriptor for it
#if(!$wikinamelist.contains($context.mainWikiName))
  #set($ok = $wikinamelist.add($context.mainWikiName))
#end

This wiki farm contains wikis :
#foreach($wikiname in $wikinamelist)
  * $wikiname
#end

Result

This wiki farm contains wikis :

  • classtemplate
  • xwikidefaulten
  • sandbox
  • xwiki
  • chronopolys
  • bestventes
  • wwwdev
  • platform
  • enterprise
  • manager
  • code
  • community
  • forge
  • skol
  • dev
  • reference
  • watch
  • nearbee
  • playground
  • workspaces
  • curriki
  • laloutre
  • newplayground
  • xeclipse
Version 7.1 last modified by VincentMassol on 09/12/2007 at 19:20

Comments 0

No comments for this document

Attachments 0

No attachments for this document

Creator: ThomasMortagne on 2007/12/06 16:55
This wiki is licensed under a Creative Commons license
1.4.1.10194