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); $replace = array_values($nets);
$networkname = str_replace($search, $replace, $network); $networkname = str_replace($search, $replace, $network);
$platform = '';
if (in_array($network, Protocol::FEDERATED) && !empty($gsid)) { if (in_array($network, Protocol::FEDERATED) && !empty($gsid)) {
$gserver = self::getServerForId($gsid); $gserver = self::getServerForId($gsid);
if (!empty($gserver['platform'])) { if (!empty($gserver['platform'])) {
$platform = $gserver['platform']; $platform = (string) $gserver['platform'];
} elseif (!empty($gserver['network']) && ($gserver['network'] != Protocol::ACTIVITYPUB)) { } elseif (!empty($gserver['network']) && ($gserver['network'] != Protocol::ACTIVITYPUB)) {
$platform = self::networkToName($gserver['network']); $platform = self::networkToName($gserver['network']);
} }
if (!empty($platform)) { if ($platform !== '') {
$networkname = $platform; $networkname = $platform;
} }
} }
@ -161,7 +162,7 @@ class ContactSelector
$networkname = DI::l10n()->t('%s (via %s)', $networkname, self::networkToName($protocol)); $networkname = DI::l10n()->t('%s (via %s)', $networkname, self::networkToName($protocol));
} elseif (in_array($network, ['', $protocol]) && ($network == Protocol::DFRN)) { } elseif (in_array($network, ['', $protocol]) && ($network == Protocol::DFRN)) {
$networkname .= ' (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)'; $networkname .= ' (Diaspora)';
} }
@ -191,7 +192,7 @@ class ContactSelector
$nets = [ $nets = [
Protocol::ACTIVITYPUB => 'activitypub', // https://commons.wikimedia.org/wiki/File:ActivityPub-logo-symbol.svg Protocol::ACTIVITYPUB => 'activitypub', // https://commons.wikimedia.org/wiki/File:ActivityPub-logo-symbol.svg
Protocol::BLUESKY => 'bluesky', // https://commons.wikimedia.org/wiki/File:Bluesky_Logo.svg Protocol::BLUESKY => 'bluesky', // https://commons.wikimedia.org/wiki/File:Bluesky_Logo.svg
Protocol::DFRN => 'friendica', Protocol::DFRN => 'friendica',
Protocol::DIASPORA => 'diaspora', // https://www.svgrepo.com/svg/362315/diaspora Protocol::DIASPORA => 'diaspora', // https://www.svgrepo.com/svg/362315/diaspora
Protocol::DIASPORA2 => 'diaspora', // https://www.svgrepo.com/svg/362315/diaspora Protocol::DIASPORA2 => 'diaspora', // https://www.svgrepo.com/svg/362315/diaspora
Protocol::DISCOURSE => 'discourse', // https://commons.wikimedia.org/wiki/File:Discourse_icon.svg Protocol::DISCOURSE => 'discourse', // https://commons.wikimedia.org/wiki/File:Discourse_icon.svg

View file

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

View file

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

View file

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

View file

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

View file

@ -114,6 +114,8 @@ class Plaintext
$post['text'] = trim($item['title']); $post['text'] = trim($item['title']);
} }
$abstract = '';
// Fetch the abstract from the given target network // Fetch the abstract from the given target network
switch ($htmlmode) { switch ($htmlmode) {
case BBCode::TWITTER: case BBCode::TWITTER:
@ -123,7 +125,7 @@ class Plaintext
case BBCode::BLUESKY: case BBCode::BLUESKY:
$abstract = BBCode::getAbstract($item['body'], Protocol::BLUESKY); $abstract = BBCode::getAbstract($item['body'], Protocol::BLUESKY);
break; break;
default: // We don't know the exact target. default: // We don't know the exact target.
// We fetch an abstract since there is a posting limit. // We fetch an abstract since there is a posting limit.
if ($limit > 0) { if ($limit > 0) {
@ -246,6 +248,9 @@ class Plaintext
$limit = $baselimit; $limit = $baselimit;
while ($message) { while ($message) {
$word = $message;
$message = '';
$pos = 0;
$pos_word = mb_strpos($message, ' '); $pos_word = mb_strpos($message, ' ');
$pos_paragraph = mb_strpos($message, "\n"); $pos_paragraph = mb_strpos($message, "\n");
@ -255,9 +260,6 @@ class Plaintext
$pos = $pos_word + 1; $pos = $pos_word + 1;
} elseif ($pos_paragraph !== false) { } elseif ($pos_paragraph !== false) {
$pos = $pos_paragraph + 1; $pos = $pos_paragraph + 1;
} else {
$word = $message;
$message = '';
} }
if (trim($message)) { if (trim($message)) {
@ -272,7 +274,7 @@ class Plaintext
$break = mb_strrpos($word, "\n") !== false; $break = mb_strrpos($word, "\n") !== false;
if (!$break && (mb_strrpos($word, '. ') !== false || mb_strrpos($word, '? ') !== false || mb_strrpos($word, '! ') !== false)) { if (!$break && (mb_strrpos($word, '. ') !== false || mb_strrpos($word, '? ') !== false || mb_strrpos($word, '! ') !== false)) {
$break = IntlChar::isupper(mb_substr($message, 0, 1)); $break = IntlChar::isupper(mb_substr($message, 0, 1));
} }
$comma = (mb_strrpos($word, ', ') !== false) && IntlChar::isalpha(mb_substr($message, 0, 1)); $comma = (mb_strrpos($word, ', ') !== false) && IntlChar::isalpha(mb_substr($message, 0, 1));
@ -291,7 +293,7 @@ class Plaintext
$break_pos = 0; $break_pos = 0;
$comma_pos = 0; $comma_pos = 0;
} elseif ($break) { } elseif ($break) {
$break_pos = $pos + mb_strlen($part); $break_pos = $pos + mb_strlen($part);
} elseif ($comma) { } elseif ($comma) {
$comma_pos = $pos + mb_strlen($part); $comma_pos = $pos + mb_strlen($part);
} }

View file

@ -402,7 +402,7 @@ class Widget
return ''; return '';
} }
$commonContacts = Contact\Relation::listCommon($localPCid, $visitorPCid, $condition, 0, 5, true); $commonContacts = Contact\Relation::listCommon($localPCid, $visitorPCid, $condition, 0, 5);
if (!DBA::isResult($commonContacts)) { if (!DBA::isResult($commonContacts)) {
return ''; return '';
} }
@ -479,6 +479,10 @@ class Widget
DI::cache()->set($cachekey, $dthen, Duration::HOUR); DI::cache()->set($cachekey, $dthen, Duration::HOUR);
} }
$cutoffday = '';
$thisday = '';
$nextday = '';
if ($dthen) { if ($dthen) {
// Set the start and end date to the beginning of the month // Set the start and end date to the beginning of the month
$cutoffday = $dthen; $cutoffday = $dthen;
@ -513,7 +517,6 @@ class Widget
return $o; return $o;
} }
$cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years; $cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years;
$cutoff = array_key_exists($cutoff_year, $ret); $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 public static function getHTML(array $contact, bool $hide_mention = false, bool $hide_follow = false): string
{ {
if (!isset($contact['network']) || !isset($contact['id'])) { if (!isset($contact['network']) || !isset($contact['id'])) {
Logger::warning('Incomplete contact', ['contact' => $contact ?? []]); Logger::warning('Incomplete contact', ['contact' => $contact]);
} }
$contact_url = Contact::getProfileLink($contact); $contact_url = Contact::getProfileLink($contact);
@ -61,7 +61,7 @@ class VCard
$hide_follow = true; $hide_follow = true;
$hide_mention = true; $hide_mention = true;
} }
if ($contact['uid']) { if ($contact['uid']) {
$id = $contact['id']; $id = $contact['id'];
$rel = $contact['rel']; $rel = $contact['rel'];