]> git.mxchange.org Git - friendica.git/blob - mod/match.php
Merge pull request #1944 from annando/1510-proxy-picture-size
[friendica.git] / mod / match.php
1 <?php
2 include_once('include/text.php');
3 require_once('include/socgraph.php');
4 require_once('include/contact_widgets.php');
5 require_once('mod/proxy.php');
6
7 function match_content(&$a) {
8
9         $o = '';
10         if(! local_user())
11                 return;
12
13         $a->page['aside'] .= follow_widget();
14         $a->page['aside'] .= findpeople_widget();
15
16         $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
17
18         $o .= replace_macros(get_markup_template("section_title.tpl"),array(
19                 '$title' => t('Profile Match')
20         ));
21
22         $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
23                 intval(local_user())
24         );
25         if(! count($r))
26                 return;
27         if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
28                 notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
29                 return;
30
31         }
32
33         $params = array();
34         $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
35
36         if($tags) {
37                 $params['s'] = $tags;
38                 if($a->pager['page'] != 1)
39                         $params['p'] = $a->pager['page'];
40
41                 if(strlen(get_config('system','directory')))
42                         $x = post_url(get_server().'/msearch', $params);
43                 else
44                         $x = post_url($a->get_baseurl() . '/msearch', $params);
45
46                 $j = json_decode($x);
47
48                 if($j->total) {
49                         $a->set_pager_total($j->total);
50                         $a->set_pager_itemspage($j->items_page);
51                 }
52
53                 if(count($j->results)) {
54
55
56
57                         $tpl = get_markup_template('match.tpl');
58                         foreach($j->results as $jj) {
59                                 $match_nurl = normalise_link($jj->url);
60                                 $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
61                                         intval(local_user()),
62                                         dbesc($match_nurl));
63                                 if (!count($match)) {
64                                         $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
65                                         $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
66                                         $o .= replace_macros($tpl,array(
67                                                 '$url' => zrl($jj->url),
68                                                 '$name' => $jj->name,
69                                                 '$photo' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
70                                                 '$inttxt' => ' ' . t('is interested in:'),
71                                                 '$conntxt' => t('Connect'),
72                                                 '$connlnk' => $connlnk,
73                                                 '$tags' => $jj->tags
74                                         ));
75                                 }
76                         }
77                 } else {
78                         info( t('No matches') . EOL);
79                 }
80
81         }
82
83         $o .= cleardiv();
84         $o .= paginate($a);
85         return $o;
86 }