2 function directory_init(&$a) {
3 $a->set_pager_itemspage(60);
7 function directory_post(&$a) {
9 $a->data['search'] = $_POST['search'];
14 function directory_content(&$a) {
16 $o .= '<script> $(document).ready(function() { $(\'#nav-directory-link\').addClass(\'nav-selected\'); });</script>';
17 if(x($_SESSION,'theme'))
18 unset($_SESSION['theme']);
20 if(x($a->data,'search'))
21 $search = notags(trim($a->data['search']));
23 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
25 $tpl = load_view_file('view/directory_header.tpl');
28 $gdirpath = dirname(get_config('system','directory_submit_url'));
29 if(strlen($gdirpath)) {
30 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
31 . $gdirpath . '">' . t('Global Directory') . '</a></div></li></ul>';
34 $o .= replace_macros($tpl, array(
36 '$globaldir' => $globaldir,
37 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : "")
41 $search = dbesc($search);
42 $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
44 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
47 $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
49 $a->set_pager_total($r[0]['total']);
53 $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 $publish AND `user`.`blocked` = 0 $sql_extra ORDER BY `name` ASC LIMIT %d , %d ",
54 intval($a->pager['start']),
55 intval($a->pager['itemspage'])
59 $tpl = load_view_file('view/directory_item.tpl');
61 if(in_array('small', $a->argv))
69 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
71 if(strlen($rr['locality']))
72 $details .= $rr['locality'];
73 if(strlen($rr['region'])) {
74 if(strlen($rr['locality']))
76 $details .= $rr['region'];
78 if(strlen($rr['country-name'])) {
81 $details .= $rr['country-name'];
83 if(strlen($rr['dob'])) {
84 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
85 $details .= "<br />Age: $years" ;
87 if(strlen($rr['gender']))
88 $details .= '<br />Gender: ' . $rr['gender'];
90 $entry = replace_macros($tpl,array(
92 '$profile-link' => $profile_link,
93 '$photo' => $rr[$photo],
94 '$alt-text' => $rr['name'],
95 '$name' => $rr['name'],
96 '$details' => $details
101 $arr = array('contact' => $rr, 'entry' => $entry);
103 call_hooks('directory_item', $arr);
109 $o .= "<div class=\"directory-end\" ></div>\r\n";
114 notice("No entries (some entries may be hidden).");