blob: aa3d84081a4467f5ae95ac8e11f8850d7d2def87 (
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
|
<?php
/**
* Elgg tagcloud
* Displays a tagcloud
*/
if (!empty($vars['subtype'])) {
$subtype = "&subtype=" . urlencode($vars['subtype']);
} else {
$subtype = "";
}
if (!empty($vars['object'])) {
$object = "&object=" . urlencode($vars['object']);
} else {
$object = "";
}
if (empty($vars['tagcloud']) && !empty($vars['value']))
$vars['tagcloud'] = $vars['value'];
if (!empty($vars['tagcloud']) && is_array($vars['tagcloud'])) {
if (get_context() === 'random')
shuffle($vars['tagcloud']);
$counter = 0;
$cloud = "";
$max = 0;
foreach($vars['tagcloud'] as $tag) {
if ($tag->total > $max) {
$max = $tag->total;
}
}
foreach($vars['tagcloud'] as $tag) {
if (!empty($cloud)) $cloud .= ",";
$size = round((log($tag->total) / log($max)) * 100) + 80;
if ($size < 100) $size = 100;
$cloud .= "<a href=\"" . $vars['url'] . "search/?tag=". urlencode($tag->tag) . $object . $subtype . "\" style=\"font-size: {$size}%\" title=\"".addslashes($tag->tag)." ({$tag->total})\" style=\"text-decoration:none;\">" . htmlentities($tag->tag, ENT_QUOTES, 'UTF-8') . "</a>";
}
$tags = explode(',', $cloud);
asort($tags);
$tags = implode(',', $tags);
echo str_replace(",", " ", $tags);
}
?>
|