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 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
18 notice( t('Public access denied.') . EOL);
23 $o .= '<script> $(document).ready(function() { $(\'#nav-directory-link\').addClass(\'nav-selected\'); });</script>';
24 if(x($_SESSION,'theme'))
25 unset($_SESSION['theme']);
27 if(x($a->data,'search'))
28 $search = notags(trim($a->data['search']));
30 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
32 $tpl = get_markup_template('directory_header.tpl');
35 $gdirpath = dirname(get_config('system','directory_submit_url'));
36 if(strlen($gdirpath)) {
37 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
38 . $gdirpath . '">' . t('Global Directory') . '</a></div></li></ul>';
41 $o .= replace_macros($tpl, array(
43 '$globaldir' => $globaldir,
44 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
45 '$sitedir' => t('Site Directory'),
46 '$submit' => t('Find')
50 $search = dbesc($search);
51 $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) " : "");
53 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
56 $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 ");
58 $a->set_pager_total($r[0]['total']);
62 $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 ",
63 intval($a->pager['start']),
64 intval($a->pager['itemspage'])
68 $tpl = get_markup_template('directory_item.tpl');
70 if(in_array('small', $a->argv))
78 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
80 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
83 if(strlen($rr['locality']))
84 $details .= $rr['locality'];
85 if(strlen($rr['region'])) {
86 if(strlen($rr['locality']))
88 $details .= $rr['region'];
90 if(strlen($rr['country-name'])) {
93 $details .= $rr['country-name'];
95 if(strlen($rr['dob'])) {
96 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
97 $details .= '<br />' . t('Age: ') . $years ;
99 if(strlen($rr['gender']))
100 $details .= '<br />' . t('Gender: ') . $rr['gender'];
102 $entry = replace_macros($tpl,array(
104 '$profile-link' => $profile_link,
105 '$photo' => $rr[$photo],
106 '$alt-text' => $rr['name'],
107 '$name' => $rr['name'],
108 '$details' => $pdesc . $details
113 $arr = array('contact' => $rr, 'entry' => $entry);
115 call_hooks('directory_item', $arr);
121 $o .= "<div class=\"directory-end\" ></div>\r\n";
126 notice( t("No entries \x28some entries may be hidden\x29.") . EOL);