3 function directory_init(&$a) {
4 $a->set_pager_itemspage(60);
8 function directory_post(&$a) {
10 $a->data['search'] = $_POST['search'];
15 function directory_content(&$a) {
17 $everything = (($a->argc > 1 && $a->argv[1] === 'all' && is_site_admin()) ? true : false);
19 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
20 notice( t('Public access denied.') . EOL);
25 $o .= '<script> $(document).ready(function() { $(\'#nav-directory-link\').addClass(\'nav-selected\'); });</script>';
26 if(x($_SESSION,'theme'))
27 unset($_SESSION['theme']);
29 if(x($a->data,'search'))
30 $search = notags(trim($a->data['search']));
32 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
34 $tpl = get_markup_template('directory_header.tpl');
37 $gdirpath = dirname(get_config('system','directory_submit_url'));
38 if(strlen($gdirpath)) {
39 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
40 . $gdirpath . '">' . t('Global Directory') . '</a></div></li></ul>';
46 $admin = '<ul><li><div id="directory-admin-link"><a href="' . $a->get_baseurl() . '/directory' . '">' . t('Normal site view') . '</a></div></li></ul>';
48 $admin = '<ul><li><div id="directory-admin-link"><a href="' . $a->get_baseurl() . '/directory/all' . '">' . t('View all site entries') . '</a></div></li></ul>';
51 $o .= replace_macros($tpl, array(
53 '$globaldir' => $globaldir,
55 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
56 '$sitedir' => t('Site Directory'),
57 '$submit' => t('Find')
61 $search = dbesc($search);
62 $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
64 $publish = ((get_config('system','publish_all') || $everything) ? '' : " AND `publish` = 1 " );
67 $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 ");
69 $a->set_pager_total($r[0]['total']);
72 $order = " ORDER BY `register_date` DESC ";
74 $order = " ORDER BY `name` ASC ";
77 $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 LIMIT %d , %d ",
78 intval($a->pager['start']),
79 intval($a->pager['itemspage'])
83 $tpl = get_markup_template('directory_item.tpl');
85 if(in_array('small', $a->argv))
93 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
95 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
98 if(strlen($rr['locality']))
99 $details .= $rr['locality'];
100 if(strlen($rr['region'])) {
101 if(strlen($rr['locality']))
103 $details .= $rr['region'];
105 if(strlen($rr['country-name'])) {
108 $details .= $rr['country-name'];
110 if(strlen($rr['dob'])) {
111 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
112 $details .= '<br />' . t('Age: ') . $years ;
114 if(strlen($rr['gender']))
115 $details .= '<br />' . t('Gender: ') . $rr['gender'];
117 $entry = replace_macros($tpl,array(
119 '$profile-link' => $profile_link,
120 '$photo' => $rr[$photo],
121 '$alt-text' => $rr['name'],
122 '$name' => $rr['name'],
123 '$details' => $pdesc . $details
128 $arr = array('contact' => $rr, 'entry' => $entry);
130 call_hooks('directory_item', $arr);
136 $o .= "<div class=\"directory-end\" ></div>\r\n";
141 notice( t("No entries \x28some entries may be hidden\x29.") . EOL);