Fix errors in Content namespace

This commit is contained in:
Art4 2024-11-19 08:30:26 +00:00
parent 3c84c21318
commit caa826ca06
8 changed files with 28 additions and 16 deletions

View file

@ -142,17 +142,18 @@ class ContactSelector
$replace = array_values($nets);
$networkname = str_replace($search, $replace, $network);
$platform = '';
if (in_array($network, Protocol::FEDERATED) && !empty($gsid)) {
$gserver = self::getServerForId($gsid);
if (!empty($gserver['platform'])) {
$platform = $gserver['platform'];
$platform = (string) $gserver['platform'];
} elseif (!empty($gserver['network']) && ($gserver['network'] != Protocol::ACTIVITYPUB)) {
$platform = self::networkToName($gserver['network']);
}
if (!empty($platform)) {
if ($platform !== '') {
$networkname = $platform;
}
}
@ -161,7 +162,7 @@ class ContactSelector
$networkname = DI::l10n()->t('%s (via %s)', $networkname, self::networkToName($protocol));
} elseif (in_array($network, ['', $protocol]) && ($network == Protocol::DFRN)) {
$networkname .= ' (DFRN)';
} elseif (in_array($network, ['', $protocol]) && ($network == Protocol::DIASPORA) && ($platform != 'diaspora')) {
} elseif (in_array($network, ['', $protocol]) && ($network == Protocol::DIASPORA) && ($platform !== 'diaspora')) {
$networkname .= ' (Diaspora)';
}

View file

@ -180,6 +180,7 @@ class Item
public static function replaceTag(string &$body, int $profile_uid, string $tag, string $network = '')
{
$replaced = false;
$contact = [];
//is it a person tag?
if (Tag::isType($tag, Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION)) {
@ -247,6 +248,8 @@ class Item
}
}
$newname = '';
// Check if $contact has been successfully loaded
if (DBA::isResult($contact)) {
$profile = $contact['url'];

View file

@ -178,7 +178,7 @@ class OEmbed
$oembed->thumbnail_height = $data['images'][0]['height'];
}
Hook::callAll('oembed_fetch_url', $embedurl, $oembed);
Hook::callAll('oembed_fetch_url', $embedurl);
return $oembed;
}

View file

@ -116,9 +116,10 @@ class PostMedia extends BaseRepository
return $attachments;
}
$heights = [];
$heights = [];
$selected = '';
$previews = [];
$video = [];
foreach ($PostMedias as $PostMedia) {
foreach ($links as $link) {

View file

@ -543,6 +543,8 @@ class NPF
return $npf;
}
$block = [];
$media = Post\Media::getByURL($uri_id, $attributes['src'], [Post\Media::AUDIO, Post\Media::VIDEO]);
if (!empty($media)) {
switch ($media['type']) {

View file

@ -114,6 +114,8 @@ class Plaintext
$post['text'] = trim($item['title']);
}
$abstract = '';
// Fetch the abstract from the given target network
switch ($htmlmode) {
case BBCode::TWITTER:
@ -246,6 +248,9 @@ class Plaintext
$limit = $baselimit;
while ($message) {
$word = $message;
$message = '';
$pos = 0;
$pos_word = mb_strpos($message, ' ');
$pos_paragraph = mb_strpos($message, "\n");
@ -255,9 +260,6 @@ class Plaintext
$pos = $pos_word + 1;
} elseif ($pos_paragraph !== false) {
$pos = $pos_paragraph + 1;
} else {
$word = $message;
$message = '';
}
if (trim($message)) {

View file

@ -402,7 +402,7 @@ class Widget
return '';
}
$commonContacts = Contact\Relation::listCommon($localPCid, $visitorPCid, $condition, 0, 5, true);
$commonContacts = Contact\Relation::listCommon($localPCid, $visitorPCid, $condition, 0, 5);
if (!DBA::isResult($commonContacts)) {
return '';
}
@ -479,6 +479,10 @@ class Widget
DI::cache()->set($cachekey, $dthen, Duration::HOUR);
}
$cutoffday = '';
$thisday = '';
$nextday = '';
if ($dthen) {
// Set the start and end date to the beginning of the month
$cutoffday = $dthen;
@ -513,7 +517,6 @@ class Widget
return $o;
}
$cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years;
$cutoff = array_key_exists($cutoff_year, $ret);

View file

@ -34,7 +34,7 @@ class VCard
public static function getHTML(array $contact, bool $hide_mention = false, bool $hide_follow = false): string
{
if (!isset($contact['network']) || !isset($contact['id'])) {
Logger::warning('Incomplete contact', ['contact' => $contact ?? []]);
Logger::warning('Incomplete contact', ['contact' => $contact]);
}
$contact_url = Contact::getProfileLink($contact);