]> git.mxchange.org Git - friendica.git/commitdiff
Fix errors in Content namespace
authorArt4 <art4@wlabs.de>
Tue, 19 Nov 2024 08:30:26 +0000 (08:30 +0000)
committerArt4 <art4@wlabs.de>
Tue, 19 Nov 2024 08:30:26 +0000 (08:30 +0000)
src/Content/ContactSelector.php
src/Content/Item.php
src/Content/OEmbed.php
src/Content/Post/Repository/PostMedia.php
src/Content/Text/NPF.php
src/Content/Text/Plaintext.php
src/Content/Widget.php
src/Content/Widget/VCard.php

index 5a00feeaf6425688ce98dc8dfe9b47448ce33213..4e75ea34d12eeed12b7003cf5e238292c7d73ef9 100644 (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)';
                }
 
@@ -191,7 +192,7 @@ class ContactSelector
                $nets = [
                        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::DFRN        => 'friendica', 
+                       Protocol::DFRN        => 'friendica',
                        Protocol::DIASPORA    => '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
index a5a1a17a19057369cc9be823ebe5e1f789f27e2d..66a3328b04936e8de1520e2c8ecd0f761cb0bf47 100644 (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'];
index 4d3c58904194a7bcc4b4b35b6e831589e6833776..e5841ea22e31d736f9476c21797df0eb134b2d6b 100644 (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;
        }
index e46bd994867376eb8c5f968f4f63b07bad8ca772..778591c1ab8fcf8a826174f1b1d6664a2d8f455c 100644 (file)
@@ -116,9 +116,10 @@ class PostMedia extends BaseRepository
                        return $attachments;
                }
 
-               $heights = [];
+               $heights  = [];
                $selected = '';
                $previews = [];
+               $video    = [];
 
                foreach ($PostMedias as $PostMedia) {
                        foreach ($links as $link) {
index a0dd84fafabda16294971c709b3be1c6ac66a724..c830d64a0f252b87e28783e00d14d6de73e6043e 100644 (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']) {
index d2362714f4237c8182712c10f3e7a5ebbcf5cfe9..04af33cf7db5e581e5237e22e73cafda5ae82b41 100644 (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:
@@ -123,7 +125,7 @@ class Plaintext
                        case BBCode::BLUESKY:
                                $abstract = BBCode::getAbstract($item['body'], Protocol::BLUESKY);
                                break;
-       
+
                        default: // We don't know the exact target.
                                // We fetch an abstract since there is a posting limit.
                                if ($limit > 0) {
@@ -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)) {
@@ -272,7 +274,7 @@ class Plaintext
                        $break = mb_strrpos($word, "\n") !== false;
                        if (!$break && (mb_strrpos($word, '. ') !== false || mb_strrpos($word, '? ') !== false || mb_strrpos($word, '! ') !== false)) {
                                $break = IntlChar::isupper(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;
                                $comma_pos = 0;
                        } elseif ($break) {
-                               $break_pos = $pos + mb_strlen($part);   
+                               $break_pos = $pos + mb_strlen($part);
                        } elseif ($comma) {
                                $comma_pos = $pos + mb_strlen($part);
                        }
index 6f030b640f6a2c1804bd04d93205febbb40a2006..0c73df9091fa62b37d7fc1347e53fb614dcf90a5 100644 (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);
 
index 737db45ac258502cb342099c55807e263c9d6f71..cda7bb53b80cdf3334d8d3073008ca4eed0a34cb 100644 (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);
@@ -61,7 +61,7 @@ class VCard
                                $hide_follow  = true;
                                $hide_mention = true;
                        }
-               
+
                        if ($contact['uid']) {
                                $id      = $contact['id'];
                                $rel     = $contact['rel'];