]> git.mxchange.org Git - friendica.git/blob - mod/match.php
Merge branch 'erikl-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('No keywords to match. Please add keywords to your default profile.');
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                 $x = post_url('http://dir.friendika.com/msearch', $params);
31
32                 $j = json_decode($x);
33
34                 if($j->total) {
35                         $a->set_pager_total($j->total);
36                         $a->set_pager_itemspage($j->items_page);
37                 }
38
39                 if(count($j->results)) {
40                         foreach($j->results as $jj) {
41                                 $o .= '<div class="profile-match-wrapper"><div class="profile-match-photo">';
42                                 $o .= '<a href="' . $jj->url . '">' . '<img src="' . $jj->photo . '" alt="' . $jj->name . '" title="' . $jj->name . '[' . $jj->url . ']' . '" /></a></div>';
43                                 $o .= '<div class="profile-match-break"></div>';
44                                 $o .= '<div class="profile-match-name"><a href="' . $jj->url . '" title="' . $jj->name . '[' . $jj->url .']' . '">' . $jj->name . '</a></div>';
45                                 $o .= '<div class="profile-match-end"></div></div>';
46                         }
47                         $o .= '<div id="profile-match-wrapper-end"></div>';
48                 }
49                 else {
50                         notice( t('No matches') . EOL);
51                 }               
52
53         }
54
55         $o .= paginate($a);
56         return $o;
57 }