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 $profile = $parameters['profile'];
25 } elseif (empty($parameters['action'])) {
26 // Show the profile hovercard
27 $nickname = $parameters['profile'];
30 throw new NotFoundException(DI::l10n()->t('No profile'));
33 Profile::load($a, $nickname, $profile);
37 if (!empty($a->profile['page-flags']) && ($a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
38 $page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
40 if (!empty($a->profile['openidserver'])) {
41 $page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
43 if (!empty($a->profile['openid'])) {
44 $delegate = ((strstr($a->profile['openid'], '://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
45 $page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
49 if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
50 $keywords = $a->profile['pub_keywords'] ?? '';
51 $keywords = str_replace([',', ' ', ',,'], [' ', ',', ','], $keywords);
52 if (strlen($keywords)) {
53 $page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
57 $baseUrl = DI::baseUrl();
59 $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : ''));
61 $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n";
62 $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl->get() . '/dfrn_poll/' . $nickname . '" />' . "\r\n";
63 $page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl->get() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
64 header('Link: <' . $baseUrl->get() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
66 foreach (['request', 'confirm', 'notify', 'poll'] as $dfrn) {
67 $page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl->get() . "/dfrn_{$dfrn}/{$nickname}\" />\r\n";