Fixed problems with upload images and show images in created visual consoles. Gitlab: #314

This commit is contained in:
m-lopez-f 2017-02-20 13:54:34 +01:00
parent 3ffe8ae49f
commit ca8ec686ac
2 changed files with 59 additions and 41 deletions

View File

@ -95,12 +95,26 @@ if (defined('METACONSOLE')) {
$table->align[1] = 'left';
}
$table->class = 'databox filters';
$table->size[0] = '20%';
$table->size[1] = '20%';
$table->size[1] = '50%';
$table->data = array ();
$table->data[0][0] = __('Name:') .
ui_print_help_tip(__("Use [ or ( as first character, for example '[*] Map name', to render this map name in main menu"), true);
$table->data[0][1] = html_print_input_text('name', $visualConsoleName,
'', 80, 100, true);
$table->rowspan[0][2] = 6;
if ($action == 'new') {
$table->data[0][2] = '<img id="imagen" style="display:none;"
src="">';
}
else {
$table->data[0][2] = '<img id="imagen" style="width:230px;"
src="images/console/background/'.$background.'">';
}
$table->data[1][0] = __('Group:');
$groups = users_get_groups ($config['id_user'], 'RW');
@ -150,16 +164,6 @@ $table->data[5][1] .= '<span class="opt" style="visibility:hidden;">
value="modsize">' . __('Set default size') .
'</button></span>';
if ($action == 'new') {
$table->data[5][2] = '<img id="imagen" style="display:none"
src="">';
}
else {
$table->data[5][2] = '<img id="imagen" style="display:none"
src="images/console/background/'.$background.'">';
}
$table->data[0][3] = $table->data[0][4] = $table->data[0][5] = '';
if ($action == 'new') {
$textButtonSubmit = __('Save');
$classButtonSubmit = 'sub wand';
@ -185,46 +189,60 @@ echo "</form>";
$(document).ready (function () {
$("#modsize").click(function(event){
event.preventDefault();
$("#modsize").click(function(event){
event.preventDefault();
if($('.opt').css('visibility') == 'hidden'){
$('.opt').css('visibility','visible');
}
if ($('#imagen').attr('src') != '') {
$('input[name=width]').val($('#imagen').width());
$('input[name=height]').val($('#imagen').height());
}
});
$("#getsize").click(function(event){
event.preventDefault();
$('input[name=width]').val($('#imagen').width());
$('input[name=height]').val($('#imagen').height());
});
});
$("#getsize").click(function(event){
event.preventDefault();
$("#background").change(function() {
$('#imagen').attr('src','images/console/background/'+$('#background').val());
$('#imagen').width(230);
$('#imagen').show();
});
$( "input[type=submit]" ).click(function( event ) {
if($( "#getsize" ).css('visibility')=='hidden'){
$('input[name=width]').val($('#imagen').width());
$('input[name=height]').val($('#imagen').height());
}
});
$("#file-background_image").change(function(){
readURL(this);
});
$('input[name=width]').val($('#imagen').width());
$('input[name=height]').val($('#imagen').height());
});
$("#background").click(function(event){
$('#imagen').attr('src','images/console/background/'+$('#background').val());
});
$( "input[type=submit]" ).click(function( event ) {
if($( "#getsize" ).css('visibility')=='hidden'){
$('input[name=width]').val($('#imagen').width());
$('input[name=height]').val($('#imagen').height());
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#imagen').attr('src', e.target.result);
$('#imagen').width(230);
$('#imagen').show();
}
reader.readAsDataURL(input.files[0]);
}
}
});
$("#file-background_image").change(function(event){
$('#back').submit();
});
$("#text-background_color").attachColorPicker();
$("#imgInp").change(function(){
readURL(this);
});
$("#text-background_color").attachColorPicker();
});

View File

@ -174,7 +174,7 @@ switch ($activeTab) {
if ($uploadOK == 1) {
if (move_uploaded_file($_FILES["background_image"]["tmp_name"], $target_file)) {
$background = $_FILES["background_image"]["name"];
$background = $nameImage;
$values['background'] = $background;
$error2 = chmod($target_file, 0644);
$uploadOK = $error2;