4 use Friendica\Core\System;
6 require_once('include/text.php');
7 require_once('include/socgraph.php');
8 require_once('include/contact_widgets.php');
9 require_once('mod/proxy.php');
12 * @brief Controller for /match.
14 * It takes keywords from your profile and queries the directory server for
15 * matching keywords from other profiles.
20 function match_content(App $a) {
27 $a->page['aside'] .= findpeople_widget();
28 $a->page['aside'] .= follow_widget();
30 $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
32 $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
35 if (! dbm::is_result($r)) {
38 if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
39 notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
44 $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
48 if($a->pager['page'] != 1)
49 $params['p'] = $a->pager['page'];
51 if(strlen(get_config('system','directory')))
52 $x = post_url(get_server().'/msearch', $params);
54 $x = post_url(System::baseUrl() . '/msearch', $params);
59 $a->set_pager_total($j->total);
60 $a->set_pager_itemspage($j->items_page);
63 if(count($j->results)) {
67 foreach($j->results as $jj) {
68 $match_nurl = normalise_link($jj->url);
69 $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
74 $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
75 $connlnk = System::baseUrl() . '/follow/?url=' . $jj->url;
77 'profile' => array(t("View Profile"), zrl($jj->url)),
78 'follow' => array(t("Connect/Follow"), $connlnk)
81 $contact_details = get_contact_details_by_url($jj->url, local_user());
84 'url' => zrl($jj->url),
85 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url),
87 'details' => $contact_details['location'],
88 'tags' => $contact_details['keywords'],
89 'about' => $contact_details['about'],
90 'account_type' => account_type($contact_details),
91 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
92 'inttxt' => ' ' . t('is interested in:'),
93 'conntxt' => t('Connect'),
94 'connlnk' => $connlnk,
95 'img_hover' => $jj->tags,
96 'photo_menu' => $photo_menu,
103 $tpl = get_markup_template('viewcontact_template.tpl');
105 $o .= replace_macros($tpl,array(
106 '$title' => t('Profile Match'),
107 '$contacts' => $entries,
108 '$paginate' => paginate($a),
113 info( t('No matches') . EOL);