diff --git a/include/api.php b/include/api.php index 77dfb7462b..20b3844cd5 100644 --- a/include/api.php +++ b/include/api.php @@ -643,8 +643,6 @@ function api_get_user(App $a, $contact_id = null) $contact = DBA::selectFirst('contact', [], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]); if (DBA::isResult($contact)) { - $network_name = ContactSelector::networkToName($contact['network'], $contact['url']); - // If no nick where given, extract it from the address if (($contact['nick'] == "") || ($contact['name'] == $contact['nick'])) { $contact['nick'] = api_get_nick($contact["url"]); @@ -655,7 +653,7 @@ function api_get_user(App $a, $contact_id = null) 'id_str' => (string) $contact["id"], 'name' => $contact["name"], 'screen_name' => (($contact['nick']) ? $contact['nick'] : $contact['name']), - 'location' => ($contact["location"] != "") ? $contact["location"] : $network_name, + 'location' => ($contact["location"] != "") ? $contact["location"] : ContactSelector::networkToName($contact['network'], $contact['url']), 'description' => $contact["about"], 'profile_image_url' => $contact["micro"], 'profile_image_url_https' => $contact["micro"], @@ -713,8 +711,6 @@ function api_get_user(App $a, $contact_id = null) $uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]); } - $network_name = ContactSelector::networkToName($uinfo[0]['network'], $uinfo[0]['url']); - $pcontact_id = Contact::getIdForURL($uinfo[0]['url'], 0, true); if (!empty($profile['about'])) { @@ -728,7 +724,7 @@ function api_get_user(App $a, $contact_id = null) } elseif (!empty($uinfo[0]["location"])) { $location = $uinfo[0]["location"]; } else { - $location = $network_name; + $location = ContactSelector::networkToName($uinfo[0]['network'], $uinfo[0]['url']); } $ret = [ diff --git a/mod/hovercard.php b/mod/hovercard.php index 6160642762..101ebd5af2 100644 --- a/mod/hovercard.php +++ b/mod/hovercard.php @@ -96,20 +96,20 @@ function hovercard_content() // Move the contact data to the profile array so we can deliver it to $profile = [ - 'name' => $contact['name'], - 'nick' => $contact['nick'], - 'addr' => defaults($contact, 'addr', $contact['url']), - 'thumb' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB), - 'url' => Contact::magicLink($contact['url']), - 'nurl' => $contact['nurl'], // We additionally store the nurl as identifier - 'location' => $contact['location'], - 'gender' => $contact['gender'], - 'about' => $contact['about'], - 'network' => Strings::formatNetworkName($contact['network'], $contact['url']), - 'tags' => $contact['keywords'], - 'bd' => $contact['birthday'] <= DBA::NULL_DATE ? '' : $contact['birthday'], + 'name' => $contact['name'], + 'nick' => $contact['nick'], + 'addr' => defaults($contact, 'addr', $contact['url']), + 'thumb' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB), + 'url' => Contact::magicLink($contact['url']), + 'nurl' => $contact['nurl'], // We additionally store the nurl as identifier + 'location' => $contact['location'], + 'gender' => $contact['gender'], + 'about' => $contact['about'], + 'network_link' => Strings::formatNetworkName($contact['network'], $contact['url']), + 'tags' => $contact['keywords'], + 'bd' => $contact['birthday'] <= DBA::NULL_DATE ? '' : $contact['birthday'], 'account_type' => Contact::getAccountType($contact), - 'actions' => $actions, + 'actions' => $actions, ]; if ($datatype == 'html') { $tpl = Renderer::getMarkupTemplate('hovercard.tpl'); diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 887e35b721..132f9f3344 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -297,9 +297,9 @@ class Profile $profile['picdate'] = urlencode(defaults($profile, 'picdate', '')); if (($profile['network'] != '') && ($profile['network'] != Protocol::DFRN)) { - $profile['network_name'] = Strings::formatNetworkName($profile['network'], $profile['url']); + $profile['network_link'] = Strings::formatNetworkName($profile['network'], $profile['url']); } else { - $profile['network_name'] = ''; + $profile['network_link'] = ''; } Addon::callHooks('profile_sidebar_enter', $profile); diff --git a/src/Module/Contact.php b/src/Module/Contact.php index c030f60f46..410f5878bb 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -75,18 +75,17 @@ class Contact extends BaseModule $a->data['contact'] = $contact; if (($contact['network'] != '') && ($contact['network'] != Protocol::DFRN)) { - $networkname = Strings::formatNetworkName($contact['network'], $contact['url']); + $network_link = Strings::formatNetworkName($contact['network'], $contact['url']); } else { - $networkname = ''; + $network_link = ''; } - /// @TODO Add nice spaces $vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('vcard-widget.tpl'), [ '$name' => $contact['name'], '$photo' => $contact['photo'], '$url' => Model\Contact::MagicLink($contact['url']), '$addr' => defaults($contact, 'addr', ''), - '$network_name' => $networkname, + '$network_link' => $network_link, '$network' => L10n::t('Network:'), '$account_type' => Model\Contact::getAccountType($contact) ]); diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 48e580d678..473774b71d 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -140,18 +140,18 @@ class Strings } /** - * @brief translate and format the networkname of a contact + * @brief Translate and format the network name of a contact * - * @param string $network Networkname of the contact (e.g. dfrn, rss and so on) - * @param string $url The contact url + * @param string $network Network name of the contact (e.g. dfrn, rss and so on) + * @param string $url The contact url * - * @return string Formatted network name + * @return string Formatted network name */ - public static function formatNetworkName($network, $url = 0) + public static function formatNetworkName($network, $url = '') { - if ($network != "") { - if ($url != "") { - $network_name = '' . ContactSelector::networkToName($network, $url) . ""; + if ($network != '') { + if ($url != '') { + $network_name = '' . ContactSelector::networkToName($network, $url) . ''; } else { $network_name = ContactSelector::networkToName($network); } @@ -161,7 +161,7 @@ class Strings } /** - * @brief Remove intentation from a text + * @brief Remove indentation from a text * * @param string $text String to be transformed. * @param string $chr Optional. Indentation tag. Default tab (\t). diff --git a/view/templates/hovercard.tpl b/view/templates/hovercard.tpl index 0c259c440e..a688f57b20 100644 --- a/view/templates/hovercard.tpl +++ b/view/templates/hovercard.tpl @@ -12,7 +12,7 @@
{{$profile.addr}} - {{if $profile.network}} ({{$profile.network}}){{/if}} + {{if $profile.network_link}}({{$profile.network_link nofilter}}){{/if}}
{{*{{if $profile.about}}
{{$profile.about nofilter}}
{{/if}}*}} diff --git a/view/templates/profile_vcard.tpl b/view/templates/profile_vcard.tpl index f10a21ca6c..124fca154f 100644 --- a/view/templates/profile_vcard.tpl +++ b/view/templates/profile_vcard.tpl @@ -13,7 +13,7 @@
{{$profile.name}}
{{/if}} {{if $account_type}}
{{$account_type}}
{{/if}} - {{if $profile.network_name}}
{{$network}}
{{$profile.network_name nofilter}}
{{/if}} + {{if $profile.network_link}}
{{$network}}
{{$profile.network_link nofilter}}
{{/if}} {{if $location}}
{{$location}}
diff --git a/view/templates/vcard-widget.tpl b/view/templates/vcard-widget.tpl index 47b64b68da..240466460e 100644 --- a/view/templates/vcard-widget.tpl +++ b/view/templates/vcard-widget.tpl @@ -9,6 +9,6 @@
{{$name}}
{{/if}} {{if $account_type}}{{/if}} - {{if $network_name}}
{{$network}}
{{$network_name}}
{{/if}} + {{if $network_link}}
{{$network}}
{{$network_link nofilter}}
{{/if}}
diff --git a/view/theme/duepuntozero/templates/profile_vcard.tpl b/view/theme/duepuntozero/templates/profile_vcard.tpl index 5027507943..a7d0a0bc5a 100644 --- a/view/theme/duepuntozero/templates/profile_vcard.tpl +++ b/view/theme/duepuntozero/templates/profile_vcard.tpl @@ -10,7 +10,7 @@ {{if $account_type}}{{/if}} - {{if $profile.network_name}}
{{$network}}
{{$profile.network_name nofilter}}
{{/if}} + {{if $profile.network_link}}
{{$network}}
{{$profile.network_link nofilter}}
{{/if}} {{if $location}}
{{$location}}
diff --git a/view/theme/frio/templates/vcard-widget.tpl b/view/theme/frio/templates/vcard-widget.tpl index f65db725b2..0eae2841bd 100644 --- a/view/theme/frio/templates/vcard-widget.tpl +++ b/view/theme/frio/templates/vcard-widget.tpl @@ -32,7 +32,7 @@ {{if $account_type}}{{/if}} - {{if $network_name}}
{{$network}}
{{$network_name nofilter}}
{{/if}} + {{if $network_link}}
{{$network}}
{{$network_link nofilter}}
{{/if}} diff --git a/view/theme/quattro/templates/profile_vcard.tpl b/view/theme/quattro/templates/profile_vcard.tpl index 6e81bd90cf..68028fe91e 100644 --- a/view/theme/quattro/templates/profile_vcard.tpl +++ b/view/theme/quattro/templates/profile_vcard.tpl @@ -33,7 +33,7 @@ {{if $account_type}}{{/if}} - {{if $profile.network_name}}
{{$network}}
{{$profile.network_name nofilter}}
{{/if}} + {{if $profile.network_link}}
{{$network}}
{{$profile.network_link nofilter}}
{{/if}} {{if $location}}
{{$location}}
diff --git a/view/theme/vier/templates/profile_vcard.tpl b/view/theme/vier/templates/profile_vcard.tpl index 2acca2fd09..b37f5d2591 100644 --- a/view/theme/vier/templates/profile_vcard.tpl +++ b/view/theme/vier/templates/profile_vcard.tpl @@ -24,7 +24,7 @@ {{/if}} {{if $account_type}}{{/if}} - {{if $profile.network_name}}
{{$network}}
{{$profile.network_name nofilter}}
{{/if}} + {{if $profile.network_link}}
{{$network}}
{{$profile.network_link nofilter}}
{{/if}} {{if $location}}
{{$location}}