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 = [])
23 /** @var Arguments $args */
24 $args = self::getClass(Arguments::class);
28 // A logged in user views a profile of a user
29 if ((local_user()) && $args->get(2) === 'view') {
30 $nickname = $a->user['nickname'];
31 $profile = $parameters['profile'];
33 // Show the profile hovercard
34 } elseif ($args->getArgc() == 2) {
35 $nickname = $parameters['profile'];
39 /** @var L10n $l10n */
40 $l10n = self::getClass(L10n::class);
41 throw new NotFoundException($l10n->t('No profile'));
44 Profile::load($a, $nickname, $profile);
46 /** @var Page $page */
47 $page = self::getClass(Page::class);
49 if (!empty($a->profile['page-flags']) && ($a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
50 $page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
52 if (!empty($a->profile['openidserver'])) {
53 $page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
55 if (!empty($a->profile['openid'])) {
56 $delegate = ((strstr($a->profile['openid'], '://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
57 $page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
60 /** @var Configuration $config */
61 $config = self::getClass(Configuration::class);
63 if ($config->get('system', 'block_public') && !Session::isAuthenticated()) {
64 $keywords = $a->profile['pub_keywords'] ?? '';
65 $keywords = str_replace([',', ' ', ',,'], [' ', ',', ','], $keywords);
66 if (strlen($keywords)) {
67 $page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
71 /** @var BaseURL $baseUrl */
72 $baseUrl = self::getClass(BaseURL::class);
74 $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : ''));
76 $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n";
77 $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl->get() . '/dfrn_poll/' . $nickname . '" />' . "\r\n";
78 $page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl->get() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
79 header('Link: <' . $baseUrl->get() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
81 foreach (['request', 'confirm', 'notify', 'poll'] as $dfrn) {
82 $page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl->get() . "/dfrn_{$dfrn}/{$nickname}\" />\r\n";