2 require_once('inc/init.php');
5 if ($conf['userlogreq'] && $user == ''){
6 header('Location: login.php');
12 $smarty->assign('tagcloud',tag_cloud());
14 header('Content-Type: text/html; charset=utf-8');
15 $smarty->display('tags.tpl');
21 if(!$conf['extended']) return;
23 $result = ldap_queryabooks('(objectClass=inetOrgPerson)',$FIELDS['_marker']);
28 foreach ($result as $entry){
29 if(!empty($entry[$FIELDS['_marker']]) && count($entry[$FIELDS['_marker']])){
30 foreach($entry[$FIELDS['_marker']] as $marker){
31 $marker = strtolower($marker);
32 if (empty($tags[$marker])) { $tags[$marker]=0; }
34 if($tags[$marker] > $max) $max = $tags[$marker];
35 if($tags[$marker] < $min) $min = $tags[$marker];
40 tag_cloud_weight(&$tags,$min,$max,6);
43 foreach($tags as $tag => $cnt){
44 $out .= '<a href="index.php?marker='.rawurlencode($tag).'" class="cloud_'.$cnt.'">';
45 $out .= htmlspecialchars($tag).'</a> ';
52 * Calculate weights for a nicer tagcloud distribution
54 function tag_cloud_weight(&$tags,$min,$max,$levels){
55 // calculate tresholds
57 for($i=0; $i<=$levels; $i++){
58 $tresholds[$i] = pow($max - $min + 1, $i/$levels);
62 foreach($tags as $tag => $cnt){
63 foreach($tresholds as $tresh => $val){
68 $tags[$tag] = $levels;