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>';
18 if(x($a->data,'search'))
19 $search = notags(trim($a->data['search']));
21 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
23 $tpl = load_view_file('view/directory_header.tpl');
26 $gdirpath = dirname(get_config('system','directory_submit_url'));
27 if(strlen($gdirpath)) {
28 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
29 . $gdirpath . '">' . t('Global Directory') . '</a></div></li></ul>';
32 $o .= replace_macros($tpl, array(
34 '$globaldir' => $globaldir,
35 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : "")
39 $search = dbesc($search);
40 $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) " : "");
42 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
45 $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 ");
47 $a->set_pager_total($r[0]['total']);
51 $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 ",
52 intval($a->pager['start']),
53 intval($a->pager['itemspage'])
57 $tpl = load_view_file('view/directory_item.tpl');
59 if(in_array('small', $a->argv))
67 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
69 if(strlen($rr['locality']))
70 $details .= $rr['locality'];
71 if(strlen($rr['region'])) {
72 if(strlen($rr['locality']))
74 $details .= $rr['region'];
76 if(strlen($rr['country-name'])) {
79 $details .= $rr['country-name'];
81 if(strlen($rr['dob'])) {
82 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
83 $details .= "<br />Age: $years" ;
85 if(strlen($rr['gender']))
86 $details .= '<br />Gender: ' . $rr['gender'];
88 $entry = replace_macros($tpl,array(
90 '$profile-link' => $profile_link,
91 '$photo' => $rr[$photo],
92 '$alt-text' => $rr['name'],
93 '$name' => $rr['name'],
94 '$details' => $details
99 $arr = array('contact' => $rr, 'entry' => $entry);
101 call_hooks('directory_item', $arr);
107 $o .= "<div class=\"directory-end\" ></div>\r\n";
112 notice("No entries (some entries may be hidden).");