2 require_once('inc/init.php');
5 if ($conf['userlogreq'] && !isset($_SESSION['ldapab']['username'])){
6 header('Location: login.php');
11 $smarty->assign('tagcloud',tag_cloud());
13 header('Content-Type: text/html; charset=utf-8');
14 $smarty->display('tags.tpl');
20 if(!$FIELDS['_marker']) return;
22 $result = ldap_queryabooks('(objectClass=inetOrgPerson)',$FIELDS['_marker']);
26 foreach ($result as $entry){
27 if(!empty($entry[$FIELDS['_marker']]) && count($entry[$FIELDS['_marker']])){
28 foreach($entry[$FIELDS['_marker']] as $marker){
29 $marker = strtolower($marker);
30 if (empty($tags[$marker])) { $tags[$marker]=0; }
32 if($tags[$marker] > $max) $max = $tags[$marker];
33 if($tags[$marker] < $min) $min = $tags[$marker];
38 tag_cloud_weight(&$tags,$min,$max,6);
41 foreach($tags as $tag => $cnt){
42 $out .= '<a href="index.php?marker='.rawurlencode($tag).'" class="cloud_'.$cnt.'">';
43 $out .= htmlspecialchars($tag).'</a> ';
50 * Calculate weights for a nicer tagcloud distribution
52 function tag_cloud_weight(&$tags,$min,$max,$levels){
53 // calculate tresholds
55 for($i=0; $i<=$levels; $i++){
56 $tresholds[$i] = pow($max - $min + 1, $i/$levels);
60 foreach($tags as $tag => $cnt){
61 foreach($tresholds as $tresh => $val){
66 $tags[$tag] = $levels;