Wiki source code of TagCloud

Last modified by Hal Eden on 2010/08/20 11:06

Show last authors
1 #set($query = "select elements(prop.list) from BaseObject as obj, DBStringListProperty as prop where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags'")
2
3 #set( $allTags = $xwiki.sort($xwiki.search($query)))
4 #set( $previousTag = "")
5 #set( $tagsWithCount = $xwiki.getHashMap())
6 #set( $count = 1)
7 #set( $maxCount = 1)
8 #foreach($tag in $allTags)
9 #if ($tag == $previousTag)
10 #set( $count = $count + 1)
11 #if ($count > $maxCount)
12 #set ($maxCount = $count)
13 #end
14 #else
15 #set( $count = 1)
16 #set( $previousTag = "")
17 #end
18 #set( $dummy = $tagsWithCount.put($tag, $count))
19 #set( $previousTag = $tag)
20 #end
21
22 #set($query = "select distinct elements(prop.list) from BaseObject as obj, DBStringListProperty as prop where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags'")
23
24 #set( $tagsDistinct = $xwiki.sort($xwiki.search($query)))
25 <div style="font-size: 2.00em; text-align: justify; text-justify: auto;">
26 #foreach($tag in $tagsDistinct)
27 #set( $currentCount = $tagsWithCount.get($tag))
28 #set( $size = 50 + ($currentCount * 50 / $maxCount))
29 <span style="font-size: $size%"><a href="$xwiki.getURL("Main.Tags", "view", "tag=$tag")")>$tag</a></span>
30 #end
31 </div>