6 use Friendica\Core\Config;
7 use Friendica\Core\System;
8 use Friendica\Database\DBM;
9 use Friendica\Object\Contact;
11 require_once 'include/text.php';
12 require_once 'include/contact_widgets.php';
13 require_once 'mod/proxy.php';
16 * @brief Controller for /match.
18 * It takes keywords from your profile and queries the directory server for
19 * matching keywords from other profiles.
25 function match_content(App $a)
32 $a->page['aside'] .= findpeople_widget();
33 $a->page['aside'] .= follow_widget();
35 $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
38 "SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
41 if (! DBM::is_result($r)) {
44 if (! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
45 notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
50 $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
54 if ($a->pager['page'] != 1) {
55 $params['p'] = $a->pager['page'];
58 if (strlen(Config::get('system', 'directory'))) {
59 $x = post_url(get_server().'/msearch', $params);
61 $x = post_url(System::baseUrl() . '/msearch', $params);
67 $a->set_pager_total($j->total);
68 $a->set_pager_itemspage($j->items_page);
71 if (count($j->results)) {
74 foreach ($j->results as $jj) {
75 $match_nurl = normalise_link($jj->url);
77 "SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
83 $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
84 $connlnk = System::baseUrl() . '/follow/?url=' . $jj->url;
86 'profile' => array(t("View Profile"), zrl($jj->url)),
87 'follow' => array(t("Connect/Follow"), $connlnk)
90 $contact_details = Contact::getDetailsByURL($jj->url, local_user());
93 'url' => zrl($jj->url),
94 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url),
96 'details' => $contact_details['location'],
97 'tags' => $contact_details['keywords'],
98 'about' => $contact_details['about'],
99 'account_type' => Contact::getAccountType($contact_details),
100 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
101 'inttxt' => ' ' . t('is interested in:'),
102 'conntxt' => t('Connect'),
103 'connlnk' => $connlnk,
104 'img_hover' => $jj->tags,
105 'photo_menu' => $photo_menu,
112 $tpl = get_markup_template('viewcontact_template.tpl');
114 $o .= replace_macros(
117 '$title' => t('Profile Match'),
118 '$contacts' => $entries,
119 '$paginate' => paginate($a))
122 info(t('No matches') . EOL);