2011-10-03 08:10:15 -04:00
|
|
|
<?php
|
|
|
|
|
2011-10-11 22:27:58 -04:00
|
|
|
function dirfind_init(&$a) {
|
|
|
|
|
|
|
|
require_once('include/contact_widgets.php');
|
|
|
|
|
|
|
|
if(! x($a->page,'aside'))
|
|
|
|
$a->page['aside'] = '';
|
|
|
|
|
|
|
|
$a->page['aside'] .= follow_widget();
|
|
|
|
|
|
|
|
$a->page['aside'] .= findpeople_widget();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-03 08:10:15 -04:00
|
|
|
|
2011-10-11 21:24:37 -04:00
|
|
|
function dirfind_content(&$a) {
|
2011-10-03 08:10:15 -04:00
|
|
|
|
2011-10-03 17:47:18 -04:00
|
|
|
$search = notags(trim($_REQUEST['search']));
|
2012-05-20 00:53:27 -04:00
|
|
|
|
|
|
|
if(strpos($search,'@') === 0)
|
|
|
|
$search = substr($search,1);
|
2011-10-03 08:10:15 -04:00
|
|
|
|
|
|
|
$o = '';
|
|
|
|
|
2015-05-29 20:21:30 -04:00
|
|
|
$o .= replace_macros(get_markup_template("section_title.tpl"),array(
|
|
|
|
'$title' => sprintf( t('People Search - %s'), $search)
|
|
|
|
));
|
|
|
|
|
2011-10-03 08:10:15 -04:00
|
|
|
if($search) {
|
2011-10-03 17:47:18 -04:00
|
|
|
|
|
|
|
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
|
2011-10-03 08:10:15 -04:00
|
|
|
|
|
|
|
if(strlen(get_config('system','directory_submit_url')))
|
2012-02-19 13:45:08 -05:00
|
|
|
$x = fetch_url('http://dir.friendica.com/lsearch?f=' . $p . '&search=' . urlencode($search));
|
2011-10-03 17:47:18 -04:00
|
|
|
|
|
|
|
//TODO fallback local search if global dir not available.
|
2011-10-03 08:10:15 -04:00
|
|
|
// else
|
2011-10-03 17:47:18 -04:00
|
|
|
// $x = post_url($a->get_baseurl() . '/lsearch', $params);
|
2011-10-03 08:10:15 -04:00
|
|
|
|
|
|
|
$j = json_decode($x);
|
|
|
|
|
|
|
|
if($j->total) {
|
|
|
|
$a->set_pager_total($j->total);
|
|
|
|
$a->set_pager_itemspage($j->items_page);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(count($j->results)) {
|
|
|
|
|
|
|
|
$tpl = get_markup_template('match.tpl');
|
|
|
|
foreach($j->results as $jj) {
|
|
|
|
|
|
|
|
$o .= replace_macros($tpl,array(
|
2012-03-30 01:20:14 -04:00
|
|
|
'$url' => zrl($jj->url),
|
2011-10-03 08:10:15 -04:00
|
|
|
'$name' => $jj->name,
|
|
|
|
'$photo' => $jj->photo,
|
|
|
|
'$tags' => $jj->tags
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
info( t('No matches') . EOL);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$o .= '<div class="clear"></div>';
|
|
|
|
$o .= paginate($a);
|
|
|
|
return $o;
|
|
|
|
}
|