Committer: ybuhvalova
LJSUP-13134: Add a new setting for Minimalism layout (sort tags by popularity) U trunk/bin/upgrading/s2layers/sup/layout.s2
Modified: trunk/bin/upgrading/s2layers/sup/layout.s2 =================================================================== --- trunk/bin/upgrading/s2layers/sup/layout.s2 2012-07-27 14:17:47 UTC (rev 12367) +++ trunk/bin/upgrading/s2layers/sup/layout.s2 2012-07-27 15:18:45 UTC (rev 12368) @@ -154,6 +154,11 @@ property string tag_display { des = "Display of tags in sidebar"; values = "list|list|cloud|cloud"; } set tag_display = "cloud"; + + property string tag_order { des = "Order of tags"; + values = "abc|alphabetical|popularity|by popularity"; + } set tag_order = "abc"; + property bool tag_limit { des = "Limit number of tags displayed"; } set tag_limit = true; property int tag_cloud_max { des = "Number of tags to display in Tags sidebar (if limited)"; @@ -660,6 +665,36 @@ } } $most_count = $most_count - $skipped; + + #------- Order by TagCount ---------- + + if($*tag_order == "popularity"){ + var int[] graph_for_sort; + + foreach var TagDetail tag ($total_tags) { + $graph_for_sort[$tag.use_count] = $tag.use_count; + $tcount++; + } + $graph_for_sort = reverse($graph_for_sort); + + var TagDetail[] newTags; + + foreach var int Ts ($graph_for_sort) { + if ($Ts) { + foreach var TagDetail tag ($tags) { + if($tag.use_count == $Ts){ + $newTags[size $newTags] = $tag; + } + } + } + } + + $tags = $newTags; + + } + + #------ //Order by TagCount --------- + foreach var TagDetail tag ($tags) { var string text = "1"; var string text2 = "1";