]> git.sur5r.net Git - contagged/blob - tags.php
tagcloud added
[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('header.tpl');
11   $smarty->display('list_filter.tpl');
12   $smarty->display('tags.tpl');
13   $smarty->display('footer.tpl');
14
15   function tag_cloud(){
16     global $conf;
17     global $LDAP_CON;
18     if(!$conf[extended]) return;
19     
20     $result = ldap_queryabooks('(objectClass=contactPerson)','marker');
21
22     $max = 0;
23     $tags = array();
24     foreach ($result as $entry){
25       if(count($entry['marker'])){
26         foreach($entry['marker'] as $marker){
27           $marker = strtolower($marker);
28           $tags[$marker] += 1;
29           if($tags[$marker] > $max) $max = $tags[$marker];
30         }
31       }
32     }
33     ksort($tags);
34
35     $out = '';
36     foreach($tags as $tag => $cnt){
37       $pct = round($cnt * 20 / $max); // percents from 0 to 20
38
39       $out .= '<a href="index.php?marker='.rawurlencode($tag).'" class="tc'.$pct.'">';
40       $out .= htmlspecialchars($tag).'</a> ';
41     }
42
43     return $out;
44   }
45
46 ?>