mirror of
https://github.com/friendica/friendica
synced 2025-04-29 11:44:24 +02:00
Display the contact alias if the URL is no HTTP link
This commit is contained in:
parent
6d911a8f39
commit
4c3f2441f7
16 changed files with 528 additions and 303 deletions
|
@ -154,7 +154,8 @@ class Conversation
|
|||
'uid' => 0,
|
||||
'id' => $activity['author-id'],
|
||||
'network' => $activity['author-network'],
|
||||
'url' => $activity['author-link']
|
||||
'url' => $activity['author-link'],
|
||||
'alias' => $activity['author-alias'],
|
||||
];
|
||||
$url = Contact::magicLinkByContact($author);
|
||||
if (strpos($url, 'contact/redir/') === 0) {
|
||||
|
@ -272,7 +273,7 @@ class Conversation
|
|||
$phrase = $this->l10n->tt('<button type="button" %2$s>%1$d person</button> attends', '<button type="button" %2$s>%1$d people</button> attend', $total, $spanatts);
|
||||
break;
|
||||
case 'attendno':
|
||||
$phrase = $this->l10n->tt('<button type="button" %2$s>%1$d person</button> doesn\'t attend','<button type="button" %2$s>%1$d people</button> don\'t attend', $total, $spanatts);
|
||||
$phrase = $this->l10n->tt('<button type="button" %2$s>%1$d person</button> doesn\'t attend', '<button type="button" %2$s>%1$d people</button> don\'t attend', $total, $spanatts);
|
||||
break;
|
||||
case 'attendmaybe':
|
||||
$phrase = $this->l10n->tt('<button type="button" %2$s>%1$d person</button> attends maybe', '<button type="button" %2$s>%1$d people</button> attend maybe', $total, $spanatts);
|
||||
|
@ -537,7 +538,7 @@ class Conversation
|
|||
if (!$update) {
|
||||
$live_update_div = '<div id="live-contact"></div>' . "\r\n"
|
||||
. "<script> var profile_uid = -1; var netargs = '" . substr($this->args->getCommand(), 8)
|
||||
."?f='; </script>\r\n";
|
||||
. "?f='; </script>\r\n";
|
||||
}
|
||||
} elseif ($mode === self::MODE_SEARCH) {
|
||||
$live_update_div = '<div id="live-search"></div>' . "\r\n";
|
||||
|
@ -625,7 +626,13 @@ class Conversation
|
|||
|
||||
$tags = Tag::populateFromItem($item);
|
||||
|
||||
$author = ['uid' => 0, 'id' => $item['author-id'], 'network' => $item['author-network'], 'url' => $item['author-link']];
|
||||
$author = [
|
||||
'uid' => 0,
|
||||
'id' => $item['author-id'],
|
||||
'network' => $item['author-network'],
|
||||
'url' => $item['author-link'],
|
||||
'alias' => $item['author-alias'],
|
||||
];
|
||||
$profile_link = Contact::magicLinkByContact($author);
|
||||
|
||||
$sparkle = '';
|
||||
|
@ -856,7 +863,8 @@ class Conversation
|
|||
$row['causer-avatar'] = $contact['thumb'];
|
||||
$row['causer-name'] = $contact['name'];
|
||||
} elseif (($row['gravity'] == ItemModel::GRAVITY_ACTIVITY) && ($row['verb'] == Activity::ANNOUNCE) &&
|
||||
($row['author-id'] == $activity['causer-id'])) {
|
||||
($row['author-id'] == $activity['causer-id'])
|
||||
) {
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
@ -892,9 +900,15 @@ class Conversation
|
|||
}
|
||||
|
||||
if (in_array($row['gravity'], [ItemModel::GRAVITY_PARENT, ItemModel::GRAVITY_COMMENT]) && !empty($row['causer-id'])) {
|
||||
$causer = ['uid' => 0, 'id' => $row['causer-id'], 'network' => $row['causer-network'], 'url' => $row['causer-link']];
|
||||
$causer = [
|
||||
'uid' => 0,
|
||||
'id' => $row['causer-id'],
|
||||
'network' => $row['causer-network'],
|
||||
'url' => $row['causer-link'],
|
||||
'alias' => $row['causer-alias'],
|
||||
];
|
||||
|
||||
$row['reshared'] = $this->l10n->t('%s reshared this.', '<a href="'. htmlentities(Contact::magicLinkByContact($causer)) .'">' . htmlentities($row['causer-name']) . '</a>');
|
||||
$row['reshared'] = $this->l10n->t('%s reshared this.', '<a href="' . htmlentities(Contact::magicLinkByContact($causer)) . '">' . htmlentities($row['causer-name']) . '</a>');
|
||||
}
|
||||
$row['direction'] = ['direction' => 3, 'title' => (empty($row['causer-id']) ? $this->l10n->t('Reshared') : $this->l10n->t('Reshared by %s <%s>', $row['causer-name'], $row['causer-link']))];
|
||||
break;
|
||||
|
@ -994,15 +1008,21 @@ class Conversation
|
|||
$condition = DBA::mergeConditions($condition, ["(`gravity` != ? OR `origin`)", ItemModel::GRAVITY_ACTIVITY]);
|
||||
}
|
||||
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["`uid` IN (0, ?) AND (NOT `vid` IN (?, ?, ?) OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW), Verb::getID(Activity::READ)]);
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
["`uid` IN (0, ?) AND (NOT `vid` IN (?, ?, ?) OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW), Verb::getID(Activity::READ)]
|
||||
);
|
||||
|
||||
$condition = DBA::mergeConditions($condition, ["(`uid` != ? OR `private` != ?)", 0, ItemModel::PRIVATE]);
|
||||
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["`visible` AND NOT `deleted` AND NOT `author-blocked` AND NOT `owner-blocked`
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
[
|
||||
"`visible` AND NOT `deleted` AND NOT `author-blocked` AND NOT `owner-blocked`
|
||||
AND ((NOT `contact-pending` AND (`contact-rel` IN (?, ?))) OR `self` OR `contact-uid` = ?)",
|
||||
Contact::SHARING, Contact::FRIEND, 0]);
|
||||
Contact::SHARING, Contact::FRIEND, 0
|
||||
]
|
||||
);
|
||||
|
||||
$thread_parents = Post::select(['uri-id', 'causer-id'], $condition, ['order' => ['uri-id' => false, 'uid']]);
|
||||
|
||||
|
@ -1109,8 +1129,10 @@ class Conversation
|
|||
$items[$key]['user-collapsed-author'] = !$always_display && in_array($row['author-id'], $collapses);
|
||||
$items[$key]['user-collapsed-owner'] = !$always_display && in_array($row['owner-id'], $collapses);
|
||||
|
||||
if (in_array($mode, [self::MODE_COMMUNITY, self::MODE_NETWORK]) &&
|
||||
(in_array($row['author-id'], $blocks) || in_array($row['owner-id'], $blocks) || in_array($row['author-id'], $ignores) || in_array($row['owner-id'], $ignores))) {
|
||||
if (
|
||||
in_array($mode, [self::MODE_COMMUNITY, self::MODE_NETWORK]) &&
|
||||
(in_array($row['author-id'], $blocks) || in_array($row['owner-id'], $blocks) || in_array($row['author-id'], $ignores) || in_array($row['owner-id'], $ignores))
|
||||
) {
|
||||
unset($items[$key]);
|
||||
}
|
||||
}
|
||||
|
@ -1145,7 +1167,7 @@ class Conversation
|
|||
$condition = DBA::mergeConditions(['parent-uri-id' => $uriids, 'gravity' => ItemModel::GRAVITY_ACTIVITY, 'verb' => $verbs], ["NOT `deleted`"]);
|
||||
$separator = chr(255) . chr(255) . chr(255);
|
||||
|
||||
$sql = "SELECT `thr-parent-id`, `body`, `verb`, COUNT(*) AS `total`, GROUP_CONCAT(REPLACE(`author-name`, '" . $separator . "', ' ') SEPARATOR '". $separator ."' LIMIT 50) AS `title` FROM `post-view` WHERE " . array_shift($condition) . " GROUP BY `thr-parent-id`, `verb`, `body`";
|
||||
$sql = "SELECT `thr-parent-id`, `body`, `verb`, COUNT(*) AS `total`, GROUP_CONCAT(REPLACE(`author-name`, '" . $separator . "', ' ') SEPARATOR '" . $separator . "' LIMIT 50) AS `title` FROM `post-view` WHERE " . array_shift($condition) . " GROUP BY `thr-parent-id`, `verb`, `body`";
|
||||
|
||||
$emojis = [];
|
||||
|
||||
|
@ -1286,7 +1308,7 @@ class Conversation
|
|||
// Searches the post item in the children
|
||||
$j = 0;
|
||||
while ($child['children'][$j]['verb'] !== Activity::POST && $j < count($child['children'])) {
|
||||
$j ++;
|
||||
$j++;
|
||||
}
|
||||
|
||||
$moved_item = $child['children'][$j];
|
||||
|
@ -1360,8 +1382,10 @@ class Conversation
|
|||
* items and add them as children of their top-level post.
|
||||
*/
|
||||
foreach ($parents as $i => $parent) {
|
||||
$parents[$i]['children'] = array_merge($this->getItemChildren($item_array, $parent, true),
|
||||
$this->getItemChildren($item_array, $parent, false));
|
||||
$parents[$i]['children'] = array_merge(
|
||||
$this->getItemChildren($item_array, $parent, true),
|
||||
$this->getItemChildren($item_array, $parent, false)
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($parents as $i => $parent) {
|
||||
|
|
|
@ -78,7 +78,7 @@ class GroupManager
|
|||
|
||||
$groupList = [];
|
||||
|
||||
$fields = ['id', 'url', 'name', 'micro', 'thumb', 'avatar', 'network', 'uid'];
|
||||
$fields = ['id', 'url', 'alias', 'name', 'micro', 'thumb', 'avatar', 'network', 'uid'];
|
||||
$contacts = DBA::select('account-user-view', $fields, $condition, $params);
|
||||
if (!$contacts) {
|
||||
return $groupList;
|
||||
|
@ -87,6 +87,7 @@ class GroupManager
|
|||
while ($contact = DBA::fetch($contacts)) {
|
||||
$groupList[] = [
|
||||
'url' => $contact['url'],
|
||||
'alias' => $contact['alias'],
|
||||
'name' => $contact['name'],
|
||||
'id' => $contact['id'],
|
||||
'micro' => $contact['micro'],
|
||||
|
|
|
@ -305,18 +305,20 @@ class Item
|
|||
}
|
||||
|
||||
$author_arr = [
|
||||
'uid' => 0,
|
||||
'id' => $item['author-id'],
|
||||
'uid' => 0,
|
||||
'id' => $item['author-id'],
|
||||
'network' => $item['author-network'],
|
||||
'url' => $item['author-link'],
|
||||
'url' => $item['author-link'],
|
||||
'alias' => $item['author-lias'],
|
||||
];
|
||||
$author = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $item['author-name'] . '[/url]';
|
||||
|
||||
$author_arr = [
|
||||
'uid' => 0,
|
||||
'id' => $obj['author-id'],
|
||||
'uid' => 0,
|
||||
'id' => $obj['author-id'],
|
||||
'network' => $obj['author-network'],
|
||||
'url' => $obj['author-link'],
|
||||
'url' => $obj['author-link'],
|
||||
'alias' => $obj['author-alias'],
|
||||
];
|
||||
$objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
|
||||
|
||||
|
@ -372,10 +374,11 @@ class Item
|
|||
}
|
||||
|
||||
$author = [
|
||||
'uid' => 0,
|
||||
'id' => $item['author-id'],
|
||||
'uid' => 0,
|
||||
'id' => $item['author-id'],
|
||||
'network' => $item['author-network'],
|
||||
'url' => $item['author-link'],
|
||||
'url' => $item['author-link'],
|
||||
'alias' => $item['author-alias'],
|
||||
];
|
||||
$profile_link = Contact::magicLinkByContact($author, $item['author-link']);
|
||||
if (strpos($profile_link, 'contact/redir/') === 0) {
|
||||
|
|
|
@ -422,7 +422,8 @@ class HTML
|
|||
{
|
||||
$URLSearchString = "^\[\]";
|
||||
|
||||
$matches = ["/\[url\=([$URLSearchString]*)\].*?\[\/url\]/ism",
|
||||
$matches = [
|
||||
"/\[url\=([$URLSearchString]*)\].*?\[\/url\]/ism",
|
||||
"/\[url\]([$URLSearchString]*)\[\/url\]/ism",
|
||||
"/\[img\=[0-9]*x[0-9]*\](.*?)\[\/img\]/ism",
|
||||
"/\[img\](.*?)\[\/img\]/ism",
|
||||
|
@ -531,8 +532,10 @@ class HTML
|
|||
$ignore = false;
|
||||
|
||||
// A list of some links that should be ignored
|
||||
$list = ["/user/", "/tag/", "/group/", "/circle/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
|
||||
"//plus.google.com/", "//twitter.com/"];
|
||||
$list = [
|
||||
"/user/", "/tag/", "/group/", "/circle/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
|
||||
"//plus.google.com/", "//twitter.com/"
|
||||
];
|
||||
foreach ($list as $listitem) {
|
||||
if (strpos($treffer[1], $listitem) !== false) {
|
||||
$ignore = true;
|
||||
|
@ -941,7 +944,8 @@ class HTML
|
|||
$domain = '(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)*' . preg_quote(trim($domain, '/'), '%');
|
||||
});
|
||||
|
||||
$config->set('URI.SafeIframeRegexp',
|
||||
$config->set(
|
||||
'URI.SafeIframeRegexp',
|
||||
'%^https://(?:
|
||||
' . implode('|', $allowedIframeDomains) . '
|
||||
)
|
||||
|
@ -1050,7 +1054,8 @@ class HTML
|
|||
if (isset($mediaType->parameters['charset'])) {
|
||||
return strtolower($mediaType->parameters['charset']);
|
||||
}
|
||||
} catch(\InvalidArgumentException $e) {}
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -474,7 +474,6 @@ class Widget
|
|||
$thisday = substr($dnow, 4);
|
||||
$dnow = substr($dnow, 0, 8) . '01';
|
||||
$dthen = substr($dthen, 0, 8) . '01';
|
||||
|
||||
|
||||
/*
|
||||
* Starting with the current month, get the first and last days of every
|
||||
|
@ -494,7 +493,6 @@ class Widget
|
|||
|
||||
$ret[$dyear][] = [$str, $end_month, $start_month];
|
||||
$dnow = DateTimeFormat::utc($dnow . ' -1 month', 'Y-m-d');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,7 +504,7 @@ class Widget
|
|||
$cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years;
|
||||
$cutoff = array_key_exists($cutoff_year, $ret);
|
||||
|
||||
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/posted_date.tpl'),[
|
||||
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/posted_date.tpl'), [
|
||||
'$title' => DI::l10n()->t('Archives'),
|
||||
'$size' => $visible_years,
|
||||
'$cutoff_year' => $cutoff_year,
|
||||
|
@ -540,7 +538,14 @@ class Widget
|
|||
['ref' => 'community', 'name' => DI::l10n()->t('Groups')],
|
||||
];
|
||||
|
||||
return self::filter('accounttype', DI::l10n()->t('Account Types'), '',
|
||||
DI::l10n()->t('All'), $base, $accounts, $accounttype);
|
||||
return self::filter(
|
||||
'accounttype',
|
||||
DI::l10n()->t('Account Types'),
|
||||
'',
|
||||
DI::l10n()->t('All'),
|
||||
$base,
|
||||
$accounts,
|
||||
$accounttype
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ class ContactBlock
|
|||
$contact_uriids = array_column($personal_contacts, 'uri-id');
|
||||
|
||||
if (!empty($contact_uriids)) {
|
||||
$contacts_stmt = DBA::select('contact', ['id', 'uid', 'addr', 'url', 'name', 'thumb', 'avatar', 'network'], ['uri-id' => $contact_uriids, 'uid' => $contact_uid]);
|
||||
$contacts_stmt = DBA::select('contact', ['id', 'uid', 'addr', 'url', 'alias', 'name', 'thumb', 'avatar', 'network'], ['uri-id' => $contact_uriids, 'uid' => $contact_uid]);
|
||||
|
||||
if (DBA::isResult($contacts_stmt)) {
|
||||
$contacts_title = DI::l10n()->tt('%d Contact', '%d Contacts', $total);
|
||||
|
|
|
@ -29,6 +29,7 @@ use Friendica\Core\Renderer;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
/**
|
||||
|
@ -50,9 +51,15 @@ class VCard
|
|||
Logger::warning('Incomplete contact', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);
|
||||
}
|
||||
|
||||
if (!Network::isValidHttpUrl($contact['url']) && Network::isValidHttpUrl($contact['alias'])) {
|
||||
$url = $contact['alias'];
|
||||
} else {
|
||||
$url = $contact['url'];
|
||||
}
|
||||
|
||||
if ($contact['network'] != '') {
|
||||
$network_link = Strings::formatNetworkName($contact['network'], $contact['url']);
|
||||
$network_avatar = ContactSelector::networkToIcon($contact['network'], $contact['url']);
|
||||
$network_link = Strings::formatNetworkName($contact['network'], $url);
|
||||
$network_avatar = ContactSelector::networkToIcon($contact['network'], $url);
|
||||
} else {
|
||||
$network_link = '';
|
||||
$network_avatar = '';
|
||||
|
@ -83,9 +90,9 @@ class VCard
|
|||
|
||||
if (empty($contact['self']) && Protocol::supportsFollow($contact['network'])) {
|
||||
if (in_array($rel, [Contact::SHARING, Contact::FRIEND])) {
|
||||
$unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1';
|
||||
$unfollow_link = 'contact/unfollow?url=' . urlencode($url) . '&auto=1';
|
||||
} elseif (!$pending) {
|
||||
$follow_link = 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1';
|
||||
$follow_link = 'contact/follow?url=' . urlencode($url) . '&auto=1';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +104,7 @@ class VCard
|
|||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/vcard.tpl'), [
|
||||
'$contact' => $contact,
|
||||
'$photo' => $photo,
|
||||
'$url' => Contact::magicLinkByContact($contact, $contact['url']),
|
||||
'$url' => Contact::magicLinkByContact($contact, $url),
|
||||
'$about' => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['about'] ?? ''),
|
||||
'$xmpp' => DI::l10n()->t('XMPP:'),
|
||||
'$matrix' => DI::l10n()->t('Matrix:'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue