]> git.mxchange.org Git - friendica.git/blob - mod/match.php
rev update
[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         $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
11
12         $o .= '<h2>' . t('Profile Match') . '</h2>';
13
14         $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
15                 intval(local_user())
16         );
17         if(! count($r))
18                 return; 
19         if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
20                 notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
21                 return;
22
23         }
24
25         $params = array();
26         $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
27         
28         if($tags) {
29                 $params['s'] = $tags;
30                 if($a->pager['page'] != 1)
31                         $params['p'] = $a->pager['page'];
32                         
33                 if(strlen(get_config('system','directory_submit_url')))
34                         $x = post_url('http://dir.friendica.com/msearch', $params);
35                 else
36                         $x = post_url($a->get_baseurl() . '/msearch', $params);
37
38                 $j = json_decode($x);
39
40                 if($j->total) {
41                         $a->set_pager_total($j->total);
42                         $a->set_pager_itemspage($j->items_page);
43                 }
44
45                 if(count($j->results)) {
46
47
48                         
49                         $tpl = get_markup_template('match.tpl');
50                         foreach($j->results as $jj) {
51                                 
52                                 $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
53                                 $o .= replace_macros($tpl,array(
54                                         '$url' => zrl($jj->url),
55                                         '$name' => $jj->name,
56                                         '$photo' => $jj->photo,
57                                         '$inttxt' => ' ' . t('is interested in:'),
58                                         '$conntxt' => t('Connect'),
59                                         '$connlnk' => $connlnk,
60                                         '$tags' => $jj->tags
61                                 ));
62                         }
63                 }
64                 else {
65                         info( t('No matches') . EOL);
66                 }               
67
68         }
69
70         $o .= cleardiv();
71         $o .= paginate($a);
72         return $o;
73 }