]> git.mxchange.org Git - friendica.git/blob - mod/tagmatch.php
common_tabs in notifications.php
[friendica.git] / mod / tagmatch.php
1 <?php
2
3
4 function tagmatch_content(&$a) {
5
6         $search = notags(trim($_REQUEST['search']));
7         
8         $o = '';
9
10         $o .= '<h2>' . t('Tag Match') . ' - ' . $search . '</h2>';
11         
12         if($search) {
13
14                 $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
15                         
16                 if(strlen(get_config('system','directory_submit_url')))
17                         $x = fetch_url('http://dir.friendika.com/lsearch?f=' . $p .  '&search=' . urlencode($search));
18
19 //TODO fallback local search if global dir not available.
20 //              else
21 //                      $x = post_url($a->get_baseurl() . '/lsearch', $params);
22
23                 $j = json_decode($x);
24
25                 if($j->total) {
26                         $a->set_pager_total($j->total);
27                         $a->set_pager_itemspage($j->items_page);
28                 }
29
30                 if(count($j->results)) {
31                         
32                         $tpl = get_markup_template('match.tpl');
33                         foreach($j->results as $jj) {
34                                 
35                                 $o .= replace_macros($tpl,array(
36                                         '$url' => $jj->url,
37                                         '$name' => $jj->name,
38                                         '$photo' => $jj->photo,
39                                         '$tags' => $jj->tags
40                                 ));
41                         }
42                 }
43                 else {
44                         info( t('No matches') . EOL);
45                 }               
46
47         }
48
49         $o .= '<div class="clear"></div>';
50         $o .= paginate($a);
51         return $o;
52 }