Browse Source
Merge pull request 'Embed video Live View settings, app type/layout fields, complete translations' (#3) from feature/eve-live-columns into master
master
Merge pull request 'Embed video Live View settings, app type/layout fields, complete translations' (#3) from feature/eve-live-columns into master
master
17 changed files with 548 additions and 133 deletions
-
2lib/1.json
-
2lib/2.json
-
2lib/3.json
-
2lib/4.json
-
2lib/5.json
-
2lib/6.json
-
2lib/7.json
-
9lib/controller/doApplicationOperation.php
-
100lib/controller/doModuleOperation.php
-
32lib/controller/getApplicationSettings.php
-
17lib/controller/getModuleEditor.php
-
244lib/controller/getModuleSettings.php
-
90lib/controller/updateServerModuleSettings.php
-
62lib/controller/uploadAsset.php
-
2lib/defines.php
-
86lib/javascript/jsapi_dynamic/rgoose_modules.js
-
25lib/upgrade_database.php
2
lib/1.json
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
lib/2.json
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
lib/3.json
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
lib/4.json
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
lib/5.json
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
lib/6.json
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
lib/7.json
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,90 @@ |
|||
<?php |
|||
// Saves the settings window of a module (getModuleSettings.php -> saveSettings()).
|
|||
require_once('../ajax_asm.php'); |
|||
if( $CUser->Data['id'] > 1 ){ |
|||
$Data = array(); |
|||
$Data['success'] = false; |
|||
$Data['msg'] = 'Module Not Selected!'; |
|||
$MID = isset( $_POST['MID'] ) ? intval( $_POST['MID'] ) : 0; |
|||
if( $MID > 0 ){ |
|||
$Data['msg'] = 'Module Does Not Exists!'; |
|||
$RR = $DATABASE->Query( "SELECT * FROM `modules` WHERE `id`={$MID}", false ); |
|||
if( count( $RR ) ){ |
|||
$CMD = $RR[0]; |
|||
$AUX = intval( $CMD['aux_id'] ); |
|||
// clamp a numeric POST field to [min,max], $def when it is missing
|
|||
$pInt = function( $Name, $Min, $Max, $Def ){ |
|||
if( !isset( $_POST[$Name] ) || $_POST[$Name] === '' ) return $Def; |
|||
return max( $Min, min( $Max, intval( $_POST[$Name] ) ) ); |
|||
}; |
|||
$pFloat = function( $Name, $Min, $Max, $Def ){ |
|||
if( !isset( $_POST[$Name] ) || $_POST[$Name] === '' ) return $Def; |
|||
return max( $Min, min( $Max, floatval( $_POST[$Name] ) ) ); |
|||
}; |
|||
$pBool = function( $Name ){ |
|||
if( !isset( $_POST[$Name] ) ) return 0; |
|||
$V = strtolower( strval( $_POST[$Name] ) ); |
|||
return ( $V === 'true' || $V === '1' || $V === 'on' ) ? 1 : 0; |
|||
}; |
|||
// OpenCV line types la_mojo accepts (0 and 1 are old values: 8 / 4 connected)
|
|||
$pLine = function( $Name ){ |
|||
$V = isset( $_POST[$Name] ) ? intval( $_POST[$Name] ) : 8; |
|||
return in_array( $V, array( 0, 1, 4, 8, 16 ) ) ? $V : 8; |
|||
}; |
|||
switch( intval( $CMD['type'] ) ){ |
|||
case 8:{ // Embed Video Encoder (module_eve)
|
|||
$SiW = array( 320, 640, 800, 1280, 1024, 1920 ); |
|||
$SiH = array( 240, 480, 600, 720, 768, 1080 ); |
|||
$SIZE = $pInt( 'SIZE', 0, count( $SiW ) - 1, 3 ); |
|||
$W = $SiW[$SIZE]; |
|||
$H = $SiH[$SIZE]; |
|||
$F = array( |
|||
'web_port' => $pInt( 'PORT', 1, 65535, 8972 ), |
|||
'width' => $W, |
|||
'height' => $H, |
|||
'compression_quality' => $pInt( 'COMPRESSION', 0, 100, 70 ), |
|||
'show_ts' => $pBool( 'SHOW1' ), |
|||
'show_label' => $pBool( 'SHOW2' ), |
|||
'show_logo' => $pBool( 'SHOW3' ), |
|||
// positions in pixels, negative values are measured from the right / bottom edge
|
|||
'ts_x' => $pInt( 'TS_POSX', -$W, $W, 5 ), |
|||
'ts_y' => $pInt( 'TS_POSY', -$H, $H, 5 ), |
|||
'ts_transperant' => $pBool( 'TS_TRANS' ), |
|||
'ts_font_face' => $pInt( 'TS_FONT', 0, 7, 1 ), |
|||
'ts_font_scale' => $pFloat( 'TS_FONT_SCALE', 0.1, 4.0, 1.0 ), |
|||
'ts_font_thickness' => $pInt( 'TS_FONT_THICK', 1, 8, 1 ), |
|||
'ts_line_type' => $pLine( 'TS_LINE' ), |
|||
'label_x' => $pInt( 'LBL_POSX', -$W, $W, 5 ), |
|||
'label_y' => $pInt( 'LBL_POSY', -$H, $H, -10 ), |
|||
'label_transperant' => $pBool( 'LBL_TRANS' ), |
|||
'label_font_face' => $pInt( 'LBL_FONT', 0, 7, 1 ), |
|||
'label_font_scale' => $pFloat( 'LBL_FONT_SCALE', 0.1, 4.0, 1.0 ), |
|||
'label_font_thickness' => $pInt( 'LBL_FONT_THICK', 1, 8, 1 ), |
|||
'label_line_type' => $pLine( 'LBL_LINE' ), |
|||
'logo_x' => $pInt( 'LOG_POSX', -$W, $W, 0 ), |
|||
'logo_y' => $pInt( 'LOG_POSY', -$H, $H, 0 ), |
|||
'logo_w' => $pInt( 'LOG_W', 0, $W, 0 ), |
|||
'logo_h' => $pInt( 'LOG_H', 0, $H, 0 ) |
|||
); |
|||
$SET = array(); |
|||
foreach( $F as $K => $V ) $SET[] = "`{$K}`=".( is_float( $V ) ? sprintf( '%.3F', $V ) : intval( $V ) ); |
|||
// exec() reports a failure instead of die() in Query()
|
|||
if( $DATABASE->DBLink->exec( "UPDATE `module_eve` SET ".implode( ', ', $SET )." WHERE `id`={$AUX}" ) ){ |
|||
$Data['success'] = true; |
|||
$Data['msg'] = ''; |
|||
} else { |
|||
$Data['msg'] = 'Unable to save the settings!'; |
|||
}; |
|||
break; |
|||
}; |
|||
default: |
|||
$Data['msg'] = 'Saving the settings of this module type is not supported!'; |
|||
break; |
|||
}; |
|||
}; |
|||
}; |
|||
echo json_encode( $Data ); |
|||
exit(); |
|||
}; |
|||
header( 'location: /'); |
|||
?>
|
|||
@ -0,0 +1,62 @@ |
|||
<?php |
|||
// Asset upload. type=eve_logo, id=<module id>: logo of the Embed Video Encoder.
|
|||
// The picture is stored as an RGBA PNG in data/assets/images/<md5>.png (the path la_mojo
|
|||
// loads, relative to its working folder) and module_eve.logo_md5 is updated.
|
|||
require_once('../ajax_asm.php'); |
|||
if( $CUser->Data['id'] > 1 ){ |
|||
$Data = array(); |
|||
$Data['success'] = false; |
|||
$Data['msg'] = 'Wrong Parameters'; |
|||
$TYPE = isset( $_POST['type'] ) ? strval( $_POST['type'] ) : ''; |
|||
$MID = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : 0; |
|||
if( $TYPE == 'eve_logo' && $MID > 0 ){ |
|||
$RR = $DATABASE->Query( "SELECT * FROM `modules` WHERE `id`={$MID} AND `type`=8", false ); |
|||
if( !count( $RR ) ){ |
|||
$Data['msg'] = 'Module Does Not Exists!'; |
|||
} else if( !isset( $_FILES['file'] ) || $_FILES['file']['error'] != UPLOAD_ERR_OK || !is_uploaded_file( $_FILES['file']['tmp_name'] ) ){ |
|||
$Data['msg'] = 'File upload failed!'; |
|||
} else if( $_FILES['file']['size'] > 4 * 1024 * 1024 ){ |
|||
$Data['msg'] = 'The picture is too big (max 4 MB)!'; |
|||
} else if( !function_exists( 'imagecreatefromstring' ) ){ |
|||
$Data['msg'] = 'PHP GD extension is missing!'; |
|||
} else { |
|||
$IMG = @imagecreatefromstring( file_get_contents( $_FILES['file']['tmp_name'] ) ); |
|||
if( $IMG === false ){ |
|||
$Data['msg'] = 'Unsupported picture format!'; |
|||
} else { |
|||
// normalise to a true colour picture with alpha channel (la_mojo uses alpha as mask)
|
|||
$W = imagesx( $IMG ); |
|||
$H = imagesy( $IMG ); |
|||
$OUT = imagecreatetruecolor( $W, $H ); |
|||
imagealphablending( $OUT, false ); |
|||
imagesavealpha( $OUT, true ); |
|||
imagefill( $OUT, 0, 0, imagecolorallocatealpha( $OUT, 0, 0, 0, 127 ) ); |
|||
imagecopy( $OUT, $IMG, 0, 0, 0, 0, $W, $H ); |
|||
imagedestroy( $IMG ); |
|||
ob_start(); |
|||
imagepng( $OUT ); |
|||
$PNG = ob_get_clean(); |
|||
imagedestroy( $OUT ); |
|||
$MD5 = md5( $PNG ); |
|||
$DIR = __DIR__.'/data/assets/images'; |
|||
if( !is_dir( $DIR ) ) @mkdir( $DIR, 0775, true ); |
|||
if( @file_put_contents( $DIR.'/'.$MD5.'.png', $PNG ) === false ){ |
|||
$Data['msg'] = 'Unable to store the picture!'; |
|||
} else { |
|||
$AUX = intval( $RR[0]['aux_id'] ); |
|||
$DATABASE->DBLink->exec( "UPDATE `module_eve` SET `logo_md5`='{$MD5}' WHERE `id`={$AUX}" ); |
|||
$Data['success'] = true; |
|||
$Data['msg'] = ''; |
|||
$Data['md5'] = $MD5; |
|||
$Data['url'] = '/lib/controller/data/assets/images/'.$MD5.'.png'; |
|||
$Data['width'] = $W; |
|||
$Data['height'] = $H; |
|||
}; |
|||
}; |
|||
}; |
|||
}; |
|||
echo json_encode( $Data ); |
|||
exit(); |
|||
}; |
|||
header( 'location: /'); |
|||
?>
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue