<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* @param boolean $disabled optional, default false
* @return string
*/
- public static function pollInterval($current, $disabled = false)
+ public static function pollInterval(string $current, bool $disabled = false): string
{
$dis = (($disabled) ? ' disabled="disabled" ' : '');
$o = '';
* @return string Server URL
* @throws \Exception
*/
- private static function getServerURLForProfile($profile)
+ private static function getServerURLForProfile(string $profile): string
{
if (!empty(self::$server_url[$profile])) {
return self::$server_url[$profile];
}
/**
+ * Determines network name
+ *
* @param string $network network of the contact
* @param string $profile optional, default empty
* @param string $protocol (Optional) Protocol that is used for the transmission
+ * @param int $gsid Server id
* @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function networkToName($network, $profile = '', $protocol = '')
+ public static function networkToName(string $network, string $profile = '', string $protocol = '', int $gsid = null): string
{
$nets = [
Protocol::DFRN => DI::l10n()->t('DFRN'),
$networkname = str_replace($search, $replace, $network);
if ((in_array($network, Protocol::FEDERATED)) && ($profile != "")) {
- $gserver = self::getServerForProfile($profile);
+ if (!empty($gsid) && !empty(self::$serverdata[$gsid])) {
+ $gserver = self::$serverdata[$gsid];
+ } elseif (!empty($gsid)) {
+ $gserver = DBA::selectFirst('gserver', ['platform', 'network'], ['id' => $gsid]);
+ self::$serverdata[$gsid] = $gserver;
+ } else {
+ $gserver = self::getServerForProfile($profile);
+ }
if (!empty($gserver['platform'])) {
$platform = $gserver['platform'];
}
/**
+ * Determines network's icon name
+ *
* @param string $network network
* @param string $profile optional, default empty
- * @return string
+ * @param int $gsid Server id
+ * @return string Name for network icon
* @throws \Exception
*/
- public static function networkToIcon($network, $profile = "")
+ public static function networkToIcon(string $network, string $profile = "", int $gsid = null): string
{
$nets = [
Protocol::DFRN => 'friendica',
$network_icon = str_replace($search, $replace, $network);
if ((in_array($network, Protocol::FEDERATED)) && ($profile != "")) {
- $gserver = self::getServerForProfile($profile);
+ if (!empty($gsid) && !empty(self::$serverdata[$gsid])) {
+ $gserver = self::$serverdata[$gsid];
+ } elseif (!empty($gsid)) {
+ $gserver = DBA::selectFirst('gserver', ['platform', 'network'], ['id' => $gsid]);
+ self::$serverdata[$gsid] = $gserver;
+ } else {
+ $gserver = self::getServerForProfile($profile);
+ }
if (!empty($gserver['platform'])) {
$network_icon = $platform_icons[strtolower($gserver['platform'])] ?? $network_icon;
}