Elgg  Version 1.9
tagcloud.php
Go to the documentation of this file.
1 <?php
15 if (!empty($vars['subtype'])) {
16  $subtype = "&entity_subtype=" . urlencode($vars['subtype']);
17 } else {
18  $subtype = "";
19 }
20 if (!empty($vars['type'])) {
21  $type = "&entity_type=" . urlencode($vars['type']);
22 } else {
23  $type = "";
24 }
25 
26 if (empty($vars['tagcloud']) && !empty($vars['value'])) {
27  $vars['tagcloud'] = $vars['value'];
28 }
29 
30 if (!empty($vars['tagcloud']) && is_array($vars['tagcloud'])) {
31  $counter = 0;
32  $max = 0;
33 
34  foreach ($vars['tagcloud'] as $tag) {
35  if ($tag->total > $max) {
36  $max = $tag->total;
37  }
38  }
39 
40  $cloud = '';
41  foreach ($vars['tagcloud'] as $tag) {
42  $tag->tag = htmlspecialchars($tag->tag, ENT_QUOTES, 'UTF-8', false);
43 
44  if ($cloud != '') {
45  $cloud .= ', ';
46  }
47  // protecting against division by zero warnings
48  $size = round((log($tag->total) / log($max + .0001)) * 100) + 30;
49  if ($size < 100) {
50  $size = 100;
51  }
52  $url = "search?q=". urlencode($tag->tag) . "&search_type=tags$type$subtype";
53 
54  $cloud .= elgg_view('output/url', array(
55  'text' => $tag->tag,
56  'href' => $url,
57  'style' => "font-size: $size%;",
58  'title' => "$tag->tag ($tag->total)",
59  'rel' => 'tag'
60  ));
61  }
62 
63  $cloud .= elgg_view('tagcloud/extend');
64 
65  echo "<div class=\"elgg-tagcloud\">$cloud</div>";
66 }
$size
Definition: view.php:10
$url
Definition: exceptions.php:24
elgg echo
Translates a string.
Definition: languages.js:43
$type
Definition: add.php:8
if(!$cloud) $cloud
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
$subtype
Definition: river.php:10
if(file_exists($welcome)) $vars
Definition: upgrade.php:93