]> git.mxchange.org Git - friendica.git/blob - mod/dirfind.php
rev update
[friendica.git] / mod / dirfind.php
1 <?php
2
3 function dirfind_init(&$a) {
4
5         require_once('include/contact_widgets.php');
6
7         if(! x($a->page,'aside'))
8                 $a->page['aside'] = '';
9
10         $a->page['aside'] .= follow_widget();
11
12         $a->page['aside'] .= findpeople_widget();
13 }
14
15
16
17 function dirfind_content(&$a) {
18
19         $search = notags(trim($_REQUEST['search']));
20
21         if(strpos($search,'@') === 0)
22                 $search = substr($search,1);
23         
24         $o = '';
25
26         $o .= '<h2>' . t('People Search') . ' - ' . $search . '</h2>';
27         
28         if($search) {
29
30                 $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
31                         
32                 if(strlen(get_config('system','directory_submit_url')))
33                         $x = fetch_url('http://dir.friendica.com/lsearch?f=' . $p .  '&search=' . urlencode($search));
34
35 //TODO fallback local search if global dir not available.
36 //              else
37 //                      $x = post_url($a->get_baseurl() . '/lsearch', $params);
38
39                 $j = json_decode($x);
40
41                 if($j->total) {
42                         $a->set_pager_total($j->total);
43                         $a->set_pager_itemspage($j->items_page);
44                 }
45
46                 if(count($j->results)) {
47                         
48                         $tpl = get_markup_template('match.tpl');
49                         foreach($j->results as $jj) {
50                                 
51                                 $o .= replace_macros($tpl,array(
52                                         '$url' => zrl($jj->url),
53                                         '$name' => $jj->name,
54                                         '$photo' => $jj->photo,
55                                         '$tags' => $jj->tags
56                                 ));
57                         }
58                 }
59                 else {
60                         info( t('No matches') . EOL);
61                 }               
62
63         }
64
65         $o .= '<div class="clear"></div>';
66         $o .= paginate($a);
67         return $o;
68 }