2 require_once('init.php');
7 $smarty->assign('tagcloud',tag_cloud());
9 header('Content-Type: text/html; charset=utf-8');
10 $smarty->display('tags.tpl');
15 if(!$conf['extended']) return;
17 $result = ldap_queryabooks('(objectClass=contactPerson)','marker');
22 foreach ($result as $entry){
23 if(!empty($entry['marker']) && count($entry['marker'])){
24 foreach($entry['marker'] as $marker){
25 $marker = strtolower($marker);
26 if (empty($tags[$marker])) { $tags[$marker]=0; }
28 if($tags[$marker] > $max) $max = $tags[$marker];
29 if($tags[$marker] < $min) $min = $tags[$marker];
34 tag_cloud_weight(&$tags,$min,$max,6);
37 foreach($tags as $tag => $cnt){
38 $out .= '<a href="index.php?marker='.rawurlencode($tag).'" class="cloud_'.$cnt.'">';
39 $out .= htmlspecialchars($tag).'</a> ';
46 * Calculate weights for a nicer tagcloud distribution
48 function tag_cloud_weight(&$tags,$min,$max,$levels){
49 // calculate tresholds
51 for($i=0; $i<=$levels; $i++){
52 $tresholds[$i] = pow($max - $min + 1, $i/$levels);
56 foreach($tags as $tag => $cnt){
57 foreach($tresholds as $tresh => $val){
62 $tags[$tag] = $levels;