2 function directory_init(&$a) {
3 $a->set_pager_itemspage(60);
6 function directory_content(&$a) {
7 $o .= '<script> $(document).ready(function() { $(\'#nav-directory-link\').addClass(\'nav-selected\'); });</script>';
9 $search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
11 $tpl .= load_view_file('view/directory_header.tpl');
14 $gdirpath = dirname(get_config('system','directory_submit_url'));
15 if(strlen($gdirpath)) {
16 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
17 . $gdirpath . '">' . t('Global Directory') . '</a></div></li></ul>';
20 $o .= replace_macros($tpl, array(
22 '$globaldir' => $globaldir,
23 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : "")
27 $search = dbesc($search);
28 $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) " : "");
31 $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 ");
33 $a->set_pager_total($r[0]['total']);
37 $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 ",
38 intval($a->pager['start']),
39 intval($a->pager['itemspage'])
43 $tpl = load_view_file('view/directory_item.tpl');
45 if(in_array('small', $a->argv))
53 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
55 if(strlen($rr['locality']))
56 $details .= $rr['locality'];
57 if(strlen($rr['region'])) {
58 if(strlen($rr['locality']))
60 $details .= $rr['region'];
62 if(strlen($rr['country-name'])) {
65 $details .= $rr['country-name'];
67 if(strlen($rr['dob'])) {
68 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
69 $details .= "<br />Age: $years" ;
71 if(strlen($rr['gender']))
72 $details .= '<br />Gender: ' . $rr['gender'];
74 $o .= replace_macros($tpl,array(
76 '$profile-link' => $profile_link,
77 '$photo' => $rr[$photo],
78 '$alt-text' => $rr['name'],
79 '$name' => $rr['name'],
80 '$details' => $details
86 $o .= "<div class=\"directory-end\" ></div>\r\n";
91 notice("No entries (some entries may be hidden).");