2 function directory_init(&$a) {
3 $a->set_pager_itemspage(60);
6 function directory_content(&$a) {
8 $o .= '<script> $(document).ready(function() { $(\'#nav-directory-link\').addClass(\'nav-selected\'); });</script>';
10 $search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
12 $tpl = load_view_file('view/directory_header.tpl');
15 $gdirpath = dirname(get_config('system','directory_submit_url'));
16 if(strlen($gdirpath)) {
17 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
18 . $gdirpath . '">' . t('Global Directory') . '</a></div></li></ul>';
21 $o .= replace_macros($tpl, array(
23 '$globaldir' => $globaldir,
24 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : "")
28 $search = dbesc($search);
29 $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`) AGAINST ('$search' IN BOOLEAN MODE) " : "");
32 $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `publish` = 1 AND `user`.`blocked` = 0 $sql_extra ");
34 $a->set_pager_total($r[0]['total']);
38 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `publish` = 1 AND `user`.`blocked` = 0 $sql_extra ORDER BY `name` ASC LIMIT %d , %d ",
39 intval($a->pager['start']),
40 intval($a->pager['itemspage'])
44 $tpl = load_view_file('view/directory_item.tpl');
46 if(in_array('small', $a->argv))
54 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
56 if(strlen($rr['locality']))
57 $details .= $rr['locality'];
58 if(strlen($rr['region'])) {
59 if(strlen($rr['locality']))
61 $details .= $rr['region'];
63 if(strlen($rr['country-name'])) {
66 $details .= $rr['country-name'];
68 if(strlen($rr['dob'])) {
69 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
70 $details .= "<br />Age: $years" ;
72 if(strlen($rr['gender']))
73 $details .= '<br />Gender: ' . $rr['gender'];
75 $o .= replace_macros($tpl,array(
77 '$profile-link' => $profile_link,
78 '$photo' => $rr[$photo],
79 '$alt-text' => $rr['name'],
80 '$name' => $rr['name'],
81 '$details' => $details
87 $o .= "<div class=\"directory-end\" ></div>\r\n";
92 notice("No entries (some entries may be hidden).");