]> git.mxchange.org Git - friendica.git/blob - mod/directory.php
directory enhancements
[friendica.git] / mod / directory.php
1 <?php
2
3
4 function directory_content(&$a) {
5
6
7         $tpl .= file_get_contents('view/directory_header.tpl');
8
9         $o .= replace_macros($tpl, array(
10
11         ));
12
13         $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `publish` = 1 ORDER BY `name` ASC");
14         if(count($r)) {
15
16                 $tpl = file_get_contents('view/directory_item.tpl');
17
18                 if(in_array('small', $a->argv))
19                         $photo = 'thumb';
20                 else
21                         $photo = 'photo';
22
23                 foreach($r as $rr) {
24
25                         $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
26                         $details = '';
27                         if(strlen($rr['locality']))
28                                 $details .= $rr['locality'];
29                         if(strlen($rr['region'])) {
30                                 if(strlen($rr['locality']))
31                                         $details .= ', ';
32                                 $details .= $rr['region'];
33                         }
34                         if(strlen($rr['country-name'])) {
35                                 if(strlen($details))
36                                         $details .= ', ';
37                                 $details .= $rr['country-name'];
38                         }
39                         if(strlen($rr['dob']))
40                                 $details .= '<br />Age: ' ; // . calculate age($rr['dob'])) ;
41                         if(strlen($rr['gender']))
42                                 $details .= '<br />Gender: ' . $rr['gender'];
43
44                         $o .= replace_macros($tpl,array(
45                                 '$id' => $rr['id'],
46                                 '$profile-link' => $profile_link,
47                                 '$photo' => $rr[$photo],
48                                 '$alt-text' => $rr['name'],
49                                 '$name' => $rr['name'],
50                                 '$details' => $details  
51
52
53                         ));
54
55                 }
56                 $o .= "<div class=\"directory-end\" ></div>\r\n";
57         }
58         else
59                 notice("No entries (some entries may be hidden).");
60
61         return $o;
62 }