From: Jakobus Schürz Date: Wed, 15 Mar 2023 20:48:17 +0000 (+0100) Subject: render max_imagesize in header.tpl X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=920dcca263edb51088381b7077ff336222e10bd9;p=friendica.git render max_imagesize in header.tpl so it is reachable general from the whole website, and the dropzone-factory can use it also to create dropzones from modal.js --- diff --git a/mod/photos.php b/mod/photos.php index 5b225489ec..a08b569ced 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1139,8 +1139,6 @@ function photos_content(App $a) '$loading' => DI::l10n()->t('Loading...'), '$qcomment' => $qcomment, '$rand_num' => Crypto::randomDigits(12), - // Dropzone - '$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000, 1), ]); } } @@ -1196,8 +1194,6 @@ function photos_content(App $a) '$preview' => DI::l10n()->t('Preview'), '$qcomment' => $qcomment, '$rand_num' => Crypto::randomDigits(12), - // Dropzone - '$max_imagesize' => round(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000, 1), ]); } @@ -1272,8 +1268,6 @@ function photos_content(App $a) '$preview' => DI::l10n()->t('Preview'), '$qcomment' => $qcomment, '$rand_num' => Crypto::randomDigits(12), - // Dropzone - '$max_imagesize' => round(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000, 1), ]); } } diff --git a/src/App/Page.php b/src/App/Page.php index 965c04915c..45ec6be0fb 100644 --- a/src/App/Page.php +++ b/src/App/Page.php @@ -253,11 +253,15 @@ class Page implements ArrayAccess '$touch_icon' => $touch_icon, '$block_public' => intval($config->get('system', 'block_public')), '$stylesheets' => $this->stylesheets, - '$likeError' => $l10n->t('Like not successfull'), - '$dislikeError' => $l10n->t('Dislike not successfull'), - '$announceError' => $l10n->t('Sharing not successfull'), - '$srvError' => $l10n->t('Backend error'), - '$netError' => $l10n->t('Network error'), + '$likeError' => $l10n->t('Like not successfull'), + '$dislikeError' => $l10n->t('Dislike not successfull'), + '$announceError' => $l10n->t('Sharing not successfull'), + '$srvError' => $l10n->t('Backend error'), + '$netError' => $l10n->t('Network error'), + // Dropzone + '$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand($config->get('system', 'maximagesize')) / 1000000, 1), + + ]) . $this->page['htmlhead']; } diff --git a/src/Content/Conversation.php b/src/Content/Conversation.php index 1d7430e193..f23333911b 100644 --- a/src/Content/Conversation.php +++ b/src/Content/Conversation.php @@ -409,9 +409,6 @@ class Conversation '$compose_link_title' => $this->l10n->t('Open Compose page'), '$always_open_compose' => $this->pConfig->get($this->session->getLocalUserId(), 'frio', 'always_open_compose', false), - // Dropzone - '$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand($this->config->get('system', 'maximagesize')) / 1000000, 1), - ]); diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index 19726eb717..f53158b1f7 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -240,9 +240,6 @@ class Compose extends BaseModule 'deny_cid' => $contact_deny_list, 'deny_gid' => $group_deny_list, ]), - - // Dropzone - '$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand($this->config->get('system', 'maximagesize')) / 1000000, 1), ]); } } diff --git a/src/Module/Post/Edit.php b/src/Module/Post/Edit.php index 403908cc02..5ddc250d8c 100644 --- a/src/Module/Post/Edit.php +++ b/src/Module/Post/Edit.php @@ -185,8 +185,6 @@ class Edit extends BaseModule '$compose_link_title' => $this->t('Open Compose page'), - // Dropzone - '$max_imagesize' => round(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000,1), ]); return $output; } diff --git a/src/Object/Post.php b/src/Object/Post.php index c6ef5e3ba1..3f4d061a17 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -1069,8 +1069,6 @@ class Post '$preview' => DI::l10n()->t('Preview'), '$indent' => $indent, '$rand_num' => Crypto::randomDigits(12), - // Dropzone - '$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000,1), ]); } diff --git a/view/js/dropzone-factory.js b/view/js/dropzone-factory.js index 5aaab50362..bbf92625d8 100644 --- a/view/js/dropzone-factory.js +++ b/view/js/dropzone-factory.js @@ -1,8 +1,8 @@ var DzFactory = function () { - this.createDropzone = function(dropSelector, textareaSelector, maxImagesize) { + this.createDropzone = function(dropSelector, textareaSelector) { return new Dropzone( dropSelector, { paramName: 'userfile', // The name that will be used to transfer the file - maxFilesize: maxImagesize, // MB + maxFilesize: max_imagesize, // MB url: '/media/photo/upload?response=url&album=', accept: function(file, done) { done(); @@ -52,8 +52,8 @@ var DzFactory = function () { }) }; - this.setupDropzone = function(dropSelector, textareaSelector, maxImagesize) { - var dropzone = this.createDropzone(dropSelector, textareaSelector, maxImagesize); + this.setupDropzone = function(dropSelector, textareaSelector) { + var dropzone = this.createDropzone(dropSelector, textareaSelector); $(dropSelector).on('paste', function(event) { dzFactory.copyPaste(event, dropzone); }) diff --git a/view/templates/item/compose.tpl b/view/templates/item/compose.tpl index 499dfaffb2..09e42c90e5 100644 --- a/view/templates/item/compose.tpl +++ b/view/templates/item/compose.tpl @@ -96,5 +96,5 @@ diff --git a/view/theme/frio/js/dropzone-frio.js b/view/theme/frio/js/dropzone-frio.js deleted file mode 100644 index c165633c44..0000000000 --- a/view/theme/frio/js/dropzone-frio.js +++ /dev/null @@ -1,24 +0,0 @@ -function isInteger(value) { - return /^\d+$/.test(value); -} - -function getMBytes(value) { - var res; - if (isInteger(value)) { - res = value; - } else { - eh = value.slice(-1); - am = Number(value.slice(0, -1)); - switch (eh) { - case 'k': - res = am * 1024; - break; - case 'm': - res = am * 1024 * 1024; - break; - case 'g': - res = am * 1024 * 1024 * 1024; - } - } - return res / 1000000; -} diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index 85c258c92f..905e787434 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -293,8 +293,7 @@ function editpost(url) { // To make dropzone fileupload work on editing a comment, we need to // attach a new dropzone to modal - console.log("modal.js max_imagesize",'{{$max_imagesize}}'); - dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text', '{{$max_imagesize}}'); + dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text'); modal.show(); $("#jot-popup").show(); diff --git a/view/theme/frio/templates/comment_item.tpl b/view/theme/frio/templates/comment_item.tpl index 3d9860a104..81664cf0fe 100644 --- a/view/theme/frio/templates/comment_item.tpl +++ b/view/theme/frio/templates/comment_item.tpl @@ -67,12 +67,12 @@ - + {{* 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 325c8d5b3b..5c18afa86f 100644 --- a/view/theme/frio/templates/jot.tpl +++ b/view/theme/frio/templates/jot.tpl @@ -180,5 +180,5 @@ can load different content into the jot modal (e.g. the item edit jot)