3 namespace Friendica\Module;
5 use Friendica\App\Arguments;
6 use Friendica\App\BaseURL;
7 use Friendica\App\Page;
8 use Friendica\BaseModule;
9 use Friendica\Core\Config\Configuration;
10 use Friendica\Core\L10n\L10n;
11 use Friendica\Core\Session;
12 use Friendica\Model\Profile;
13 use Friendica\Model\User;
14 use Friendica\Network\HTTPException\NotFoundException;
17 * Loads a profile for the HoverCard view
19 class HoverCard extends BaseModule
21 public static function rawContent(array $parameters = [])
25 if ((local_user()) && ($parameters['action'] ?? '') === 'view') {
26 // A logged in user views a profile of a user
27 $nickname = $a->user['nickname'];
28 $profile = $parameters['profile'];
29 } elseif (empty($parameters['action'])) {
30 // Show the profile hovercard
31 $nickname = $parameters['profile'];
34 /** @var L10n $l10n */
35 $l10n = self::getClass(L10n::class);
36 throw new NotFoundException($l10n->t('No profile'));
39 Profile::load($a, $nickname, $profile);
41 /** @var Page $page */
42 $page = self::getClass(Page::class);
44 if (!empty($a->profile['page-flags']) && ($a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
45 $page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
47 if (!empty($a->profile['openidserver'])) {
48 $page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
50 if (!empty($a->profile['openid'])) {
51 $delegate = ((strstr($a->profile['openid'], '://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
52 $page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
55 /** @var Configuration $config */
56 $config = self::getClass(Configuration::class);
58 if ($config->get('system', 'block_public') && !Session::isAuthenticated()) {
59 $keywords = $a->profile['pub_keywords'] ?? '';
60 $keywords = str_replace([',', ' ', ',,'], [' ', ',', ','], $keywords);
61 if (strlen($keywords)) {
62 $page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
66 /** @var BaseURL $baseUrl */
67 $baseUrl = self::getClass(BaseURL::class);
69 $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : ''));
71 $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n";
72 $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl->get() . '/dfrn_poll/' . $nickname . '" />' . "\r\n";
73 $page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl->get() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
74 header('Link: <' . $baseUrl->get() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
76 foreach (['request', 'confirm', 'notify', 'poll'] as $dfrn) {
77 $page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl->get() . "/dfrn_{$dfrn}/{$nickname}\" />\r\n";