From 1f14870b384e1a8562465e97664ac980595deea5 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 14 Jun 2017 15:35:35 -0400 Subject: [PATCH] updates, fix merge problems --- web/skins/classic/views/monitor.php | 604 ++++++++++++++-------------- 1 file changed, 300 insertions(+), 304 deletions(-) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 1d54b375a..6c7b31016 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -52,7 +52,7 @@ if ( ! $Server ) { } if ( ! empty($_REQUEST['mid']) ) { - $monitor = dbFetchMonitor( $_REQUEST['mid'] ); + $monitor = new Monitor( $_REQUEST['mid'] ); if ( ZM_OPT_X10 ) $x10Monitor = dbFetchOne( 'SELECT * FROM TriggersX10 WHERE MonitorId = ?', NULL, array($_REQUEST['mid']) ); } else { @@ -155,29 +155,32 @@ function fourcc( $a, $b, $c, $d ) { } if ( isset( $_REQUEST['newMonitor'] ) ) { - $newMonitor = $_REQUEST['newMonitor']; + # Update the monitor object with whatever has been set so far. + $monitor->set( $_REQUEST['newMonitor'] ); + if ( ZM_OPT_X10 ) $newX10Monitor = $_REQUEST['newX10Monitor']; } else { - $newMonitor = $monitor; - $newMonitor['Triggers'] = explode( ',', isset($monitor['Triggers'])?$monitor['Triggers']:"" ); + # FIXME: Triggers in the db is a comma separated string. Needs to be an array. + #$monitor->Triggers()= explode( ',', isset($monitor->Triggers())?$monitor->Triggers:"" ); if ( ZM_OPT_X10 ) $newX10Monitor = $x10Monitor; } # What if it has less zeros? This is not robust code. -if ( $monitor->AnalysisFPS == '0.00' ) - $monitor->AnalysisFPS = ''; -if ( $monitor->MaxFPS == '0.00' ) - $monitor->MaxFPS = ''; -if ( $monitor->AlarmMaxFPS == '0.00' ) - $monitor->AlarmMaxFPS = ''; +if ( $monitor->AnalysisFPS() == '0.00' ) + $monitor->AnalysisFPS( '' ); +if ( $monitor->MaxFPS() == '0.00' ) + $monitor->MaxFPS( '' ); +if ( $monitor->AlarmMaxFPS() == '0.00' ) + $monitor->AlarmMaxFPS( '' ); if ( !empty($_REQUEST['preset']) ) { $preset = dbFetchOne( 'SELECT Type, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Palette, MaxFPS, Controllable, ControlId, ControlDevice, ControlAddress, DefaultRate, DefaultScale FROM MonitorPresets WHERE Id = ?', NULL, array($_REQUEST['preset']) ); foreach ( $preset as $name=>$value ) { + # Does isset handle NULL's? I don't think this code is correct. if ( isset($value) ) { - $newMonitor[$name] = $value; + $monitor->$name = $value; } } } @@ -185,16 +188,17 @@ if ( !empty($_REQUEST['probe']) ) { $probe = unserialize(base64_decode($_REQUEST['probe'])); foreach ( $probe as $name=>$value ) { if ( isset($value) ) { - $newMonitor[$name] = $value; + # Does isset handle NULL's? I don't think this code is correct. + $monitor->$name = $value; } } - if ( ZM_HAS_V4L && $newMonitor['Type'] == 'Local' ) { - $newMonitor['Palette'] = fourCC( substr($newMonitor['Palette'],0,1), substr($newMonitor['Palette'],1,1), substr($newMonitor['Palette'],2,1), substr($newMonitor['Palette'],3,1) ); - if ( $newMonitor['Format'] == 'PAL' ) - $newMonitor['Format'] = 0x000000ff; - elseif ( $newMonitor['Format'] == 'NTSC' ) - $newMonitor['Format'] = 0x0000b000; - } + if ( ZM_HAS_V4L && $monitor->Type() == 'Local' ) { + $monitor->Palette( fourCC( substr($monitor->Palette,0,1), substr($monitor->Palette,1,1), substr($monitor->Palette,2,1), substr($monitor->Palette,3,1) ) ); + if ( $monitor->Format() == 'PAL' ) + $monitor->Format( 0x000000ff ); + elseif ( $monitor->Format() == 'NTSC' ) + $monitor->Format( 0x0000b000 ); + } } $sourceTypes = array( @@ -235,7 +239,7 @@ $rtspFFMpegMethods = array( 'rtpUni' => 'UDP', 'rtpMulti' => 'UDP Multicast', 'rtpRtspHttp' => 'HTTP Tunnel' -); + ); $httpMethods = array( 'simple' => 'Simple', @@ -263,7 +267,7 @@ if ( ZM_HAS_V4L1 ) { $v4l1MaxChannels = 15; $v4l1DeviceChannels = array(); for ( $i = 0; $i <= $v4l1MaxChannels; $i++ ) - $v4l1DeviceChannels['$i'] = $i; + $v4l1DeviceChannels[$i] = $i; $v4l1LocalPalettes = array( translate('Grey') => 1, @@ -465,7 +469,7 @@ $videowriteropts = array( 'H264 Camera Passthrough' => 2 ); -xhtmlHeaders(__FILE__, translate('Monitor')." - ".validHtmlStr($monitor['Name']) ); +xhtmlHeaders(__FILE__, translate('Monitor')." - ".validHtmlStr($monitor->Name()) ); ?>
@@ -481,20 +485,20 @@ if ( canEdit( 'Monitors' ) ) { } ?>
- + - + - +
-

- Name) ?>Id) ) { ?> (Id ?>)

+

- Name()) ?>Id()) ) { ?> (Id()?>)

- + ?>
- - - + + + - + - - - - - - - - + + + + + + + + Triggers) ) { - foreach( explode( ',', isset($monitor->Triggers)?$monitor->Triggers:"" ) as $newTrigger ) { + if ( null !== $monitor->Triggers() ) { + foreach( explode( ',', $monitor->Triggers() ) as $newTrigger ) { ?> Type != 'Local') ) { +if ( ZM_HAS_V4L && ($tab != 'source' || $monitor->Type()!= 'Local') ) { ?> - - - - - - + + + + + + Type != 'Remote' ) { +if ( $tab != 'source' || $monitor->Type()!= 'Remote' ) { ?> - - + + Type != 'Local' && $monitor->Type != 'Remote' && $monitor->Type != 'Ffmpeg' && $monitor->Type != 'Libvlc') ) { +if ( $tab != 'source' || ($monitor->Type()!= 'Local' && $monitor->Type()!= 'Remote' && $monitor->Type()!= 'Ffmpeg' && $monitor->Type()!= 'Libvlc') ) { ?> - + Type != 'Ffmpeg' && $monitor->Type != 'Libvlc' )) { +if ( $tab != 'source' || ($monitor->Type()!= 'Ffmpeg' && $monitor->Type()!= 'Libvlc' )) { ?> - + Type != 'Remote' && $monitor->Type != 'File' && $monitor->Type != 'Ffmpeg' && $monitor->Type != 'Libvlc' && $monitor->Type != 'cURL') ) { +if ( $tab != 'source' || ($monitor->Type()!= 'Remote' && $monitor->Type()!= 'File' && $monitor->Type()!= 'Ffmpeg' && $monitor->Type()!= 'Libvlc' && $monitor->Type()!= 'cURL') ) { ?> - - - + + + - - - - - + + + + + - - - - + + + + Type != 'Remote' && $monitor->Protocol != 'rtsp') ) { +if ( $tab != 'source' || ($monitor->Type()!= 'Remote' && $monitor->Protocol()!= 'rtsp') ) { ?> - + - - - - + + + + - - - - - - + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + Type != 'Local') ) { +if ( ZM_HAS_V4L && ($tab != 'misc' || $monitor->Type()!= 'Local') ) { ?> - + @@ -670,77 +669,82 @@ switch ( $tab ) { case 'general' : { ?> - + - + - - + + - - Type() != 'Local' && $monitor->Type() != 'File' ) { ?> + +Type() != 'Local' && $monitor->Type() != 'File' ) { +?> - + - + - - - - + + + + @@ -756,8 +760,8 @@ switch ( $tab ) { - - + + @@ -773,7 +777,7 @@ switch ( $tab ) { if ( $optCount && ($optCount%$breakCount == 0) ) echo '
'; ?> - checked="checked"/>  + Triggers() ) && in_array( $optTrigger, $monitor->Triggers() ) ) { ?> checked="checked"/> Type == 'Local' ) { - ?> - + if ( ZM_HAS_V4L && $monitor->Type() == 'Local' ) { +?> + - Method == 'v4l1' ) { ?> - - - - - - - - +Method() == 'v4l1' ) { +?> + + + + + + + + - - Type == "Remote" ) { ?> + +Type() == 'Remote' ) { +?> - Protocol) || $monitor->Protocol == "http" ) { ?> - - - - - - - - Type == 'File' ) { ?> - - Type == 'cURL' ) { ?> - - - - Type == 'Ffmpeg' || $monitor->Type == 'Libvlc' ) { ?> - +Protocol()) || $monitor->Protocol() == 'http' ) { +?> + + + + + + + +Type() == 'File' ) { +?> + +Type() == 'cURL' ) { +?> + + + +Type() == 'Ffmpeg' || $monitor->Type() == 'Libvlc' ) { +?> + - - - - - + + + + + - - Type == 'Local' ) { - ?> - + +Type() == 'Local' ) { +?> + - - - + Type == 'Remote' ) { + if ( $monitor->Type() == 'Remote' ) { ?> - Protocol != 'rtsp' ) { echo ' style="display:none;"'; } ?>> - - - - - - - - - - - - - - - - - - - - - - - - - - > + Protocol()!= 'rtsp' ) { echo ' style="display:none;"'; } ?>> - - - - + + + + - - - - + + + + - - - - - - + + + + + + - + - - - - + + + + translate('None'), @@ -947,9 +928,9 @@ switch ( $tab ) { '1' => translate('Preset')." 1", ); ?> - + - + - - - - - - +?> + + + + + + +Controllable()) ) + continue; +?> + + + - Type == 'Local' ) { - ?> - - - - - Type() == 'Local' ) { +?> + + + + + + + + + + + + + +
'None'); - $result = dbQuery( 'SELECT * FROM Servers ORDER BY Name'); - $results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server' ); - foreach ( $results as $row => $server_obj ) { - $servers[$server_obj->Id()] = $server_obj->Name(); - } - echo htmlSelect( "newMonitor[ServerId]", $servers, $monitor->ServerId() ); + $servers = array(''=>'None'); + $result = dbQuery( 'SELECT * FROM Servers ORDER BY Name'); + $results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server' ); + foreach ( $results as $row => $server_obj ) { + $servers[$server_obj->Id()] = $server_obj->Name(); + } + echo htmlSelect( 'newMonitor[ServerId]', $servers, $monitor->ServerId() ); ?>
'Default'); - $result = dbQuery( 'SELECT * FROM Storage ORDER BY Name'); - $results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Storage' ); - foreach ( $results as $row => $storage_obj ) { - $storage_areas[$storage_obj->Id] = $storage_obj->Name(); - } - echo htmlSelect( 'newMonitor[StorageId]', $storage_areas, $monitor->StorageId() ); + $storage_areas = array(0=>'Default'); + $result = dbQuery( 'SELECT * FROM Storage ORDER BY Name'); + $results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Storage' ); + foreach ( $results as $row => $storage_obj ) { + $storage_areas[$storage_obj->Id] = $storage_obj->Name(); + } + echo htmlSelect( 'newMonitor[StorageId]', $storage_areas, $monitor->StorageId() ); ?>
Type() ); ?>
Enabled) ) { ?> checked="checked"/>
Enabled()) ) { ?> checked="checked"/>
- - + +
 ()
 ()
Method(), "submitTab( '$tab' );" ); ?>
- V4LMultiBuffer == 1 ? 'checked="checked"' : '' ) ?>/> - - V4LMultiBuffer == 0 ? 'checked="checked"' : '' ) ?>/> - - V4LMultiBuffer) ? 'checked="checked"' : '' ) ?>/> - + V4LMultiBuffer() == 1 ? 'checked="checked"' : '' ) ?>/> + + V4LMultiBuffer() == 0 ? 'checked="checked"' : '' ) ?>/> + + V4LMultiBuffer()) ? 'checked="checked"' : '' ) ?>/> +
Protocol(), "updateMethods( this );if(this.value=='rtsp'){\$('RTSPDescribe').setStyle('display','table-row');}else{\$('RTSPDescribe').hide();}" ); ?>
Method() ); ?>
Method() ); ?>
Method() ); ?>
Method() ); ?>
 ()Method() ); ?>
 (Type), 'zmOptionHelp', 'optionhelp', '?' ) ?>)
()
()
 (Type()), 'zmOptionHelp', 'optionhelp', '?' ) ?>)
()
()
 () RTSPDescribe) ) { ?> checked="checked"/>
 ()
 ()
()
()
 () RTSPDescribe()) ) { ?> checked="checked"/>
checked="checked"/>
RecordAudio()) ) { ?> checked="checked"/>
checked="checked"/>
Controllable()) ) { ?> checked="checked"/>
 
checked="checked"/>
TrackMotion()) ) { ?> checked="checked"/>
DefaultRate() ); ?>
DefaultScale() ); ?>
    
    
 () Exif) ) { ?> checked="checked"/>
+ +      +
+ +      +
 () Exif()) ) { ?> checked="checked"/>