2011-10-03 12:10:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
2011-10-12 01:24:37 +00:00
|
|
|
function dirfind_content(&$a) {
|
2011-10-03 12:10:15 +00:00
|
|
|
|
2011-10-03 21:47:18 +00:00
|
|
|
$search = notags(trim($_REQUEST['search']));
|
2011-10-03 12:10:15 +00:00
|
|
|
|
|
|
|
$o = '';
|
|
|
|
|
2011-10-12 01:24:37 +00:00
|
|
|
$o .= '<h2>' . t('People Search') . ' - ' . $search . '</h2>';
|
2011-10-03 12:10:15 +00:00
|
|
|
|
|
|
|
if($search) {
|
2011-10-03 21:47:18 +00:00
|
|
|
|
|
|
|
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
|
2011-10-03 12:10:15 +00:00
|
|
|
|
|
|
|
if(strlen(get_config('system','directory_submit_url')))
|
2011-10-03 21:47:18 +00:00
|
|
|
$x = fetch_url('http://dir.friendika.com/lsearch?f=' . $p . '&search=' . urlencode($search));
|
|
|
|
|
|
|
|
//TODO fallback local search if global dir not available.
|
2011-10-03 12:10:15 +00:00
|
|
|
// else
|
2011-10-03 21:47:18 +00:00
|
|
|
// $x = post_url($a->get_baseurl() . '/lsearch', $params);
|
2011-10-03 12:10:15 +00: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(
|
|
|
|
'$url' => $jj->url,
|
|
|
|
'$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;
|
|
|
|
}
|