4 use Friendica\Core\Config;
5 use Friendica\Core\System;
7 require_once('include/text.php');
8 require_once('include/socgraph.php');
9 require_once('include/contact_widgets.php');
10 require_once('mod/proxy.php');
13 * @brief Controller for /match.
15 * It takes keywords from your profile and queries the directory server for
16 * matching keywords from other profiles.
21 function match_content(App $a) {
28 $a->page['aside'] .= findpeople_widget();
29 $a->page['aside'] .= follow_widget();
31 $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
33 $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
36 if (! dbm::is_result($r)) {
39 if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
40 notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
45 $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
49 if($a->pager['page'] != 1)
50 $params['p'] = $a->pager['page'];
52 if(strlen(Config::get('system','directory')))
53 $x = post_url(get_server().'/msearch', $params);
55 $x = post_url(System::baseUrl() . '/msearch', $params);
60 $a->set_pager_total($j->total);
61 $a->set_pager_itemspage($j->items_page);
64 if(count($j->results)) {
68 foreach($j->results as $jj) {
69 $match_nurl = normalise_link($jj->url);
70 $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
75 $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
76 $connlnk = System::baseUrl() . '/follow/?url=' . $jj->url;
78 'profile' => array(t("View Profile"), zrl($jj->url)),
79 'follow' => array(t("Connect/Follow"), $connlnk)
82 $contact_details = get_contact_details_by_url($jj->url, local_user());
85 'url' => zrl($jj->url),
86 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url),
88 'details' => $contact_details['location'],
89 'tags' => $contact_details['keywords'],
90 'about' => $contact_details['about'],
91 'account_type' => account_type($contact_details),
92 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
93 'inttxt' => ' ' . t('is interested in:'),
94 'conntxt' => t('Connect'),
95 'connlnk' => $connlnk,
96 'img_hover' => $jj->tags,
97 'photo_menu' => $photo_menu,
104 $tpl = get_markup_template('viewcontact_template.tpl');
106 $o .= replace_macros($tpl,array(
107 '$title' => t('Profile Match'),
108 '$contacts' => $entries,
109 '$paginate' => paginate($a),
114 info( t('No matches') . EOL);