1
0
Fork 0

Merge pull request #6331 from MrPetovan/bug/6328-unescape-vcard-network-link

Unescape vcard network link
This commit is contained in:
Michael Vogel 2018-12-26 23:35:40 +01:00 committed by GitHub
commit 86f4cc90a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 36 additions and 41 deletions

View file

@ -643,8 +643,6 @@ function api_get_user(App $a, $contact_id = null)
$contact = DBA::selectFirst('contact', [], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]); $contact = DBA::selectFirst('contact', [], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]);
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {
$network_name = ContactSelector::networkToName($contact['network'], $contact['url']);
// If no nick where given, extract it from the address // If no nick where given, extract it from the address
if (($contact['nick'] == "") || ($contact['name'] == $contact['nick'])) { if (($contact['nick'] == "") || ($contact['name'] == $contact['nick'])) {
$contact['nick'] = api_get_nick($contact["url"]); $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"], 'id_str' => (string) $contact["id"],
'name' => $contact["name"], 'name' => $contact["name"],
'screen_name' => (($contact['nick']) ? $contact['nick'] : $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"], 'description' => $contact["about"],
'profile_image_url' => $contact["micro"], 'profile_image_url' => $contact["micro"],
'profile_image_url_https' => $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"]); $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); $pcontact_id = Contact::getIdForURL($uinfo[0]['url'], 0, true);
if (!empty($profile['about'])) { if (!empty($profile['about'])) {
@ -728,7 +724,7 @@ function api_get_user(App $a, $contact_id = null)
} elseif (!empty($uinfo[0]["location"])) { } elseif (!empty($uinfo[0]["location"])) {
$location = $uinfo[0]["location"]; $location = $uinfo[0]["location"];
} else { } else {
$location = $network_name; $location = ContactSelector::networkToName($uinfo[0]['network'], $uinfo[0]['url']);
} }
$ret = [ $ret = [

View file

@ -105,7 +105,7 @@ function hovercard_content()
'location' => $contact['location'], 'location' => $contact['location'],
'gender' => $contact['gender'], 'gender' => $contact['gender'],
'about' => $contact['about'], 'about' => $contact['about'],
'network' => Strings::formatNetworkName($contact['network'], $contact['url']), 'network_link' => Strings::formatNetworkName($contact['network'], $contact['url']),
'tags' => $contact['keywords'], 'tags' => $contact['keywords'],
'bd' => $contact['birthday'] <= DBA::NULL_DATE ? '' : $contact['birthday'], 'bd' => $contact['birthday'] <= DBA::NULL_DATE ? '' : $contact['birthday'],
'account_type' => Contact::getAccountType($contact), 'account_type' => Contact::getAccountType($contact),

View file

@ -297,9 +297,9 @@ class Profile
$profile['picdate'] = urlencode(defaults($profile, 'picdate', '')); $profile['picdate'] = urlencode(defaults($profile, 'picdate', ''));
if (($profile['network'] != '') && ($profile['network'] != Protocol::DFRN)) { 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 { } else {
$profile['network_name'] = ''; $profile['network_link'] = '';
} }
Addon::callHooks('profile_sidebar_enter', $profile); Addon::callHooks('profile_sidebar_enter', $profile);

View file

@ -75,18 +75,17 @@ class Contact extends BaseModule
$a->data['contact'] = $contact; $a->data['contact'] = $contact;
if (($contact['network'] != '') && ($contact['network'] != Protocol::DFRN)) { if (($contact['network'] != '') && ($contact['network'] != Protocol::DFRN)) {
$networkname = Strings::formatNetworkName($contact['network'], $contact['url']); $network_link = Strings::formatNetworkName($contact['network'], $contact['url']);
} else { } else {
$networkname = ''; $network_link = '';
} }
/// @TODO Add nice spaces
$vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('vcard-widget.tpl'), [ $vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('vcard-widget.tpl'), [
'$name' => $contact['name'], '$name' => $contact['name'],
'$photo' => $contact['photo'], '$photo' => $contact['photo'],
'$url' => Model\Contact::MagicLink($contact['url']), '$url' => Model\Contact::MagicLink($contact['url']),
'$addr' => defaults($contact, 'addr', ''), '$addr' => defaults($contact, 'addr', ''),
'$network_name' => $networkname, '$network_link' => $network_link,
'$network' => L10n::t('Network:'), '$network' => L10n::t('Network:'),
'$account_type' => Model\Contact::getAccountType($contact) '$account_type' => Model\Contact::getAccountType($contact)
]); ]);

View file

@ -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 Network name of the contact (e.g. dfrn, rss and so on) * @param string $network Network name of the contact (e.g. dfrn, rss and so on)
* @param string $url The contact url * @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 ($network != '') {
if ($url != "") { if ($url != '') {
$network_name = '<a href="' . $url .'">' . ContactSelector::networkToName($network, $url) . "</a>"; $network_name = '<a href="' . $url .'">' . ContactSelector::networkToName($network, $url) . '</a>';
} else { } else {
$network_name = ContactSelector::networkToName($network); $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 $text String to be transformed.
* @param string $chr Optional. Indentation tag. Default tab (\t). * @param string $chr Optional. Indentation tag. Default tab (\t).

View file

@ -12,7 +12,7 @@
</div> </div>
<div class="profile-details"> <div class="profile-details">
<span class="profile-addr">{{$profile.addr}}</span> <span class="profile-addr">{{$profile.addr}}</span>
{{if $profile.network}}<span class="profile-network"> ({{$profile.network}})</span>{{/if}} {{if $profile.network_link}}<span class="profile-network">({{$profile.network_link nofilter}})</span>{{/if}}
</div> </div>
{{*{{if $profile.about}}<div class="profile-details profile-about">{{$profile.about nofilter}}</div>{{/if}}*}} {{*{{if $profile.about}}<div class="profile-details profile-about">{{$profile.about nofilter}}</div>{{/if}}*}}

View file

@ -13,7 +13,7 @@
<div id="profile-photo-wrapper"><a href="{{$profile.url}}"><img class="photo u-photo" width="175" height="175" src="{{$profile.photo}}" alt="{{$profile.name}}"></a></div> <div id="profile-photo-wrapper"><a href="{{$profile.url}}"><img class="photo u-photo" width="175" height="175" src="{{$profile.photo}}" alt="{{$profile.name}}"></a></div>
{{/if}} {{/if}}
{{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}} {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
{{if $profile.network_name}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_name nofilter}}</dd></dl>{{/if}} {{if $profile.network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_link nofilter}}</dd></dl>{{/if}}
{{if $location}} {{if $location}}
<dl class="location"><dt class="location-label">{{$location}}</dt> <dl class="location"><dt class="location-label">{{$location}}</dt>
<dd class="adr h-adr"> <dd class="adr h-adr">

View file

@ -9,6 +9,6 @@
<div id="profile-photo-wrapper"><img class="vcard-photo photo u-photo" style="width: 175px; height: 175px;" src="{{$photo}}" alt="{{$name}}" /></div> <div id="profile-photo-wrapper"><img class="vcard-photo photo u-photo" style="width: 175px; height: 175px;" src="{{$photo}}" alt="{{$name}}" /></div>
{{/if}} {{/if}}
{{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}} {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
{{if $network_name}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$network_name}}</dd></dl>{{/if}} {{if $network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$network_link nofilter}}</dd></dl>{{/if}}
<div id="profile-vcard-break"></div> <div id="profile-vcard-break"></div>
</div> </div>

View file

@ -10,7 +10,7 @@
{{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}} {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
{{if $profile.network_name}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_name nofilter}}</dd></dl>{{/if}} {{if $profile.network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_link nofilter}}</dd></dl>{{/if}}
{{if $location}} {{if $location}}
<dl class="location"><dt class="location-label">{{$location}}</dt> <dl class="location"><dt class="location-label">{{$location}}</dt>

View file

@ -32,7 +32,7 @@
{{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}} {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
{{if $network_name}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$network_name nofilter}}</dd></dl>{{/if}} {{if $network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$network_link nofilter}}</dd></dl>{{/if}}
</div> </div>
</div> </div>
</div> </div>

View file

@ -33,7 +33,7 @@
{{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}} {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
{{if $profile.network_name}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_name nofilter}}</dd></dl>{{/if}} {{if $profile.network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_link nofilter}}</dd></dl>{{/if}}
{{if $location}} {{if $location}}
<dl class="location"><dt class="location-label">{{$location}}</dt> <dl class="location"><dt class="location-label">{{$location}}</dt>

View file

@ -24,7 +24,7 @@
{{/if}} {{/if}}
{{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}} {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
{{if $profile.network_name}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_name nofilter}}</dd></dl>{{/if}} {{if $profile.network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_link nofilter}}</dd></dl>{{/if}}
{{if $location}} {{if $location}}
<dl class="location"><dt class="location-label">{{$location}}</dt> <dl class="location"><dt class="location-label">{{$location}}</dt>
<dd class="adr h-adr"> <dd class="adr h-adr">