blob: ee28f751aae8da4906214b4c1f66b5f1794af449 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<?php
/**
* Elgg tagcloud
* Displays a tagcloud
*
* @package Elgg
* @subpackage Core
* @author Curverider Ltd
* @link http://elgg.org/
*
* @uses $vars['tagcloud'] An array of stdClass objects with two elements: 'tag' (the text of the tag) and 'total' (the number of elements with this tag)
* @uses $vars['value'] Sames as tagcloud
* @uses $vars['type'] Entity type
* @uses $vars['subtype'] Entity subtype
*/
$context = get_context();
if (!empty($vars['subtype'])) {
$subtype = "&entity_subtype=" . urlencode($vars['subtype']);
} else {
$subtype = "";
}
if (!empty($vars['type'])) {
$type = "&entity_type=" . urlencode($vars['type']);
} else {
$type = "";
}
if (empty($vars['tagcloud']) && !empty($vars['value'])) {
$vars['tagcloud'] = $vars['value'];
}
if (!empty($vars['tagcloud']) && is_array($vars['tagcloud'])) {
$counter = 0;
$cloud = "<div class='tagcloud_wrapper'>";
$max = 0;
if ($context != 'tags') {
$title = elgg_echo('tagcloud');
$cloud .= "<h3>$title</h3>";
}
$cloud .= '<div class="tagcloud">';
foreach($vars['tagcloud'] as $tag) {
if ($tag->total > $max) {
$max = $tag->total;
}
}
$list = '';
foreach($vars['tagcloud'] as $tag) {
if ($list != '') {
$list .= ', ';
}
// protecting against division by zero warnings
$size = round((log($tag->total) / log($max + .0001)) * 100) + 30;
if ($size < 100) {
$size = 100;
}
$url = "{$vars['url']}pg/search/?q=". urlencode($tag->tag) . "&search_type=tags$type$subtype";
$list .= "<a href=\"$url\" style=\"font-size: $size%\" title=\"".addslashes($tag->tag)." ($tag->total)\" style=\"text-decoration:none;\">" . htmlentities($tag->tag, ENT_QUOTES, 'UTF-8') . "</a>";
}
$cloud .= "$list</div>";
if ($context != 'tags') {
$cloud .= '<p class="tags">';
$cloud .= "<a href=\"{$vars['url']}pg/tags\">All site tags</a>";
$cloud .= '</p>';
}
$cloud .= elgg_view('tagcloud/extend');
$cloud .= '</div>';
echo $cloud;
}
|