]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/ContactSelector.php
Stop scrollToItem() animate twice.
[friendica.git] / src / Content / ContactSelector.php
index 2f6677aba1cfc13b564139ac2d67f48748c1dd5e..7a36ea8c681be56a7ad77e9755402e2d96f76fce 100644 (file)
@@ -81,7 +81,7 @@ class ContactSelector
                $server_url = '';
 
                // Fetch the server url from the contact table
-               $contact = DBA::selectFirst('contact', ['baseurl'], ['nurl' => Strings::normaliseLink($profile)]);
+               $contact = DBA::selectFirst('contact', ['baseurl'], ['uid' => 0, 'nurl' => Strings::normaliseLink($profile)]);
                if (DBA::isResult($contact) && !empty($contact['baseurl'])) {
                        $server_url = Strings::normaliseLink($contact['baseurl']);
                }
@@ -105,12 +105,13 @@ class ContactSelector
        }
 
        /**
-        * @param string $network network
-        * @param string $profile optional, default empty
+        * @param string $network  network of the contact
+        * @param string $profile  optional, default empty
+        * @param string $protocol (Optional) Protocol that is used for the transmission
         * @return string
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function networkToName($network, $profile = "")
+       public static function networkToName($network, $profile = '', $protocol = '')
        {
                $nets = [
                        Protocol::DFRN      =>   L10n::t('DFRN'),
@@ -125,6 +126,7 @@ class ContactSelector
                        Protocol::GPLUS     =>   L10n::t('Google+'),
                        Protocol::PUMPIO    =>   L10n::t('pump.io'),
                        Protocol::TWITTER   =>   L10n::t('Twitter'),
+                       Protocol::DISCOURSE =>   L10n::t('Discourse'),
                        Protocol::DIASPORA2 =>   L10n::t('Diaspora Connector'),
                        Protocol::STATUSNET =>   L10n::t('GNU Social Connector'),
                        Protocol::ACTIVITYPUB => L10n::t('ActivityPub'),
@@ -161,6 +163,10 @@ class ContactSelector
                        }
                }
 
+               if (!empty($protocol) && ($protocol != $network)) {
+                       $networkname = L10n::t('%s (via %s)', $networkname, self::networkToName($protocol));
+               }
+
                return $networkname;
        }
 
@@ -174,27 +180,34 @@ class ContactSelector
        {
                $nets = [
                        Protocol::DFRN      =>   'friendica',
-                       Protocol::OSTATUS   =>   'gnu-social',
+                       Protocol::OSTATUS   =>   'gnu-social', // There is no generic OStatus icon
                        Protocol::FEED      =>   'rss',
-                       Protocol::MAIL      =>   '',
+                       Protocol::MAIL      =>   'file-text-o', /// @todo
                        Protocol::DIASPORA  =>   'diaspora',
                        Protocol::ZOT       =>   'hubzilla',
                        Protocol::LINKEDIN  =>   'linkedin',
                        Protocol::XMPP      =>   'xmpp',
-                       Protocol::MYSPACE   =>   '',
+                       Protocol::MYSPACE   =>   'file-text-o', /// @todo
                        Protocol::GPLUS     =>   'google-plus',
-                       Protocol::PUMPIO    =>   '',
+                       Protocol::PUMPIO    =>   'file-text-o', /// @todo
                        Protocol::TWITTER   =>   'twitter',
+                       Protocol::DISCOURSE =>   'dot-circle-o', /// @todo
                        Protocol::DIASPORA2 =>   'diaspora',
                        Protocol::STATUSNET =>   'gnu-social',
                        Protocol::ACTIVITYPUB => 'activitypub',
-                       Protocol::PNUT      =>   '',
+                       Protocol::PNUT      =>   'file-text-o', /// @todo
                ];
 
+               $platform_icons = ['diaspora' => 'diaspora', 'friendica' => 'friendica', 'friendika' => 'friendica',
+                       'GNU Social' => 'gnu-social', 'gnusocial' => 'gnu-social', 'hubzilla' => 'hubzilla',
+                       'mastodon' => 'mastodon', 'peertube' => 'peertube', 'pixelfed' => 'pixelfed',
+                       'pleroma' => 'pleroma', 'red' => 'hubzilla', 'redmatrix' => 'hubzilla',
+                       'socialhome' => 'social-home', 'wordpress' => 'wordpress'];
+
                $search  = array_keys($nets);
                $replace = array_values($nets);
 
-               $networkicon = str_replace($search, $replace, $network);
+               $network_icon = str_replace($search, $replace, $network);
 
                if ((in_array($network, Protocol::FEDERATED)) && ($profile != "")) {
                        $server_url = self::getServerURLForProfile($profile);
@@ -203,28 +216,11 @@ class ContactSelector
                        $gserver = DBA::selectFirst('gserver', ['platform'], ['nurl' => $server_url]);
 
                        if (DBA::isResult($gserver) && !empty($gserver['platform'])) {
-                               switch (strtolower($gserver['platform'])) {
-                                       case 'friendica':
-                                               $networkicon = 'friendica';
-                                               break;
-                                       case 'hubzilla':
-                                               $networkicon = 'hubzilla';
-                                               break;
-                                       case 'mastodon':
-                                               $networkicon = 'mastodon';
-                                               break;
-                                       case 'pleroma':
-                                               $networkicon = 'pleroma';
-                                               break;
-                               }
+                               $network_icon = $platform_icons[strtolower($gserver['platform'])] ?? $network_icon;
                        }
                }
 
-               if (empty($networkicon)) {
-                       $networkicon = 'file-text-o';
-               }
-
-               return $networkicon;
+               return $network_icon;
        }
 
        /**