From 39f7660a1dd4684df0f3601deee4ef30392143d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Tue, 14 Mar 2023 16:35:18 +0100 Subject: [PATCH] fix getting bytes from shorthand in php --- mod/photos.php | 12 +++--------- src/Content/Conversation.php | 4 +--- src/Module/Item/Compose.php | 2 +- src/Module/Post/Edit.php | 9 +++------ src/Object/Post.php | 4 +--- view/templates/item/compose.tpl | 14 ++++++-------- view/theme/frio/js/modal.js | 14 +++++++------- view/theme/frio/templates/comment_item.tpl | 16 +++++++--------- view/theme/frio/templates/head.tpl | 1 - view/theme/frio/templates/jot.tpl | 16 +++++++--------- 10 files changed, 36 insertions(+), 56 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index 97c0fb22e6..d7d806bfc2 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1141,9 +1141,7 @@ function photos_content(App $a) '$qcomment' => $qcomment, '$rand_num' => Crypto::randomDigits(12), // Dropzone - //'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - // Strings::getBytresFromShorthand not working, so just workaround in template and serve the bare value - '$max_imagesize' => DI::config()->get('system', 'maximagesize'), + '$max_imagesize' => floor(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000), ]); } } @@ -1200,9 +1198,7 @@ function photos_content(App $a) '$qcomment' => $qcomment, '$rand_num' => Crypto::randomDigits(12), // Dropzone - //'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - // Strings::getBytresFromShorthand not working, so just workaround in template and serve the bare value - '$max_imagesize' => DI::config()->get('system', 'maximagesize'), + '$max_imagesize' => floor(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000), ]); } @@ -1278,9 +1274,7 @@ function photos_content(App $a) '$qcomment' => $qcomment, '$rand_num' => Crypto::randomDigits(12), // Dropzone - //'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - // Strings::getBytresFromShorthand not working, so just workaround in template and serve the bare value - '$max_imagesize' => DI::config()->get('system', 'maximagesize'), + '$max_imagesize' => floor(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000), ]); } } diff --git a/src/Content/Conversation.php b/src/Content/Conversation.php index 8460f94232..b0fd60ae3c 100644 --- a/src/Content/Conversation.php +++ b/src/Content/Conversation.php @@ -411,9 +411,7 @@ class Conversation '$always_open_compose' => $this->pConfig->get($this->session->getLocalUserId(), 'frio', 'always_open_compose', false), // Dropzone - //'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - // Strings::getBytresFromShorthand not working, so just workaround in template and serve the bare value - '$max_imagesize' => DI::config()->get('system', 'maximagesize'), + '$max_imagesize' => floor(\Friendica\Util\Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000), ]); diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index 30e2aa9d6b..d1744b9d72 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -242,7 +242,7 @@ class Compose extends BaseModule ]), // Dropzone - '$max_imagesize' => DI::config()->get('system', 'maximagesize') + '$max_imagesize' => floor(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000), ]); } } diff --git a/src/Module/Post/Edit.php b/src/Module/Post/Edit.php index 3e47889b21..e28d54c9b2 100644 --- a/src/Module/Post/Edit.php +++ b/src/Module/Post/Edit.php @@ -184,13 +184,10 @@ class Edit extends BaseModule '$shortpermset' => $this->t('Permissions'), '$compose_link_title' => $this->t('Open Compose page'), - // Dropzone - //'$max_imagesize' => \Friendica\\Util\\Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - //'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - // both not working, so just workaround in template and serve the bare value - '$max_imagesize' => DI::config()->get('system', 'maximagesize'), - ]); + // Dropzone + '$max_imagesize' => floor(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000), + ]); return $output; } diff --git a/src/Object/Post.php b/src/Object/Post.php index 9e569c6a16..5fa9dfcf6f 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -1070,9 +1070,7 @@ class Post '$indent' => $indent, '$rand_num' => Crypto::randomDigits(12), // Dropzone - //'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); - // Strings::getBytresFromShorthand not working, so just workaround in template and serve the bare value - '$max_imagesize' => DI::config()->get('system', 'maximagesize'), + '$max_imagesize' => floor(\Friendica\Util\Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000), ]); } diff --git a/view/templates/item/compose.tpl b/view/templates/item/compose.tpl index 581e8d29fd..88a19ac978 100644 --- a/view/templates/item/compose.tpl +++ b/view/templates/item/compose.tpl @@ -96,29 +96,27 @@ - {{* Include the strings which are needed for some js functions (e.g. translation) They are loaded into the html so that js functions can use them *}} diff --git a/view/theme/frio/templates/jot.tpl b/view/theme/frio/templates/jot.tpl index 1ffe7dd3c1..006095302e 100644 --- a/view/theme/frio/templates/jot.tpl +++ b/view/theme/frio/templates/jot.tpl @@ -182,29 +182,27 @@ can load different content into the jot modal (e.g. the item edit jot)