6 use Friendica\Content\Widget;
7 use Friendica\Core\Config;
8 use Friendica\Core\System;
9 use Friendica\Database\DBM;
10 use Friendica\Model\Contact;
11 use Friendica\Model\Profile;
13 require_once 'include/text.php';
14 require_once 'mod/proxy.php';
17 * @brief Controller for /match.
19 * It takes keywords from your profile and queries the directory server for
20 * matching keywords from other profiles.
26 function match_content(App $a)
33 $a->page['aside'] .= Widget::findPeople();
34 $a->page['aside'] .= Widget::follow();
36 $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
39 "SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
42 if (! DBM::is_result($r)) {
45 if (! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
46 notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
51 $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
55 if ($a->pager['page'] != 1) {
56 $params['p'] = $a->pager['page'];
59 if (strlen(Config::get('system', 'directory'))) {
60 $x = post_url(get_server().'/msearch', $params);
62 $x = post_url(System::baseUrl() . '/msearch', $params);
68 $a->set_pager_total($j->total);
69 $a->set_pager_itemspage($j->items_page);
72 if (count($j->results)) {
75 foreach ($j->results as $jj) {
76 $match_nurl = normalise_link($jj->url);
78 "SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
84 $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
85 $connlnk = System::baseUrl() . '/follow/?url=' . $jj->url;
87 'profile' => [t("View Profile"), Profile::zrl($jj->url)],
88 'follow' => [t("Connect/Follow"), $connlnk]
91 $contact_details = Contact::getDetailsByURL($jj->url, local_user());
94 'url' => Profile::zrl($jj->url),
95 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url),
97 'details' => $contact_details['location'],
98 'tags' => $contact_details['keywords'],
99 'about' => $contact_details['about'],
100 'account_type' => Contact::getAccountType($contact_details),
101 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
102 'inttxt' => ' ' . t('is interested in:'),
103 'conntxt' => t('Connect'),
104 'connlnk' => $connlnk,
105 'img_hover' => $jj->tags,
106 'photo_menu' => $photo_menu,
113 $tpl = get_markup_template('viewcontact_template.tpl');
115 $o .= replace_macros(
118 '$title' => t('Profile Match'),
119 '$contacts' => $entries,
120 '$paginate' => paginate($a)]
123 info(t('No matches') . EOL);