]> git.mxchange.org Git - friendica.git/blob - mod/match.php
Merge remote-tracking branch 'upstream/master'
[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         if($tags) {
26                 $params['s'] = $tags;
27                 if($a->pager['page'] != 1)
28                         $params['p'] = $a->pager['page'];
29                         
30                 if(strlen(get_config('system','directory_submit_url')))
31                         $x = post_url('http://dir.friendika.com/msearch', $params);
32                 else
33                         $x = post_url($a->get_baseurl() . '/msearch', $params);
34
35                 $j = json_decode($x);
36
37                 if($j->total) {
38                         $a->set_pager_total($j->total);
39                         $a->set_pager_itemspage($j->items_page);
40                 }
41
42                 if(count($j->results)) {
43                         foreach($j->results as $jj) {
44
45                                 $o .= '<div class="profile-match-wrapper"><div class="profile-match-photo">';
46                                 $o .= '<a href="' . $jj->url . '">' . '<img src="' . $jj->photo . '" alt="' . $jj->name . '" title="' . $jj->name . '[' . $jj->tags . ']' . '" /></a></div>';
47                                 $o .= '<div class="profile-match-break"></div>';
48                                 $o .= '<div class="profile-match-name"><a href="' . $jj->url . '" title="' . $jj->name . '[' . $jj->url .']' . '">' . $jj->name . '</a></div>';
49                                 $o .= '<div class="profile-match-end"></div></div>';
50                         }
51                         $o .= '<div id="profile-match-wrapper-end"></div>';
52                 }
53                 else {
54                         info( t('No matches') . EOL);
55                 }               
56
57         }
58
59         $o .= paginate($a);
60         return $o;
61 }