fix getting bytes from shorthand in php

This commit is contained in:
Jakobus Schürz 2023-03-14 16:35:18 +01:00
parent 721c065a44
commit 39f7660a1d
10 changed files with 36 additions and 56 deletions

View File

@ -1141,9 +1141,7 @@ function photos_content(App $a)
'$qcomment' => $qcomment, '$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12), '$rand_num' => Crypto::randomDigits(12),
// Dropzone // Dropzone
//'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); '$max_imagesize' => floor(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000),
// Strings::getBytresFromShorthand not working, so just workaround in template and serve the bare value
'$max_imagesize' => DI::config()->get('system', 'maximagesize'),
]); ]);
} }
} }
@ -1200,9 +1198,7 @@ function photos_content(App $a)
'$qcomment' => $qcomment, '$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12), '$rand_num' => Crypto::randomDigits(12),
// Dropzone // Dropzone
//'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); '$max_imagesize' => floor(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000),
// Strings::getBytresFromShorthand not working, so just workaround in template and serve the bare value
'$max_imagesize' => DI::config()->get('system', 'maximagesize'),
]); ]);
} }
@ -1278,9 +1274,7 @@ function photos_content(App $a)
'$qcomment' => $qcomment, '$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12), '$rand_num' => Crypto::randomDigits(12),
// Dropzone // Dropzone
//'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); '$max_imagesize' => floor(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000),
// Strings::getBytresFromShorthand not working, so just workaround in template and serve the bare value
'$max_imagesize' => DI::config()->get('system', 'maximagesize'),
]); ]);
} }
} }

View File

@ -411,9 +411,7 @@ class Conversation
'$always_open_compose' => $this->pConfig->get($this->session->getLocalUserId(), 'frio', 'always_open_compose', false), '$always_open_compose' => $this->pConfig->get($this->session->getLocalUserId(), 'frio', 'always_open_compose', false),
// Dropzone // Dropzone
//'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); '$max_imagesize' => floor(\Friendica\Util\Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000),
// Strings::getBytresFromShorthand not working, so just workaround in template and serve the bare value
'$max_imagesize' => DI::config()->get('system', 'maximagesize'),
]); ]);

View File

@ -242,7 +242,7 @@ class Compose extends BaseModule
]), ]),
// Dropzone // Dropzone
'$max_imagesize' => DI::config()->get('system', 'maximagesize') '$max_imagesize' => floor(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000),
]); ]);
} }
} }

View File

@ -184,13 +184,10 @@ class Edit extends BaseModule
'$shortpermset' => $this->t('Permissions'), '$shortpermset' => $this->t('Permissions'),
'$compose_link_title' => $this->t('Open Compose page'), '$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; return $output;
} }

View File

@ -1070,9 +1070,7 @@ class Post
'$indent' => $indent, '$indent' => $indent,
'$rand_num' => Crypto::randomDigits(12), '$rand_num' => Crypto::randomDigits(12),
// Dropzone // Dropzone
//'$max_imagesize' => Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); '$max_imagesize' => floor(\Friendica\Util\Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000),
// Strings::getBytresFromShorthand not working, so just workaround in template and serve the bare value
'$max_imagesize' => DI::config()->get('system', 'maximagesize'),
]); ]);
} }

View File

@ -96,29 +96,27 @@
</div> </div>
</div> </div>
<script> <script>
// getMByte() is from view/theme/frio/js/dropzone-frio.js
// to workaround dysfunctional php Strings:getBytesFromShorthand
Dropzone.autoDiscover = false; Dropzone.autoDiscover = false;
var dropzoneCompose = new Dropzone( '#dropzone-{{$id}}', { var dropzoneCompose = new Dropzone( '#dropzone-{{$id}}', {
paramName: "userfile", // The name that will be used to transfer the file paramName: 'userfile', // The name that will be used to transfer the file
maxFilesize: getMBytes('{{$max_imagesize}}'), // MB maxFilesize: {{$max_imagesize}}, // MB
url: "/media/photo/upload?response=url&album=", url: '/media/photo/upload?response=url&album=',
accept: function(file, done) { accept: function(file, done) {
done(); done();
}, },
init: function() { init: function() {
this.on("success", function(file, serverResponse) { this.on('success', function(file, serverResponse) {
var target = $('#comment-edit-text-{{$id}}') var target = $('#comment-edit-text-{{$id}}')
var resp = $(serverResponse).find('div#content').text() var resp = $(serverResponse).find('div#content').text()
if (target.setRangeText) { if (target.setRangeText) {
//if setRangeText function is supported by current browser //if setRangeText function is supported by current browser
target.setRangeText(" " + $.trim(resp) + " ") target.setRangeText(' ' + $.trim(resp) + ' ')
} else { } else {
target.focus() 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. // Remove just uploaded file from dropzone, makes interface more clear.
// Image can be seen in posting-preview // Image can be seen in posting-preview
// We need preview to get optical feedback about upload-progress. // We need preview to get optical feedback about upload-progress.

View File

@ -294,25 +294,25 @@ function editpost(url) {
// To make dropzone fileupload work on editing a comment, we need to // To make dropzone fileupload work on editing a comment, we need to
// attach a new dropzone to modal // attach a new dropzone to modal
dropzoneJotEdit = new Dropzone( '#jot-text-wrap', { dropzoneJotEdit = new Dropzone( '#jot-text-wrap', {
paramName: "userfile", // The name that will be used to transfer the file paramName: 'userfile', // The name that will be used to transfer the file
maxFilesize: getMBytes('{{$max_imagesize}}'), // MB maxFilesize: '{{$max_imagesize}}', // MB
url: "/media/photo/upload?response=url&album=", url: '/media/photo/upload?response=url&album=',
accept: function(file, done) { accept: function(file, done) {
done(); done();
}, },
init: function() { init: function() {
this.on("success", function(file, serverResponse) { this.on('success', function(file, serverResponse) {
var target = $('#profile-jot-text') var target = $('#profile-jot-text')
var resp = $(serverResponse).find('div#content').text() var resp = $(serverResponse).find('div#content').text()
if (target.setRangeText) { if (target.setRangeText) {
//if setRangeText function is supported by current browser //if setRangeText function is supported by current browser
target.setRangeText(" " + $.trim(resp) + " ") target.setRangeText(' ' + $.trim(resp) + ' ')
} else { } else {
target.focus() 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. // Remove just uploaded file from dropzone, makes interface more clear.
// Image can be seen in posting-preview // Image can be seen in posting-preview
// We need preview to get optical feedback about upload-progress. // We need preview to get optical feedback about upload-progress.

View File

@ -66,29 +66,27 @@
</div> </div>
<script> <script>
// getMByte() is from view/theme/frio/js/dropzone-frio.js
// to workaround dysfunctional php Strings:getBytesFromShorthand
Dropzone.autoDiscover = false; Dropzone.autoDiscover = false;
var dropzone{{$id}} = new Dropzone( '#dropzone-{{$id}}', { var dropzone{{$id}} = new Dropzone( '#dropzone-{{$id}}', {
paramName: "userfile", // The name that will be used to transfer the file paramName: 'userfile', // The name that will be used to transfer the file
maxFilesize: getMBytes('{{$max_imagesize}}'), // MB maxFilesize: {{$max_imagesize}}, // MB
url: "/media/photo/upload?response=url&album=", url: '/media/photo/upload?response=url&album=',
accept: function(file, done) { accept: function(file, done) {
done(); done();
}, },
init: function() { init: function() {
this.on("success", function(file, serverResponse) { this.on('success', function(file, serverResponse) {
var target = $('#comment-edit-text-{{$id}}') var target = $('#comment-edit-text-{{$id}}')
var resp = $(serverResponse).find('div#content').text() var resp = $(serverResponse).find('div#content').text()
if (target.setRangeText) { if (target.setRangeText) {
//if setRangeText function is supported by current browser //if setRangeText function is supported by current browser
target.setRangeText(" " + $.trim(resp) + " ") target.setRangeText(' ' + $.trim(resp) + ' ')
} else { } else {
target.focus() 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. // Remove just uploaded file from dropzone, makes interface more clear.
// Image can be seen in posting-preview // Image can be seen in posting-preview
// We need preview to get optical feedback about upload-progress. // We need preview to get optical feedback about upload-progress.

View File

@ -140,7 +140,6 @@
{{/if}} {{/if}}
<script type="text/javascript" src="view/theme/frio/js/textedit.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script> <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="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) {{* 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 *}} They are loaded into the html <head> so that js functions can use them *}}

View File

@ -182,29 +182,27 @@ can load different content into the jot modal (e.g. the item edit jot)
</script> </script>
<script> <script>
// getMByte() is from view/theme/frio/js/dropzone-frio.js
// to workaround dysfunctional php Strings:getBytesFromShorthand
Dropzone.autoDiscover = false; Dropzone.autoDiscover = false;
var dropzoneJot = new Dropzone( '#jot-text-wrap', { var dropzoneJot = new Dropzone( '#jot-text-wrap', {
paramName: "userfile", // The name that will be used to transfer the file paramName: 'userfile', // The name that will be used to transfer the file
maxFilesize: getMBytes('{{$max_imagesize}}'), // MB maxFilesize: {{$max_imagesize}}, // MB
url: "/media/photo/upload?response=url&album=", url: '/media/photo/upload?response=url&album=',
accept: function(file, done) { accept: function(file, done) {
done(); done();
}, },
init: function() { init: function() {
this.on("success", function(file, serverResponse) { this.on('success', function(file, serverResponse) {
var target = $('#profile-jot-text') var target = $('#profile-jot-text')
var resp = $(serverResponse).find('div#content').text() var resp = $(serverResponse).find('div#content').text()
if (target.setRangeText) { if (target.setRangeText) {
//if setRangeText function is supported by current browser //if setRangeText function is supported by current browser
target.setRangeText(" " + $.trim(resp) + " ") target.setRangeText(' ' + $.trim(resp) + ' ')
} else { } else {
target.focus() 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. // Remove just uploaded file from dropzone, makes interface more clear.
// Image can be seen in posting-preview // Image can be seen in posting-preview
// We need preview to get optical feedback about upload-progress. // We need preview to get optical feedback about upload-progress.