]> git.mxchange.org Git - friendica.git/blob - mod/dirfind.php
Removed Google Maps
[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 .= replace_macros(get_markup_template("section_title.tpl"),array(
27                 '$title' => sprintf( t('People Search - %s'), $search)
28         ));
29
30         if($search) {
31
32                 $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
33                         
34                 if(strlen(get_config('system','directory_submit_url')))
35                         $x = fetch_url('http://dir.friendica.com/lsearch?f=' . $p .  '&search=' . urlencode($search));
36
37 //TODO fallback local search if global dir not available.
38 //              else
39 //                      $x = post_url($a->get_baseurl() . '/lsearch', $params);
40
41                 $j = json_decode($x);
42
43                 if($j->total) {
44                         $a->set_pager_total($j->total);
45                         $a->set_pager_itemspage($j->items_page);
46                 }
47
48                 if(count($j->results)) {
49                         
50                         $tpl = get_markup_template('match.tpl');
51                         foreach($j->results as $jj) {
52                                 
53                                 $o .= replace_macros($tpl,array(
54                                         '$url' => zrl($jj->url),
55                                         '$name' => $jj->name,
56                                         '$photo' => $jj->photo,
57                                         '$tags' => $jj->tags
58                                 ));
59                         }
60                 }
61                 else {
62                         info( t('No matches') . EOL);
63                 }               
64
65         }
66
67         $o .= '<div class="clear"></div>';
68         $o .= paginate($a);
69         return $o;
70 }