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;
13 use Friendica\Model\Profile;
14 use Friendica\Model\User;
15 use Friendica\Network\HTTPException\NotFoundException;
18 * Loads a profile for the HoverCard view
20 class HoverCard extends BaseModule
22 public static function rawContent(array $parameters = [])
26 if ((local_user()) && ($parameters['action'] ?? '') === 'view') {
27 // A logged in user views a profile of a user
28 $nickname = $a->user['nickname'];
29 $profile = $parameters['profile'];
30 } elseif (empty($parameters['action'])) {
31 // Show the profile hovercard
32 $nickname = $parameters['profile'];
35 throw new NotFoundException(DI::l10n()->t('No profile'));
38 Profile::load($a, $nickname, $profile);
42 if (!empty($a->profile['page-flags']) && ($a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
43 $page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
45 if (!empty($a->profile['openidserver'])) {
46 $page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
48 if (!empty($a->profile['openid'])) {
49 $delegate = ((strstr($a->profile['openid'], '://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
50 $page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
54 if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
55 $keywords = $a->profile['pub_keywords'] ?? '';
56 $keywords = str_replace([',', ' ', ',,'], [' ', ',', ','], $keywords);
57 if (strlen($keywords)) {
58 $page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
62 $baseUrl = DI::baseUrl();
64 $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : ''));
66 $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n";
67 $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl->get() . '/dfrn_poll/' . $nickname . '" />' . "\r\n";
68 $page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl->get() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
69 header('Link: <' . $baseUrl->get() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
71 foreach (['request', 'confirm', 'notify', 'poll'] as $dfrn) {
72 $page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl->get() . "/dfrn_{$dfrn}/{$nickname}\" />\r\n";