6 use Friendica\Content\Widget;
7 use Friendica\Core\Config;
8 use Friendica\Core\L10n;
9 use Friendica\Core\System;
10 use Friendica\Database\DBM;
11 use Friendica\Model\Contact;
12 use Friendica\Model\Profile;
13 use Friendica\Util\Network;
15 require_once 'include/text.php';
16 require_once 'mod/proxy.php';
19 * @brief Controller for /match.
21 * It takes keywords from your profile and queries the directory server for
22 * matching keywords from other profiles.
28 function match_content(App $a)
35 $a->page['aside'] .= Widget::findPeople();
36 $a->page['aside'] .= Widget::follow();
38 $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
41 "SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
44 if (! DBM::is_result($r)) {
47 if (! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
48 notice(L10n::t('No keywords to match. Please add keywords to your default profile.') . EOL);
53 $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
57 if ($a->pager['page'] != 1) {
58 $params['p'] = $a->pager['page'];
61 if (strlen(Config::get('system', 'directory'))) {
62 $x = Network::post(get_server().'/msearch', $params);
64 $x = Network::post(System::baseUrl() . '/msearch', $params);
70 $a->set_pager_total($j->total);
71 $a->set_pager_itemspage($j->items_page);
74 if (count($j->results)) {
77 foreach ($j->results as $jj) {
78 $match_nurl = normalise_link($jj->url);
80 "SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
86 $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
87 $connlnk = System::baseUrl() . '/follow/?url=' . $jj->url;
89 'profile' => [L10n::t("View Profile"), Profile::zrl($jj->url)],
90 'follow' => [L10n::t("Connect/Follow"), $connlnk]
93 $contact_details = Contact::getDetailsByURL($jj->url, local_user());
96 'url' => Profile::zrl($jj->url),
97 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url),
99 'details' => $contact_details['location'],
100 'tags' => $contact_details['keywords'],
101 'about' => $contact_details['about'],
102 'account_type' => Contact::getAccountType($contact_details),
103 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
104 'inttxt' => ' ' . L10n::t('is interested in:'),
105 'conntxt' => L10n::t('Connect'),
106 'connlnk' => $connlnk,
107 'img_hover' => $jj->tags,
108 'photo_menu' => $photo_menu,
115 $tpl = get_markup_template('viewcontact_template.tpl');
117 $o .= replace_macros(
120 '$title' => L10n::t('Profile Match'),
121 '$contacts' => $entries,
122 '$paginate' => paginate($a)]
125 info(L10n::t('No matches') . EOL);