]> git.sur5r.net Git - contagged/blob - tags.php
changed layout, some HTML cleanup
[contagged] / tags.php
1 <?
2   require_once('init.php');
3   ldap_login();
4
5   //prepare templates
6   tpl_std();
7   $smarty->assign('tagcloud',tag_cloud());
8   //display templates
9   header('Content-Type: text/html; charset=utf-8');
10   $smarty->display('tags.tpl');
11
12   function tag_cloud(){
13     global $conf;
14     global $LDAP_CON;
15     if(!$conf[extended]) return;
16     
17     $result = ldap_queryabooks('(objectClass=contactPerson)','marker');
18
19     $max = 0;
20     $tags = array();
21     foreach ($result as $entry){
22       if(count($entry['marker'])){
23         foreach($entry['marker'] as $marker){
24           $marker = strtolower($marker);
25           $tags[$marker] += 1;
26           if($tags[$marker] > $max) $max = $tags[$marker];
27         }
28       }
29     }
30     ksort($tags);
31
32     $out = '';
33     foreach($tags as $tag => $cnt){
34       $pct = round($cnt * 20 / $max); // percents from 0 to 20
35
36       $out .= '<a href="index.php?marker='.rawurlencode($tag).'" class="tc'.$pct.'">';
37       $out .= htmlspecialchars($tag).'</a> ';
38     }
39
40     return $out;
41   }
42
43 ?>