Merge remote-tracking branch 'upstream/2023.05-rc' into receiver-exception

This commit is contained in:
Michael 2023-05-19 17:44:01 +00:00
commit 63436be80e
12 changed files with 253 additions and 237 deletions

View File

@ -1 +1 @@
2023.06-dev
2023.05-rc

View File

@ -375,9 +375,7 @@ function photos_post(App $a)
$arr['visible'] = 0;
$arr['origin'] = 1;
$arr['body'] = '[url=' . DI::baseUrl() . '/photos/' . $user['nickname'] . '/image/' . $photo['resource-id'] . ']'
. '[img]' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $photo['scale'] . '.'. $ext . '[/img]'
. '[/url]';
$arr['body'] = Images::getBBCodeByResource($photo['resource-id'], $user['nickname'], $photo['scale'], $ext);
$item_id = Item::insert($arr);
}

View File

@ -64,7 +64,7 @@ class App
{
const PLATFORM = 'Friendica';
const CODENAME = 'Giant Rhubarb';
const VERSION = '2023.06-dev';
const VERSION = '2023.05-rc';
// Allow themes to control internal parameters
// by changing App values in theme.php

View File

@ -378,7 +378,11 @@ class Item
'url' => $item['author-link'],
];
$profile_link = Contact::magicLinkByContact($author, $item['author-link']);
$sparkle = (strpos($profile_link, 'contact/redir/') === 0);
if (strpos($profile_link, 'contact/redir/') === 0) {
$status_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/status']);
$photos_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/photos']);
$profile_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/profile']);
}
$cid = 0;
$pcid = $item['author-id'];
@ -392,12 +396,6 @@ class Item
$rel = $contact['rel'];
}
if ($sparkle) {
$status_link = $profile_link . '/status';
$photos_link = $profile_link . '/photos';
$profile_link = $profile_link . '/profile';
}
if (!empty($pcid)) {
$contact_url = 'contact/' . $pcid;
$posts_link = $contact_url . '/posts';

View File

@ -24,7 +24,6 @@ namespace Friendica\Content\Text;
use DOMDocument;
use DOMXPath;
use Friendica\Protocol\HTTP\MediaType;
use Friendica\Content\Widget\ContactBlock;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\Core\Search;

View File

@ -1152,10 +1152,11 @@ class Contact
$status_link = '';
$photos_link = '';
$sparkle = false;
if (($contact['network'] === Protocol::DFRN) && !$contact['self'] && empty($contact['pending'])) {
$sparkle = true;
$profile_link = 'contact/redir/' . $contact['id'];
$status_link = $profile_link . '?' . http_build_query(['url' => $contact['url'] . '/status']);
$photos_link = $profile_link . '?' . http_build_query(['url' => $contact['url'] . '/photos']);
$profile_link = $profile_link . '?' . http_build_query(['url' => $contact['url'] . '/profile']);
} else {
$profile_link = $contact['url'];
}
@ -1164,12 +1165,6 @@ class Contact
$profile_link = '';
}
if ($sparkle) {
$status_link = $profile_link . '/status';
$photos_link = $profile_link . '/photos';
$profile_link = $profile_link . '/profile';
}
if (self::canReceivePrivateMessages($contact) && empty($contact['pending'])) {
$pm_url = 'message/new/' . $contact['id'];
}
@ -3444,7 +3439,7 @@ class Contact
*/
public static function magicLinkByContact(array $contact, string $url = ''): string
{
$destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
$destination = $url ?: $contact['url'];
if (!DI::userSession()->isAuthenticated()) {
return $destination;

View File

@ -489,7 +489,7 @@ class Media
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img=([^\[\]]*)\]([^\[\]]*)\[\/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
foreach ($pictures as $picture) {
if (self::isLinkToImagePage($picture[1], $picture[2])) {
$body = str_replace($picture[0], '[url=' . str_replace(['-1.', '-2.'], '-0.', $picture[2]) . '][img=' . $picture[2] . ']' . $picture[3] . '[/img][/url]', $body);
$body = str_replace($picture[0], Images::getBBCodeByUrl(str_replace(['-1.', '-2.'], '-0.', $picture[2]), $picture[2], $picture[3]), $body);
}
}
}
@ -497,7 +497,7 @@ class Media
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img\]([^\[]+?)\[/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
foreach ($pictures as $picture) {
if (self::isLinkToImagePage($picture[1], $picture[2])) {
$body = str_replace($picture[0], '[url=' . str_replace(['-1.', '-2.'], '-0.', $picture[2]) . '][img]' . $picture[2] . '[/img][/url]', $body);
$body = str_replace($picture[0], Images::getBBCodeByUrl(str_replace(['-1.', '-2.'], '-0.', $picture[2]), $picture[2]), $body);
}
}
}
@ -1004,19 +1004,7 @@ class Media
}
if ($media['type'] == self::IMAGE) {
if (!empty($media['preview'])) {
if (!empty($media['description'])) {
$body .= "\n[url=" . $media['url'] . "][img=" . $media['preview'] . ']' . $media['description'] . '[/img][/url]';
} else {
$body .= "\n[url=" . $media['url'] . "][img]" . $media['preview'] . '[/img][/url]';
}
} else {
if (!empty($media['description'])) {
$body .= "\n[img=" . $media['url'] . ']' . $media['description'] . '[/img]';
} else {
$body .= "\n[img]" . $media['url'] . '[/img]';
}
}
$body .= "\n" . Images::getBBCodeByUrl($media['url'], $media['preview'], $media['description'] ?? '');
} elseif ($media['type'] == self::AUDIO) {
$body .= "\n[audio]" . $media['url'] . "[/audio]\n";
} elseif ($media['type'] == self::VIDEO) {

View File

@ -34,7 +34,6 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Object\Image;
use Friendica\Util\Images;
use Friendica\Util\Profiler;
use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;
/**
@ -180,7 +179,7 @@ class Upload extends \Friendica\BaseModule
}
$this->logger->info('upload done');
$this->return(200, "\n\n" . '[url=' . $this->baseUrl . '/photos/' . $owner['nickname'] . '/image/' . $resource_id . '][img=' . $this->baseUrl . "/photo/$resource_id-$preview." . $image->getExt() . "][/img][/url]\n\n");
$this->return(200, "\n\n" . Images::getBBCodeByResource($resource_id, $owner['nickname'], $preview, $image->getExt()) . "\n\n");
}
/**

View File

@ -273,9 +273,7 @@ class Photos extends \Friendica\Module\BaseProfile
$arr['visible'] = $visible;
$arr['origin'] = 1;
$arr['body'] = '[url=' . $this->baseUrl . '/photos/' . $this->owner['nickname'] . '/image/' . $resource_id . ']'
. '[img]' . $this->baseUrl . "/photo/{$resource_id}-{$preview}.".$image->getExt() . '[/img]'
. '[/url]';
$arr['body'] = Images::getBBCodeByResource($resource_id, $this->owner['nickname'], $preview, $image->getExt());
$item_id = Item::insert($arr);
// Update the photo albums cache

View File

@ -316,4 +316,40 @@ class Images
return ['width' => $dest_width, 'height' => $dest_height];
}
/**
* Get a BBCode tag for an local photo page URL with a preview thumbnail and an image description
*
* @param string $resource_id
* @param string $nickname The local user owner of the resource
* @param int $preview Preview image size identifier, either 0, 1 or 2 in decreasing order of size
* @param string $ext Image file extension
* @param string $description
* @return string
*/
public static function getBBCodeByResource(string $resource_id, string $nickname, int $preview, string $ext, string $description = ''): string
{
return self::getBBCodeByUrl(
DI::baseUrl() . '/photos/' . $nickname . '/image/' . $resource_id,
DI::baseUrl() . '/photo/' . $resource_id . '-' . $preview. '.' . $ext,
$description
);
}
/**
* Get a BBCode tag for an image URL with a preview thumbnail and an image description
*
* @param string $photo Full image URL
* @param string $preview Preview image URL
* @param string $description
* @return string
*/
public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = ''): string
{
if (!empty($preview)) {
return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]';
}
return '[img=' . $photo . ']' . $description . '[/img]';
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1626,7 +1626,6 @@ $a->strings['Or - did you try to upload an empty file?'] = 'Lub - czy próbował
$a->strings['File exceeds size limit of %s'] = 'Plik przekracza limit rozmiaru wynoszący %s';
$a->strings['File upload failed.'] = 'Przesyłanie pliku nie powiodło się.';
$a->strings['Unable to process image.'] = 'Przetwarzanie obrazu nie powiodło się.';
$a->strings['Image exceeds size limit of %s'] = 'Obraz przekracza limit rozmiaru wynoszący %s';
$a->strings['Image upload failed.'] = 'Przesyłanie obrazu nie powiodło się.';
$a->strings['List of all users'] = 'Lista wszystkich użytkowników';
$a->strings['Active'] = 'Aktywne';
@ -1880,6 +1879,7 @@ $a->strings['No contacts.'] = 'Brak kontaktów.';
$a->strings['%s\'s timeline'] = 'oś czasu %s';
$a->strings['%s\'s posts'] = 'wpisy %s';
$a->strings['%s\'s comments'] = 'komentarze %s';
$a->strings['Image exceeds size limit of %s'] = 'Obraz przekracza limit rozmiaru wynoszący %s';
$a->strings['Image upload didn\'t complete, please try again'] = 'Przesyłanie zdjęć nie zostało zakończone, spróbuj ponownie';
$a->strings['Image file is missing'] = 'Brak pliku obrazu';
$a->strings['Server can\'t accept new file upload at this time, please contact your administrator'] = 'Serwer nie może teraz przyjąć nowego pliku, skontaktuj się z administratorem';