X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FContactSelector.php;h=9035d37e73c01d3c838e35c30bbc662e1507acc0;hb=30dcf3380c8c06b2b8b2583e38282857fec41b3c;hp=e327069b33fd86653bad93e0b9a661c1c3a1bcc3;hpb=854cc3e47296d4a1b01b893376064cf254d84f79;p=friendica.git diff --git a/src/Content/ContactSelector.php b/src/Content/ContactSelector.php index e327069b33..9035d37e73 100644 --- a/src/Content/ContactSelector.php +++ b/src/Content/ContactSelector.php @@ -1,52 +1,45 @@ . + * */ + namespace Friendica\Content; use Friendica\Core\Hook; -use Friendica\Core\L10n; use Friendica\Core\Protocol; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Util\Network; use Friendica\Util\Strings; /** - * @brief ContactSelector class + * ContactSelector class */ class ContactSelector { - /** - * @param string $current current - * @param string $foreign_net network - * @return string - * @throws \Exception - */ - public static function profileAssign($current, $foreign_net) - { - $o = ''; - - $disabled = (($foreign_net) ? ' disabled="true" ' : ''); - - $o .= "\r\n"; - return $o; - } + static $serverdata = []; + static $server_url = []; /** * @param string $current current * @param boolean $disabled optional, default false - * @return object + * @return string */ public static function pollInterval($current, $disabled = false) { @@ -55,12 +48,12 @@ class ContactSelector $o .= ""; - foreach ($select as $neutral => $selection) { - if ($selection !== 'NOTRANSLATION') { - $selected = (($neutral == $current) ? ' selected="selected" ' : ''); - $o .= ""; + if ((in_array($network, Protocol::FEDERATED)) && ($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); } - } - $o .= ''; - return $o; - } - /** - * @param string $current optional, default empty - * @param string $suffix optionsl, default empty - * @return string - * @throws \Friendica\Network\HTTPException\InternalServerErrorException - */ - public static function sexualPreference($current = "", $suffix = "") - { - $o = ''; - $select = [ - '' => L10n::t('No answer'), - 'Males' => L10n::t('Males'), - 'Females' => L10n::t('Females'), - 'Gay' => L10n::t('Gay'), - 'Lesbian' => L10n::t('Lesbian'), - 'No Preference' => L10n::t('No Preference'), - 'Bisexual' => L10n::t('Bisexual'), - 'Autosexual' => L10n::t('Autosexual'), - 'Abstinent' => L10n::t('Abstinent'), - 'Virgin' => L10n::t('Virgin'), - 'Deviant' => L10n::t('Deviant'), - 'Fetish' => L10n::t('Fetish'), - 'Oodles' => L10n::t('Oodles'), - 'Nonsexual' => L10n::t('Nonsexual'), - ]; + if (!empty($gserver['platform'])) { + $platform = $gserver['platform']; + } elseif (!empty($gserver['network']) && ($gserver['network'] != Protocol::ACTIVITYPUB)) { + $platform = self::networkToName($gserver['network']); + } - Hook::callAll('sexpref_selector', $select); + if (!empty($platform)) { + $networkname = $platform; - $o .= "'; - return $o; + + if (!empty($protocol) && ($protocol != $network)) { + $networkname = DI::l10n()->t('%s (via %s)', $networkname, self::networkToName($protocol)); + } + + return $networkname; } /** - * @param string $current optional, default empty + * @param string $network network + * @param string $profile optional, default empty * @return string - * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * @throws \Exception */ - public static function maritalStatus($current = "") + public static function networkToIcon($network, $profile = "") { - $o = ''; - $select = [ - '' => L10n::t('No answer'), - 'Single' => L10n::t('Single'), - 'Lonely' => L10n::t('Lonely'), - 'Available' => L10n::t('Available'), - 'Unavailable' => L10n::t('Unavailable'), - 'Has crush' => L10n::t('Has crush'), - 'Infatuated' => L10n::t('Infatuated'), - 'Dating' => L10n::t('Dating'), - 'Unfaithful' => L10n::t('Unfaithful'), - 'Sex Addict' => L10n::t('Sex Addict'), - 'Friends' => L10n::t('Friends'), - 'Friends/Benefits' => L10n::t('Friends/Benefits'), - 'Casual' => L10n::t('Casual'), - 'Engaged' => L10n::t('Engaged'), - 'Married' => L10n::t('Married'), - 'Imaginarily married' => L10n::t('Imaginarily married'), - 'Partners' => L10n::t('Partners'), - 'Cohabiting' => L10n::t('Cohabiting'), - 'Common law' => L10n::t('Common law'), - 'Happy' => L10n::t('Happy'), - 'Not looking' => L10n::t('Not looking'), - 'Swinger' => L10n::t('Swinger'), - 'Betrayed' => L10n::t('Betrayed'), - 'Separated' => L10n::t('Separated'), - 'Unstable' => L10n::t('Unstable'), - 'Divorced' => L10n::t('Divorced'), - 'Imaginarily divorced' => L10n::t('Imaginarily divorced'), - 'Widowed' => L10n::t('Widowed'), - 'Uncertain' => L10n::t('Uncertain'), - 'It\'s complicated' => L10n::t('It\'s complicated'), - 'Don\'t care' => L10n::t('Don\'t care'), - 'Ask me' => L10n::t('Ask me'), + $nets = [ + Protocol::DFRN => 'friendica', + Protocol::OSTATUS => 'gnu-social', // There is no generic OStatus icon + Protocol::FEED => 'rss', + Protocol::MAIL => 'inbox', + Protocol::DIASPORA => 'diaspora', + Protocol::ZOT => 'hubzilla', + Protocol::LINKEDIN => 'linkedin', + Protocol::XMPP => 'xmpp', + Protocol::MYSPACE => 'file-text-o', /// @todo + Protocol::GPLUS => 'google-plus', + 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 => 'file-text-o', /// @todo ]; - Hook::callAll('marital_selector', $select); + $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); + + $network_icon = str_replace($search, $replace, $network); - $o .= ''; - return $o; + + return $network_icon; } }