<
From version < 2.1 >
edited by Admin
on 2010/03/02
To version < 3.1 >
edited by Admin
on 2010/11/24
>
Change comment: Imported from XAR

Summary

Details

Page properties
Content
... ... @@ -4,76 +4,9 @@
4 4  ##
5 5  ## @param tagCloudSpace - the space to display the tag cloud for. If blank, display cloud for the whole wiki. Default is blank.
6 6  ##
7 -## Configurable popularity levels. You must an even number of levels. Default: 6.
8 -##
9 -#set ($popularityLevels = ["notPopular", "notVeryPopular", "somewhatPopular", "popular", "veryPopular", "ultraPopular"])
10 -$xwiki.ssx.use("XWiki.TagCloud")
11 -##
12 -## Get tag count map. Key: tag, value: number of occurrences.
13 -## Store the minimum number of occurrences for a tag.
14 -## Store the maximum number of occurrences for a tag.
15 -##
16 -#set ($tagCount = $xwiki.tag.getTagCount("$!tagCloudSpace"))
17 -#set ($sortedTagCounts = $sorttool.sort($tagCount.values()))
18 -#set ($maxIndex = $sortedTagCounts.size() - 1)
19 -#set ($minCount = $listtool.get($sortedTagCounts, 0))
20 -#set ($maxCount = $listtool.get($sortedTagCounts, $maxIndex))
21 -##
22 -## Calculate the total number of tags in the wiki.
23 -##
24 -#set ($totalTagNumber = 0)
25 -#foreach ($currentTagCount in $sortedTagCounts)
26 - #set ($totalTagNumber = $totalTagNumber + $currentTagCount)
27 -#end
28 -##
29 -## Build popularity map using the difference between minimum maximum tag occurrences counts
30 -## and the average tag occurences count.
31 -##
32 -#set ($countAverage = $mathtool.div($totalTagNumber, $tagCount.size()))
33 -#set ($levelsHalf = $popularityLevels.size() / 2)
34 -#set ($firstHalfCountDelta = $mathtool.sub($countAverage, $minCount))
35 -#set ($secondHalfCountDelta = $mathtool.sub($maxCount, $countAverage))
36 -#set ($popularityMap = $util.getHashMap())
37 -#set ($firstHalfIntervalSize = $mathtool.div($firstHalfCountDelta, $levelsHalf))
38 -#set ($secondHalfIntervalSize = $mathtool.div($secondHalfCountDelta, $levelsHalf))
39 -#set ($previousPopularityMax = $minCount)
40 -#set ($intervalSize = $firstHalfIntervalSize)
41 -#set ($halfPassed = false)
42 -#foreach ($popularityLevel in $popularityLevels)
43 - #if ($velocityCount > $levelsHalf && !$halfPassed)
44 - #set ($intervalSize = $secondHalfIntervalSize)
45 - #set ($halfPassed = true)
46 - #end
47 - #set ($currentPopularityMax = $mathtool.add($previousPopularityMax, $intervalSize))
48 - #set ($discard = $popularityMap.put($currentPopularityMax, $popularityLevel))
49 - #set ($previousPopularityMax = $currentPopularityMax)
50 -#end
51 -##
52 -## Display tag cloud.
53 -##
54 -{{html}}
55 -#if ($tagCount.size() > 0)
56 - <ol class="tagCloud">
57 - #foreach($tag in $tagCount.keySet())
58 - ## This hackish loop could be made simpler with #break (introduced in velocity 1.6)
59 - #set($classSet = false)
60 - #foreach($popularityMax in $sorttool.sort($popularityMap.keySet()))
61 - #if($tagCount.get($tag) > $popularityMax)
62 - ## Tag already processed
63 - #elseif(!$classSet)
64 - #set($liClass = $popularityMap.get($popularityMax))
65 - #set($classSet = true)
66 - #end
67 - #end
68 - <li class="$liClass"><a class="tag" href="$xwiki.getURL("Main.Tags", "view", "do=viewTag&amp;tag=$escapetool.url($tag)")" title="$msg.get("xe.tag.tooltip", ["${tagCount.get($tag)}"])">$escapetool.html($tag)</a></li>
69 - #end
70 - </ol>
7 +#if($tagCloudSpace && "$!tagCloudSpace" != "")
8 + {{tagcloud space="$tagCloudSpace"/}}
71 71  #else
72 - #if("$!tagCloudSpace" == "")
73 - $msg.get("xe.tag.notags")
74 - #else
75 - $msg.get("xe.tag.notagsforspace", ["$tagCloudSpace"])
76 - #end
10 + {{tagcloud/}}
77 77  #end
78 -{{/html}}
79 79  {{/velocity}}
XWiki.StyleSheetExtension[0]
Name
... ... @@ -1,0 +1,1 @@
1 +Tag cloud CSS
XWiki.WikiMacroClass[0]
Macro code
... ... @@ -1,0 +1,78 @@
1 +{{velocity}}
2 +##
3 +## tagCloudSpace - the space to display the tag cloud for. If blank, display cloud for the whole wiki. Default is blank.
4 +#set($tagCloudSpace = $context.macro.params.get('space'))
5 +##
6 +## Configurable popularity levels. You must an even number of levels. Default: 6.
7 +##
8 +#set ($popularityLevels = ["notPopular", "notVeryPopular", "somewhatPopular", "popular", "veryPopular", "ultraPopular"])
9 +$xwiki.ssx.use("XWiki.TagCloud")
10 +##
11 +## Get tag count map. Key: tag, value: number of occurrences.
12 +## Store the minimum number of occurrences for a tag.
13 +##
14 +#set ($tagCount = $xwiki.tag.getTagCount("$!tagCloudSpace"))
15 +#set ($sortedTagCounts = $sorttool.sort($tagCount.values()))
16 +#set ($maxIndex = $sortedTagCounts.size() - 1)
17 +#set ($minCount = $listtool.get($sortedTagCounts, 0))
18 +#set ($maxCount = $listtool.get($sortedTagCounts, $maxIndex))
19 +##
20 +## Calculate the total number of tags in the wiki.
21 +##
22 +#set ($totalTagNumber = 0)
23 +#foreach ($currentTagCount in $sortedTagCounts)
24 + #set ($totalTagNumber = $totalTagNumber + $currentTagCount)
25 +#end
26 +##
27 +## Build popularity map using the difference between minimum maximum tag occurrences counts
28 +## and the average tag occurences count.
29 +##
30 +#set ($countAverage = $mathtool.div($totalTagNumber, $tagCount.size()))
31 +#set ($levelsHalf = $popularityLevels.size() / 2)
32 +#set ($firstHalfCountDelta = $mathtool.sub($countAverage, $minCount))
33 +#set ($secondHalfCountDelta = $mathtool.sub($maxCount, $countAverage))
34 +#set ($popularityMap = $util.getHashMap())
35 +#set ($firstHalfIntervalSize = $mathtool.div($firstHalfCountDelta, $levelsHalf))
36 +#set ($secondHalfIntervalSize = $mathtool.div($secondHalfCountDelta, $levelsHalf))
37 +#set ($previousPopularityMax = $minCount)
38 +#set ($intervalSize = $firstHalfIntervalSize)
39 +#set ($halfPassed = false)
40 +#foreach ($popularityLevel in $popularityLevels)
41 + #if ($velocityCount > $levelsHalf && !$halfPassed)
42 + #set ($intervalSize = $secondHalfIntervalSize)
43 + #set ($halfPassed = true)
44 + #end
45 + #set ($currentPopularityMax = $mathtool.add($previousPopularityMax, $intervalSize))
46 + #set ($discard = $popularityMap.put($currentPopularityMax, $popularityLevel))
47 + #set ($previousPopularityMax = $currentPopularityMax)
48 +#end
49 +##
50 +## Display tag cloud.
51 +##
52 +{{html}}
53 +#if ($tagCount.size() > 0)
54 + <ol class="tagCloud">
55 + #foreach($tag in $tagCount.keySet())
56 + ## This hackish loop could be made simpler with #break (introduced in velocity 1.6)
57 + #set($classSet = false)
58 + #foreach($popularityMax in $sorttool.sort($popularityMap.keySet()))
59 + #if($tagCount.get($tag) > $popularityMax)
60 + ## Tag already processed
61 + #elseif(!$classSet)
62 + #set($liClass = $popularityMap.get($popularityMax))
63 + #set($classSet = true)
64 + #end
65 + #end
66 + <li class="$liClass"><a class="tag" href="$xwiki.getURL("Main.Tags", "view", "do=viewTag&amp;tag=$escapetool.url($tag)")" title="$msg.get("xe.tag.tooltip", ["${tagCount.get($tag)}"])">$escapetool.xml($tag)</a></li>
67 + #end
68 + </ol>
69 +#else
70 + #if("$!tagCloudSpace" == "")
71 + $msg.get("xe.tag.notags")
72 + #else
73 + $msg.get("xe.tag.notagsforspace", ["$tagCloudSpace"])
74 + #end
75 +#end
76 +{{/html}}
77 +{{/velocity}}
78 +
Macro content availability
... ... @@ -1,0 +1,1 @@
1 +No content
Default category
... ... @@ -1,0 +1,1 @@
1 +Content
Macro description
... ... @@ -1,0 +1,1 @@
1 +Displays the cloud of tags in this wiki or in the specified space, if any.
Macro id
... ... @@ -1,0 +1,1 @@
1 +tagcloud
Macro name
... ... @@ -1,0 +1,1 @@
1 +Tag Cloud
Supports inline mode
... ... @@ -1,0 +1,1 @@
1 +No
Macro visibility
... ... @@ -1,0 +1,1 @@
1 +Current Wiki
XWiki.WikiMacroParameterClass[0]
Parameter description
... ... @@ -1,0 +1,1 @@
1 +The space to display the tag cloud for. If missing, the tags in the whole wiki will be displayed.
Parameter mandatory
... ... @@ -1,0 +1,1 @@
1 +No
Parameter name
... ... @@ -1,0 +1,1 @@
1 +space

Get Connected