aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-01-18 19:00:41 -0800
committerfriendica <info@friendica.com>2013-01-18 19:00:41 -0800
commita168c628a2d1fd30bb5138fc7d0101963c4c5139 (patch)
treeaf4fefb9b5f6beabb256132e93be13eb82ff6fc8 /mod
parentaf5666b791c10aaee68c82009c18e4b55a373937 (diff)
downloadvolse-hubzilla-a168c628a2d1fd30bb5138fc7d0101963c4c5139.tar.gz
volse-hubzilla-a168c628a2d1fd30bb5138fc7d0101963c4c5139.tar.bz2
volse-hubzilla-a168c628a2d1fd30bb5138fc7d0101963c4c5139.zip
directory client mode
Diffstat (limited to 'mod')
-rw-r--r--mod/directory.php205
-rw-r--r--mod/dirsearch.php1
2 files changed, 98 insertions, 108 deletions
diff --git a/mod/directory.php b/mod/directory.php
index c9332f447..550e60522 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -38,148 +38,139 @@ function directory_content(&$a) {
$dirmode = intval(get_config('system','directory_mode'));
-// if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
-// $localdir = true;
-// return;
-// }
-
-// FIXME
-$localdir = true;
-
-
- if(! $localdir) {
+ if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
+ $url = z_root() . '/dirsearch';
+ }
+ if(! $url) {
$directory = find_upstream_directory($dirmode);
if($directory) {
$url = $directory['url'];
}
else {
- $url = DIRECTORY_FALLBACK_MASTER . '/post';
+ $url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
}
}
-
-
- if($localdir) {
+ if($url) {
+ $query = $url . ' ?f=' ;
if($search)
- $search = dbesc($search);
- $sql_extra = ((strlen($search)) ? " AND MATCH ( xchan_name, xchan_addr, xprof_desc, xprof_locale, xprof_region, xprof_country, xprof_gender, xprof_marital ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
+ $query .= '$name=' . urlencode($search);
- // group_concat(xtag_term separator ', ') as tags
- $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash $sql_extra");
- if($r)
- $a->set_pager_total($r[0]['total']);
+ }
+ if($a->pager['page'] != 1)
+ $query .= '&p=' . $a->pager['page'];
- $order = " ORDER BY `xchan_name` ASC ";
+ $x = z_fetch_url($query);
+ if($x['success']) {
+ $t = 0;
+ $j = json_decode($x['body'],true);
+ if($j && $j['results']) {
- $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash $sql_extra $order LIMIT %d , %d ",
- intval($a->pager['start']),
- intval($a->pager['itemspage'])
- );
+ $entries = array();
+ $photo = 'thumb';
- if($r) {
+ foreach($j['results'] as $rr) {
- $entries = array();
- $photo = 'thumb';
- foreach($r as $rr) {
- $profile_link = chanlink_hash($rr['xchan_hash']);
+ $profile_link = chanlink_url($rr['url']);
- $pdesc = (($rr['xprof_desc']) ? $rr['xprof_desc'] . '<br />' : '');
-
- $details = '';
- if(strlen($rr['xprof_locale']))
- $details .= $rr['xprof_locale'];
- if(strlen($rr['xprof_region'])) {
- if(strlen($rr['xprof_locale']))
- $details .= ', ';
- $details .= $rr['xprof_region'];
- }
- if(strlen($rr['xprof_country'])) {
- if(strlen($details))
- $details .= ', ';
- $details .= $rr['xprof_country'];
- }
- if(strlen($rr['xprof_dob'])) {
- if(($years = age($rr['xprof_dob'],'UTC','')) != 0)
- $details .= '<br />' . t('Age: ') . $years ;
- }
- if(strlen($rr['xprof_gender']))
- $details .= '<br />' . t('Gender: ') . $rr['xprof_gender'];
-
- $page_type = '';
-
- $profile = $rr;
-
- if ((x($profile,'xprof_locale') == 1)
- || (x($profile,'xprof_region') == 1)
- || (x($profile,'xprof_postcode') == 1)
- || (x($profile,'xprof_country') == 1))
- $location = t('Location:');
+ $pdesc = (($rr['description']) ? $rr['description'] . '<br />' : '');
+
+ $details = '';
+ if(strlen($rr['locale']))
+ $details .= $rr['locale'];
+ if(strlen($rr['region'])) {
+ if(strlen($rr['locale']))
+ $details .= ', ';
+ $details .= $rr['region'];
+ }
+ if(strlen($rr['country'])) {
+ if(strlen($details))
+ $details .= ', ';
+ $details .= $rr['country'];
+ }
+ if(strlen($rr['birthday'])) {
+ if(($years = age($rr['birthday'],'UTC','')) != 0)
+ $details .= '<br />' . t('Age: ') . $years ;
+ }
+ if(strlen($rr['gender']))
+ $details .= '<br />' . t('Gender: ') . $rr['gender'];
+
+ $page_type = '';
+
+ $profile = $rr;
+
+ if ((x($profile,'locale') == 1)
+ || (x($profile,'region') == 1)
+ || (x($profile,'postcode') == 1)
+ || (x($profile,'country') == 1))
+ $location = t('Location:');
+
+ $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
+
+ $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
+
+ $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
- $gender = ((x($profile,'xprof_gender') == 1) ? t('Gender:') : False);
+ $about = ((x($profile,'about') == 1) ? t('About:') : False);
+
- $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
+ $entry = array(
+ 'id' => ++$t,
+ 'profile_link' => $profile_link,
+ 'photo' => $rr['photo'],
+ 'alttext' => $rr['name'] . ' ' . $rr['address'],
+ 'name' => $rr['name'],
+ 'details' => $pdesc . $details,
+ 'profile' => $profile,
+ 'location' => $location,
+ 'gender' => $gender,
+ 'pdesc' => $pdesc,
+ 'marital' => $marital,
+ 'homepage' => $homepage,
+ 'about' => $about,
- $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
+ );
- $about = ((x($profile,'about') == 1) ? t('About:') : False);
-
- $t = 0;
-
- $entry = array(
- 'id' => ++$t,
- 'profile_link' => $profile_link,
- 'photo' => $rr[xchan_photo_m],
- 'alttext' => $rr['xchan_name'],
- 'name' => $rr['xchan_name'],
- 'details' => $pdesc . $details,
- 'profile' => $profile,
- 'location' => $location,
- 'gender' => $gender,
- 'pdesc' => $pdesc,
- 'marital' => $marital,
- 'homepage' => $homepage,
- 'about' => $about,
-
- );
-
- $arr = array('contact' => $rr, 'entry' => $entry);
-
- call_hooks('directory_item', $arr);
+ $arr = array('contact' => $rr, 'entry' => $entry);
+
+ call_hooks('directory_item', $arr);
- unset($profile);
- unset($location);
+ $entries[] = $entry;
- $entries[] = $entry;
+ unset($profile);
+ unset($location);
- }
- logger('entries: ' . print_r($entries,true));
+ }
+
+ logger('entries: ' . print_r($entries,true));
- $o .= replace_macros($tpl, array(
- '$search' => $search,
- '$desc' => t('Find'),
- '$finddsc' => t('Finding:'),
- '$safetxt' => htmlspecialchars($search,ENT_QUOTES,'UTF-8'),
- '$entries' => $entries,
- '$dirlbl' => t('Directory'),
- '$submit' => t('Find')
- ));
+ $o .= replace_macros($tpl, array(
+ '$search' => $search,
+ '$desc' => t('Find'),
+ '$finddsc' => t('Finding:'),
+ '$safetxt' => htmlspecialchars($search,ENT_QUOTES,'UTF-8'),
+ '$entries' => $entries,
+ '$dirlbl' => t('Directory'),
+ '$submit' => t('Find')
+ ));
- $o .= paginate($a);
+ $o .= alt_pager($a,$j['records']);
- }
+ }
- else
- info( t("No entries (some entries may be hidden).") . EOL);
+ else
+ info( t("No entries (some entries may be hidden).") . EOL);
- }
+ }
return $o;
}
+
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index 30a1fadae..1b1ad0877 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -36,7 +36,6 @@ function dirsearch_content(&$a) {
$marital = ((x($_REQUEST,'marital')) ? $_REQUEST['marital'] : '');
$keywords = ((x($_REQUEST,'keywords')) ? $_REQUEST['keywords'] : '');
-
$sql_extra = '';
if($name)