]> git.mxchange.org Git - friendica.git/blob - mod/match.php
Merge branch 'master' of git://github.com/friendika/Free-Friendika
[friendica.git] / mod / match.php
1 <?php
2
3
4 function match_content(&$a) {
5
6         $o = '';
7         if(! local_user())
8                 return;
9
10         $o .= '<h2>' . t('Profile Match') . '</h2>';
11
12         $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
13                 intval(local_user())
14         );
15         if(! count($r))
16                 return; 
17         if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
18                 notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
19                 return;
20
21         }
22
23         $params = array();
24         $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
25         
26         if($tags) {
27                 $params['s'] = $tags;
28                 if($a->pager['page'] != 1)
29                         $params['p'] = $a->pager['page'];
30                         
31                 if(strlen(get_config('system','directory_submit_url')))
32                         $x = post_url('http://dir.friendika.com/msearch', $params);
33                 else
34                         $x = post_url($a->get_baseurl() . '/msearch', $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' => $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 .= paginate($a);
63         return $o;
64 }