aboutsummaryrefslogtreecommitdiffstats
path: root/mod/directory.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/directory.php')
-rw-r--r--mod/directory.php98
1 files changed, 72 insertions, 26 deletions
diff --git a/mod/directory.php b/mod/directory.php
index 21fb14bfc..b11b0d410 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -1,22 +1,14 @@
<?php
require_once('include/dir_fns.php');
+require_once('include/widgets.php');
function directory_init(&$a) {
- $a->set_pager_itemspage(60);
+ $a->set_pager_itemspage(80);
}
-function directory_aside(&$a) {
-
- if(local_user()) {
- require_once('include/contact_widgets.php');
- $a->set_widget('find_people',findpeople_widget());
- }
-}
-
-
function directory_content(&$a) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
@@ -24,6 +16,24 @@ function directory_content(&$a) {
return;
}
+ $safe_mode = 1;
+
+ $observer = get_observer_hash();
+
+ if($observer) {
+ $safe_mode = get_xconfig($observer,'directory','safe_mode');
+ }
+ if($safe_mode === false)
+ $safe_mode = 1;
+ else
+ $safe_mode = intval($safe_mode);
+
+ if(x($_REQUEST,'safe'))
+ $safe_mode = (intval($_REQUEST['safe']));
+
+
+
+
$o = '';
nav_set_selected('directory');
@@ -32,10 +42,13 @@ function directory_content(&$a) {
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
+ $advanced = ((x($_REQUEST,'query')) ? notags(trim($_REQUEST['query'])) : '');
- $tpl = get_markup_template('directory_header.tpl');
+ $keywords = (($_GET['keywords']) ? $_GET['keywords'] : '');
+ $tpl = get_markup_template('directory_header.tpl');
+
$dirmode = intval(get_config('system','directory_mode'));
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
@@ -43,22 +56,45 @@ function directory_content(&$a) {
}
if(! $url) {
$directory = find_upstream_directory($dirmode);
+ $url = $directory['url'] . '/dirsearch';
+ }
- if($directory) {
- $url = $directory['url'];
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
+ logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
+
+ $contacts = array();
+
+ if(local_user()) {
+ $x = q("select abook_xchan from abook where abook_channel = %d",
+ intval(local_user())
+ );
+ if($x) {
+ foreach($x as $xx)
+ $contacts[] = $xx['abook_xchan'];
}
}
- logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
+
+
if($url) {
- $query = $url . '?f=' ;
+ // We might want to make the tagadelic count (&kw=) configurable or turn it off completely.
+
+ $numtags = get_config('system','directorytags');
+
+ $kw = ((intval($numtags)) ? $numtags : 24);
+ $query = $url . '?f=&kw=' . $kw . (($safe_mode != 1) ? '&safe=' . $safe_mode : '');
+
if($search)
- $query .= '&name=' . urlencode($search);
+ $query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
if(strpos($search,'@'))
$query .= '&address=' . urlencode($search);
+ if($keywords)
+ $query .= '&keywords=' . urlencode($keywords);
+ if($advanced)
+ $query .= '&query=' . urlencode($advanced);
+
+ $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : '');
+ if($sort_order)
+ $query .= '&order=' . urlencode($sort_order);
if($a->pager['page'] != 1)
$query .= '&p=' . $a->pager['page'];
@@ -66,7 +102,7 @@ function directory_content(&$a) {
logger('mod_directory: query: ' . $query);
$x = z_fetch_url($query);
- logger('directory: return from upstream: ' . print_r($x,true));
+ logger('directory: return from upstream: ' . print_r($x,true), LOGGER_DATA);
if($x['success']) {
$t = 0;
@@ -84,7 +120,11 @@ function directory_content(&$a) {
$profile_link = chanlink_url($rr['url']);
$pdesc = (($rr['description']) ? $rr['description'] . '<br />' : '');
-
+ $connect_link = ((local_user()) ? z_root() . '/follow?f=&url=' . urlencode($rr['address']) : '');
+
+ if(in_array($rr['hash'],$contacts))
+ $connect_link = '';
+
$details = '';
if(strlen($rr['locale']))
$details .= $rr['locale'];
@@ -128,32 +168,38 @@ function directory_content(&$a) {
'id' => ++$t,
'profile_link' => $profile_link,
'photo' => $rr['photo'],
+ 'hash' => $rr['hash'],
'alttext' => $rr['name'] . ' ' . $rr['address'],
'name' => $rr['name'],
'details' => $pdesc . $details,
'profile' => $profile,
+ 'address' => $rr['address'],
'location' => $location,
'gender' => $gender,
'pdesc' => $pdesc,
'marital' => $marital,
'homepage' => $homepage,
'about' => $about,
-
+ 'conn_label' => t('Connect'),
+ 'connect' => $connect_link,
);
$arr = array('contact' => $rr, 'entry' => $entry);
call_hooks('directory_item', $arr);
- $entries[] = $entry;
-
+ $entries[] = $arr['entry'];
unset($profile);
unset($location);
}
- logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA);
+ if($j['keywords']) {
+ $a->data['directory_keywords'] = $j['keywords'];
+ }
+
+// logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA);
$o .= replace_macros($tpl, array(
'$search' => $search,
@@ -166,7 +212,7 @@ function directory_content(&$a) {
));
- $o .= alt_pager($a,$j['records'], t('more'), t('back'));
+ $o .= alt_pager($a,$j['records'], t('next page'), t('previous page'));
}
else {