3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Core\Session;
8 use Friendica\Model\Profile;
9 use Friendica\Model\User;
10 use Friendica\Network\HTTPException\NotFoundException;
13 * Loads a profile for the HoverCard view
15 class HoverCard extends BaseModule
17 public static function rawContent(array $parameters = [])
21 if ((local_user()) && ($parameters['action'] ?? '') === 'view') {
22 // A logged in user views a profile of a user
23 $nickname = $a->user['nickname'];
24 } elseif (empty($parameters['action'])) {
25 // Show the profile hovercard
26 $nickname = $parameters['profile'];
28 throw new NotFoundException(DI::l10n()->t('No profile'));
31 Profile::load($a, $nickname);
35 if (!empty($a->profile['page-flags']) && ($a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
36 $page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
38 if (!empty($a->profile['openidserver'])) {
39 $page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
41 if (!empty($a->profile['openid'])) {
42 $delegate = ((strstr($a->profile['openid'], '://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
43 $page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
47 if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
48 $keywords = $a->profile['pub_keywords'] ?? '';
49 $keywords = str_replace([',', ' ', ',,'], [' ', ',', ','], $keywords);
50 if (strlen($keywords)) {
51 $page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
55 $baseUrl = DI::baseUrl();
57 $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : ''));
59 $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n";
60 $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl->get() . '/dfrn_poll/' . $nickname . '" />' . "\r\n";
61 $page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl->get() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
62 header('Link: <' . $baseUrl->get() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
64 foreach (['request', 'confirm', 'notify', 'poll'] as $dfrn) {
65 $page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl->get() . "/dfrn_{$dfrn}/{$nickname}\" />\r\n";