]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Widget/VCard.php
Update copyright
[friendica.git] / src / Content / Widget / VCard.php
index 340fc0cf3a7ab0308d610ad0b0f3bfa4a762ad91..d230afd303109e181d0d8df48980ab13dc1af59a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
 
 namespace Friendica\Content\Widget;
 
+use Friendica\Content\ContactSelector;
 use Friendica\Content\Text\BBCode;
+use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Util\Strings;
@@ -43,10 +46,16 @@ class VCard
         */
        public static function getHTML(array $contact)
        {
-               if (($contact['network'] != '') && ($contact['network'] != Protocol::DFRN)) {
-                       $network_link = Strings::formatNetworkName($contact['network'], $contact['url']);
+               if (!isset($contact['network']) || !isset($contact['id'])) {
+                       Logger::warning('Incomplete contact', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);
+               }
+
+               if ($contact['network'] != '') {
+                       $network_link   = Strings::formatNetworkName($contact['network'], $contact['url']);
+                       $network_avatar = ContactSelector::networkToIcon($contact['network'], $contact['url']);
                } else {
-                       $network_link = '';
+                       $network_link   = '';
+                       $network_avatar = '';
                }
 
                $follow_link      = '';
@@ -66,7 +75,7 @@ class VCard
                                $pending = $pcontact['pending'] ?? false;
                        }
 
-                       if (in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
+                       if (empty($contact['self']) && Protocol::supportsFollow($contact['network'])) {
                                if (in_array($rel, [Contact::SHARING, Contact::FRIEND])) {
                                        $unfollow_link = 'unfollow?url=' . urlencode($contact['url']) . '&auto=1';
                                } elseif (!$pending) {
@@ -85,8 +94,10 @@ class VCard
                        '$url'              => Contact::magicLinkByContact($contact, $contact['url']),
                        '$about'            => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['about'] ?? ''),
                        '$xmpp'             => DI::l10n()->t('XMPP:'),
+                       '$matrix'           => DI::l10n()->t('Matrix:'),
                        '$location'         => DI::l10n()->t('Location:'),
                        '$network_link'     => $network_link,
+                       '$network_avatar'   => $network_avatar,
                        '$network'          => DI::l10n()->t('Network:'),
                        '$account_type'     => Contact::getAccountType($contact),
                        '$follow'           => DI::l10n()->t('Follow'),