]> git.mxchange.org Git - friendica.git/commitdiff
fix getting bytes from shorthand in php
authorJakobus Schürz <jakobus.schuerz@schuerz.at>
Tue, 14 Mar 2023 15:35:18 +0000 (16:35 +0100)
committerJakobus Schürz <jakobus.schuerz@schuerz.at>
Sun, 19 Mar 2023 17:52:45 +0000 (18:52 +0100)
mod/photos.php
src/Content/Conversation.php
src/Module/Item/Compose.php
src/Module/Post/Edit.php
src/Object/Post.php
view/templates/item/compose.tpl
view/theme/frio/js/modal.js
view/theme/frio/templates/comment_item.tpl
view/theme/frio/templates/head.tpl
view/theme/frio/templates/jot.tpl

index 97c0fb22e6106e981ba6b2dd5dc5a93d44375b02..d7d806bfc2f97eb1ff301165222393d2b984cc0c 100644 (file)
@@ -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),
                                                ]);
                                        }
                                }
index 8460f942326d8efc1d06c8dfac522ef3d470d5a9..b0fd60ae3c59629f82fdf9082ab86b229f47d53e 100644 (file)
@@ -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),
 
                ]);
 
index 30e2aa9d6b897399eecd68916fd0e688f434c22b..d1744b9d72d5ac8137f064cafbbb1f83c19105eb 100644 (file)
@@ -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),
                ]);
        }
 }
index 3e47889b219e34bff58a11dedba0b431af058310..e28d54c9b2ce22343822e70a7cd4144c7ed9dd91 100644 (file)
@@ -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'),
+                       '$max_imagesize'       => floor(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000),
                ]);
-
                return $output;
        }
 
index 9e569c6a161634db39453ffd81b7bbeb83b5c68c..5fa9dfcf6fb78ea40abf2ac6e91d1141eec9ce30 100644 (file)
@@ -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),
                        ]);
                }
 
index 581e8d29fd71563e426a4d951c3dfe087d138b54..88a19ac97807f7c510ad52792f5b5dc9517e53cd 100644 (file)
        </div>
 </div>
 <script>
-       // getMByte() is from view/theme/frio/js/dropzone-frio.js
-       // to workaround dysfunctional php Strings:getBytesFromShorthand
        Dropzone.autoDiscover = false;
        var dropzoneCompose = new Dropzone( '#dropzone-{{$id}}',  { 
-               paramName: "userfile", // The name that will be used to transfer the file
-               maxFilesize: getMBytes('{{$max_imagesize}}'), // MB
-               url: "/media/photo/upload?response=url&album=",
+               paramName: 'userfile', // The name that will be used to transfer the file
+               maxFilesize: {{$max_imagesize}}, // MB
+               url: '/media/photo/upload?response=url&album=',
                accept: function(file, done) {
                        done();
                },
                init: function() {
-                       this.on("success", function(file, serverResponse) {
+                       this.on('success', function(file, serverResponse) {
                                var target = $('#comment-edit-text-{{$id}}')
                                var resp = $(serverResponse).find('div#content').text()
                                if (target.setRangeText) {
                                        //if setRangeText function is supported by current browser
-                                       target.setRangeText(" " + $.trim(resp) + " ")
+                                       target.setRangeText(' ' + $.trim(resp) + ' ')
                                } else {
                                        target.focus()
                                        document.execCommand('insertText', false /*no UI*/, $.trim(resp));
                                }
                        });
-                       this.on("complete", function(file) {
+                       this.on('complete', function(file) {
                                // Remove just uploaded file from dropzone, makes interface more clear.
                                // Image can be seen in posting-preview
                                // We need preview to get optical feedback about upload-progress.
index a20862e7517f31a3b0062b2dcfe07b8f91cf2226..705f472c431a3adf7cdccea5f1db4d7c96d0a2dc 100644 (file)
@@ -294,25 +294,25 @@ function editpost(url) {
                        // To make dropzone fileupload work on editing a comment, we need to
                        // attach a new dropzone to modal
                        dropzoneJotEdit = new Dropzone( '#jot-text-wrap', {
-                               paramName: "userfile", // The name that will be used to transfer the file
-                               maxFilesize: getMBytes('{{$max_imagesize}}'), // MB
-                               url: "/media/photo/upload?response=url&album=",
+                               paramName: 'userfile', // The name that will be used to transfer the file
+                               maxFilesize: '{{$max_imagesize}}', // MB
+                               url: '/media/photo/upload?response=url&album=',
                                accept: function(file, done) {
                                        done();
                                },
                                init: function() {
-                                       this.on("success", function(file, serverResponse) {
+                                       this.on('success', function(file, serverResponse) {
                                                var target = $('#profile-jot-text')
                                                var resp = $(serverResponse).find('div#content').text()
                                                if (target.setRangeText) {
                                                        //if setRangeText function is supported by current browser
-                                                       target.setRangeText(" " + $.trim(resp) + " ")
+                                                       target.setRangeText(' ' + $.trim(resp) + ' ')
                                                } else {
                                                        target.focus()
-                                                       document.execCommand('insertText', false /*no UI*/, " " + $.trim(resp) + " ");
+                                                       document.execCommand('insertText', false /*no UI*/, ' ' + $.trim(resp) + ' ');
                                                }
                                        });
-                                       this.on("complete", function(file) {
+                                       this.on('complete', function(file) {
                                                // Remove just uploaded file from dropzone, makes interface more clear.
                                                // Image can be seen in posting-preview
                                                // We need preview to get optical feedback about upload-progress.
index 127612b29c885499ac8474acc1fdb9349165777d..00ca396d11d92ca08cc7f9a5a4d27ae244ed0e24 100644 (file)
 </div>
 
 <script>
-       // getMByte() is from view/theme/frio/js/dropzone-frio.js
-       // to workaround dysfunctional php Strings:getBytesFromShorthand
        Dropzone.autoDiscover = false;
        var dropzone{{$id}} = new Dropzone( '#dropzone-{{$id}}', {
-               paramName: "userfile", // The name that will be used to transfer the file
-               maxFilesize: getMBytes('{{$max_imagesize}}'), // MB
-               url: "/media/photo/upload?response=url&album=",
+               paramName: 'userfile', // The name that will be used to transfer the file
+               maxFilesize: {{$max_imagesize}}, // MB
+               url: '/media/photo/upload?response=url&album=',
                accept: function(file, done) {
                        done();
                },
                init: function() {
-                       this.on("success", function(file, serverResponse) {
+                       this.on('success', function(file, serverResponse) {
                                var target = $('#comment-edit-text-{{$id}}')
                                var resp = $(serverResponse).find('div#content').text()
                                if (target.setRangeText) {
                                        //if setRangeText function is supported by current browser
-                                       target.setRangeText(" " + $.trim(resp) + " ")
+                                       target.setRangeText(' ' + $.trim(resp) + ' ')
                                } else {
                                        target.focus()
-                                       document.execCommand('insertText', false /*no UI*/, " " + $.trim(resp) + " ");
+                                       document.execCommand('insertText', false /*no UI*/, ' ' + $.trim(resp) + ' ');
                                }
                        });
-                       this.on("complete", function(file) {
+                       this.on('complete', function(file) {
                                // Remove just uploaded file from dropzone, makes interface more clear.
                                // Image can be seen in posting-preview
                                // We need preview to get optical feedback about upload-progress.
index e0cd98958395db4a6cae9400ed94672a90474cdf..478f190562bac907b92efc4828ae38c1f1b865cb 100644 (file)
        {{/if}}
        <script type="text/javascript" src="view/theme/frio/js/textedit.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
        <script type="text/javascript" src="vendor/enyo/dropzone/dist/min/dropzone.min.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
-       <script type="text/javascript" src="view/theme/frio/js/dropzone-frio.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
 
        {{* Include the strings which are needed for some js functions (e.g. translation)
 They are loaded into the html <head> so that js functions can use them *}}
index 1ffe7dd3c173132719997aa08a28e142a53bf354..006095302e3340634fc11d9b0dfdf84c97a122d8 100644 (file)
@@ -182,29 +182,27 @@ can load different content into the jot modal (e.g. the item edit jot)
 </script>
 
 <script>
-       // getMByte() is from view/theme/frio/js/dropzone-frio.js
-       // to workaround dysfunctional php Strings:getBytesFromShorthand
        Dropzone.autoDiscover = false;
        var dropzoneJot = new Dropzone( '#jot-text-wrap', {
-               paramName: "userfile", // The name that will be used to transfer the file
-               maxFilesize: getMBytes('{{$max_imagesize}}'), // MB
-               url: "/media/photo/upload?response=url&album=",
+               paramName: 'userfile', // The name that will be used to transfer the file
+               maxFilesize: {{$max_imagesize}}, // MB
+               url: '/media/photo/upload?response=url&album=',
                accept: function(file, done) {
                        done();
                },
                init: function() {
-                       this.on("success", function(file, serverResponse) {
+                       this.on('success', function(file, serverResponse) {
                                var target = $('#profile-jot-text')
                                var resp = $(serverResponse).find('div#content').text()
                                if (target.setRangeText) {
                                        //if setRangeText function is supported by current browser
-                                       target.setRangeText(" " + $.trim(resp) + " ")
+                                       target.setRangeText(' ' + $.trim(resp) + ' ')
                                } else {
                                        target.focus()
-                                       document.execCommand('insertText', false /*no UI*/, " " + $.trim(resp) + " ");
+                                       document.execCommand('insertText', false /*no UI*/, ' ' + $.trim(resp) + ' ');
                                }
                        });
-                       this.on("complete", function(file) {
+                       this.on('complete', function(file) {
                                // Remove just uploaded file from dropzone, makes interface more clear.
                                // Image can be seen in posting-preview
                                // We need preview to get optical feedback about upload-progress.