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 $o .= '<script> $(document).ready(function() { $(\'#nav-directory-link\').addClass(\'nav-selected\'); });</script>';
18 if(x($_SESSION,'theme'))
19 unset($_SESSION['theme']);
21 if(x($a->data,'search'))
22 $search = notags(trim($a->data['search']));
24 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
26 $tpl = load_view_file('view/directory_header.tpl');
29 $gdirpath = dirname(get_config('system','directory_submit_url'));
30 if(strlen($gdirpath)) {
31 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
32 . $gdirpath . '">' . t('Global Directory') . '</a></div></li></ul>';
35 $o .= replace_macros($tpl, array(
37 '$globaldir' => $globaldir,
38 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
39 '$sitedir' => t('Site Directory'),
40 '$submit' => t('Find')
44 $search = dbesc($search);
45 $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) " : "");
47 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
50 $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 ");
52 $a->set_pager_total($r[0]['total']);
56 $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 ",
57 intval($a->pager['start']),
58 intval($a->pager['itemspage'])
62 $tpl = load_view_file('view/directory_item.tpl');
64 if(in_array('small', $a->argv))
72 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
74 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
77 if(strlen($rr['locality']))
78 $details .= $rr['locality'];
79 if(strlen($rr['region'])) {
80 if(strlen($rr['locality']))
82 $details .= $rr['region'];
84 if(strlen($rr['country-name'])) {
87 $details .= $rr['country-name'];
89 if(strlen($rr['dob'])) {
90 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
91 $details .= '<br />' . t('Age: ') . $years ;
93 if(strlen($rr['gender']))
94 $details .= '<br />' . t('Gender: ') . $rr['gender'];
96 $entry = replace_macros($tpl,array(
98 '$profile-link' => $profile_link,
99 '$photo' => $rr[$photo],
100 '$alt-text' => $rr['name'],
101 '$name' => $rr['name'],
102 '$details' => $pdesc . $details
107 $arr = array('contact' => $rr, 'entry' => $entry);
109 call_hooks('directory_item', $arr);
115 $o .= "<div class=\"directory-end\" ></div>\r\n";
120 notice( t("No entries \x28some entries may be hidden\x29.") . EOL);