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