Merge ../ZoneMinder.master into server_path_prefix

This commit is contained in:
Isaac Connor 2018-07-09 12:33:58 -04:00
commit 3d1fe728f1
5 changed files with 119 additions and 98 deletions

View File

@ -44,12 +44,12 @@ foreach( $displayMonitors as &$row ) {
if ( isset($_REQUEST['mid']) && $row['Id'] == $_REQUEST['mid'] ) if ( isset($_REQUEST['mid']) && $row['Id'] == $_REQUEST['mid'] )
$monIdx = count($monitors); $monIdx = count($monitors);
$row['ScaledWidth'] = reScale( $row['Width'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $row['ScaledWidth'] = reScale($row['Width'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
$row['ScaledHeight'] = reScale( $row['Height'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $row['ScaledHeight'] = reScale($row['Height'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
$row['PopupScale'] = reScale( SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $row['PopupScale'] = reScale(SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
$row['connKey'] = generateConnKey(); $row['connKey'] = generateConnKey();
$monitors[] = new Monitor( $row ); $monitors[] = new Monitor($row);
} # end foreach Monitor } # end foreach Monitor
if ( $monitors ) { if ( $monitors ) {
@ -63,14 +63,14 @@ if ( $monitors ) {
} }
noCacheHeaders(); noCacheHeaders();
xhtmlHeaders(__FILE__, translate('CycleWatch') ); xhtmlHeaders(__FILE__, translate('CycleWatch'));
?> ?>
<body> <body>
<div id="page"> <div id="page">
<?php echo $navbar = getNavBarHTML(); ?> <?php echo $navbar = getNavBarHTML(); ?>
<div id="header"> <div id="header">
<div id="headerButtons"> <div id="headerButtons">
<?php if ( $mode == "stream" ) { ?> <?php if ( $mode == 'stream' ) { ?>
<a href="?view=<?php echo $view ?>&amp;mode=still&amp;mid=<?php echo $monitor ? $monitor->Id() : '' ?>"><?php echo translate('Stills') ?></a> <a href="?view=<?php echo $view ?>&amp;mode=still&amp;mid=<?php echo $monitor ? $monitor->Id() : '' ?>"><?php echo translate('Stills') ?></a>
<?php } else { ?> <?php } else { ?>
<a href="?view=<?php echo $view ?>&amp;mode=stream&amp;mid=<?php echo $monitor ? $monitor->Id() : '' ?>"><?php echo translate('Stream') ?></a> <a href="?view=<?php echo $view ?>&amp;mode=stream&amp;mid=<?php echo $monitor ? $monitor->Id() : '' ?>"><?php echo translate('Stream') ?></a>
@ -84,7 +84,7 @@ xhtmlHeaders(__FILE__, translate('CycleWatch') );
<div id="imageFeed"> <div id="imageFeed">
<?php <?php
if ( $monitor ) { if ( $monitor ) {
echo getStreamHTML( $monitor, array( 'scale'=>$scale, 'mode'=>$mode ) ); echo getStreamHTML($monitor, array('scale'=>$scale, 'mode'=>$mode));
} else { } else {
echo "There are no monitors to view."; echo "There are no monitors to view.";
} }

View File

@ -1,9 +1,9 @@
function nextCycleView() { function nextCycleView() {
window.location.replace( '?view=cycle&mid='+nextMid+'&mode='+mode, cycleRefreshTimeout ); window.location.replace('?view=cycle&mid='+nextMid+'&mode='+mode, cycleRefreshTimeout);
} }
function initCycle() { function initCycle() {
nextCycleView.periodical( cycleRefreshTimeout ); nextCycleView.periodical(cycleRefreshTimeout);
} }
window.addEvent( 'domready', initCycle ); window.addEvent('domready', initCycle);

View File

@ -240,7 +240,7 @@ function timerFire() {
if ( liveMode ) { if ( liveMode ) {
outputUpdate(currentTimeSecs); // In live mode we basically do nothing but redisplay outputUpdate(currentTimeSecs); // In live mode we basically do nothing but redisplay
} else if (currentTimeSecs + playSecsperInterval >= maxTimeSecs) { } else if ( currentTimeSecs + playSecsperInterval >= maxTimeSecs ) {
// beyond the end just stop // beyond the end just stop
console.log("Current time " + currentTimeSecs + " + " + playSecsperInterval + " >= " + maxTimeSecs + " so stopping"); console.log("Current time " + currentTimeSecs + " + " + playSecsperInterval + " >= " + maxTimeSecs + " so stopping");
setSpeed(0); setSpeed(0);
@ -472,7 +472,9 @@ function redrawScreen() {
function outputUpdate(time) { function outputUpdate(time) {
drawSliderOnGraph(time); drawSliderOnGraph(time);
for ( var i=0; i < numMonitors; i++ ) { for ( var i=0; i < numMonitors; i++ ) {
loadImage2Monitor(monitorPtr[i],getImageSource(monitorPtr[i],time)); var src = getImageSource(monitorPtr[i],time);
console.log("New image src: " + src);
loadImage2Monitor(monitorPtr[i],src);
} }
currentTimeSecs = time; currentTimeSecs = time;
} }

View File

@ -27,7 +27,7 @@ require_once('includes/MontageLayout.php');
$showControl = false; $showControl = false;
$showZones = false; $showZones = false;
if ( isset( $_REQUEST['showZones'] ) ) { if ( isset($_REQUEST['showZones']) ) {
if ( $_REQUEST['showZones'] == 1 ) { if ( $_REQUEST['showZones'] == 1 ) {
$showZones = true; $showZones = true;
} }
@ -51,7 +51,7 @@ $scale = '100'; # actual
if ( isset( $_REQUEST['scale'] ) ) { if ( isset( $_REQUEST['scale'] ) ) {
$scale = validInt($_REQUEST['scale']); $scale = validInt($_REQUEST['scale']);
Logger::Debug("Setting scale from request to $scale"); Logger::Debug("Setting scale from request to $scale");
} else if ( isset( $_COOKIE['zmMontageScale'] ) ) { } else if ( isset($_COOKIE['zmMontageScale']) ) {
$scale = $_COOKIE['zmMontageScale']; $scale = $_COOKIE['zmMontageScale'];
Logger::Debug("Setting scale from cookie to $scale"); Logger::Debug("Setting scale from cookie to $scale");
} }
@ -65,7 +65,6 @@ foreach ( $layouts as $l ) {
$layoutsById[$l->Id()] = $l; $layoutsById[$l->Id()] = $l;
} }
session_start(); session_start();
$layout_id = ''; $layout_id = '';
@ -80,28 +79,29 @@ $Layout = '';
$Positions = ''; $Positions = '';
if ( $layout_id and is_numeric($layout_id) and isset($layoutsById[$layout_id]) ) { if ( $layout_id and is_numeric($layout_id) and isset($layoutsById[$layout_id]) ) {
$Layout = $layoutsById[$layout_id]; $Layout = $layoutsById[$layout_id];
$Positions = json_decode( $Layout->Positions(), true ); $Positions = json_decode($Layout->Positions(), true);
} }
if ( $Layout and ( $Layout->Name() != 'Freeform' ) ) { if ( $Layout and ( $Layout->Name() != 'Freeform' ) ) {
// Use layout instead of other options // Use layout instead of other options
} }
if ( isset($_COOKIE['zmMontageWidth']) and $_COOKIE['zmMontageWidth'] ) { if ( isset($_COOKIE['zmMontageWidth']) and $_COOKIE['zmMontageWidth'] ) {
$_SESSION['zmMontageWidth'] = $options['width'] = $_COOKIE['zmMontageWidth']; $_SESSION['zmMontageWidth'] = $options['width'] = $_COOKIE['zmMontageWidth'];
} elseif ( isset($_SESSION['zmMontageWidth']) and $_SESSION['zmMontageWidth'] ) { } elseif ( isset($_SESSION['zmMontageWidth']) and $_SESSION['zmMontageWidth'] ) {
$options['width'] = $_SESSION['zmMontageWidth']; $options['width'] = $_SESSION['zmMontageWidth'];
} else } else
$options['width'] = ''; $options['width'] = '';
if ( isset($_COOKIE['zmMontageHeight']) and $_COOKIE['zmMontageHeight'] ) if ( isset($_COOKIE['zmMontageHeight']) and $_COOKIE['zmMontageHeight'] )
$_SESSION['zmMontageHeight'] = $options['height'] = $_COOKIE['zmMontageHeight']; $_SESSION['zmMontageHeight'] = $options['height'] = $_COOKIE['zmMontageHeight'];
else if ( isset($_SESSION['zmMontageHeight']) and $_SESSION['zmMontageHeight'] ) else if ( isset($_SESSION['zmMontageHeight']) and $_SESSION['zmMontageHeight'] )
$options['height'] = $_SESSION['zmMontageHeight']; $options['height'] = $_SESSION['zmMontageHeight'];
else else
$options['height'] = ''; $options['height'] = '';
if ( $scale ) if ( $scale )
$options['scale'] = $scale; $options['scale'] = $scale;
session_write_close(); session_write_close();
ob_start(); ob_start();
@ -120,16 +120,16 @@ foreach( $displayMonitors as &$row ) {
if ( ZM_OPT_CONTROL && $row['ControlId'] && $row['Controllable'] ) if ( ZM_OPT_CONTROL && $row['ControlId'] && $row['Controllable'] )
$showControl = true; $showControl = true;
$row['connKey'] = generateConnKey(); $row['connKey'] = generateConnKey();
if ( ! isset( $widths[$row['Width']] ) ) { if ( ! isset($widths[$row['Width']]) ) {
$widths[$row['Width']] = $row['Width']; $widths[$row['Width']] = $row['Width'];
} }
if ( ! isset( $heights[$row['Height']] ) ) { if ( ! isset($heights[$row['Height']]) ) {
$heights[$row['Height']] = $row['Height']; $heights[$row['Height']] = $row['Height'];
} }
$monitors[] = new Monitor( $row ); $monitors[] = new Monitor($row);
} # end foreach Monitor } # end foreach Monitor
xhtmlHeaders(__FILE__, translate('Montage') ); xhtmlHeaders(__FILE__, translate('Montage'));
?> ?>
<body> <body>
<div id="page"> <div id="page">
@ -139,7 +139,7 @@ xhtmlHeaders(__FILE__, translate('Montage') );
<?php <?php
if ( $showControl ) { if ( $showControl ) {
?> ?>
<a href="#" onclick="createPopup( '?view=control', 'zmControl', 'control' )"><?php echo translate('Control') ?></a> <a href="#" onclick="createPopup('?view=control', 'zmControl', 'control')"><?php echo translate('Control') ?></a>
<?php <?php
} }
if ( $showZones ) { if ( $showZones ) {
@ -153,21 +153,30 @@ if ( $showZones ) {
} }
?> ?>
</div> </div>
<form method="get"> <form method="get">
<input type="hidden" name="view" value="montage"/> <input type="hidden" name="view" value="montage"/>
<?php echo $filterbar ?> <?php echo $filterbar ?>
</form> </form>
<div id="sizeControl"> <div id="sizeControl">
<form action="index.php?view=montage" method="post"> <form action="index.php?view=montage" method="post">
<input type="hidden" name="object" value="MontageLayout"/> <input type="hidden" name="object" value="MontageLayout"/>
<input type="hidden" name="action" value="Save"/> <input type="hidden" name="action" value="Save"/>
<span id="widthControl"><label><?php echo translate('Width') ?>:</label><?php echo htmlSelect( 'width', $widths, $options['width'], 'changeSize(this);' ); ?></span> <span id="widthControl">
<span id="heightControl"><label><?php echo translate('Height') ?>:</label><?php echo htmlSelect( 'height', $heights, $options['height'], 'changeSize(this);' ); ?></span> <label><?php echo translate('Width') ?>:</label>
<span id="scaleControl"><label><?php echo translate('Scale') ?>:</label><?php echo htmlSelect( 'scale', $scales, $scale, 'changeScale(this);' ); ?></span> <?php echo htmlSelect('width', $widths, $options['width'], 'changeSize(this);'); ?>
</span>
<span id="heightControl">
<label><?php echo translate('Height') ?>:</label>
<?php echo htmlSelect('height', $heights, $options['height'], 'changeSize(this);'); ?>
</span>
<span id="scaleControl">
<label><?php echo translate('Scale') ?>:</label>
<?php echo htmlSelect('scale', $scales, $scale, 'changeScale(this);'); ?>
</span>
<span id="layoutControl"> <span id="layoutControl">
<label for="layout"><?php echo translate('Layout') ?>:</label> <label for="layout"><?php echo translate('Layout') ?>:</label>
<?php echo htmlSelect( 'zmMontageLayout', $layoutsById, $layout_id, array( 'onchange'=>'selectLayout(this);', 'id'=>'zmMontageLayout') ); ?> <?php echo htmlSelect('zmMontageLayout', $layoutsById, $layout_id, array('onchange'=>'selectLayout(this);', 'id'=>'zmMontageLayout')); ?>
</span> </span>
<input type="hidden" name="Positions"/> <input type="hidden" name="Positions"/>
<input type="button" id="EditLayout" value="<?php echo translate('EditLayout') ?>" onclick="edit_layout(this);"/> <input type="button" id="EditLayout" value="<?php echo translate('EditLayout') ?>" onclick="edit_layout(this);"/>
@ -187,7 +196,10 @@ foreach ( $monitors as $monitor ) {
?> ?>
<div id="monitorFrame<?php echo $monitor->Id() ?>" class="monitorFrame" title="<?php echo $monitor->Id() . ' ' .$monitor->Name() ?>" style="<?php echo $options['width'] ? 'width:'.$options['width'].'px;':''?>"> <div id="monitorFrame<?php echo $monitor->Id() ?>" class="monitorFrame" title="<?php echo $monitor->Id() . ' ' .$monitor->Name() ?>" style="<?php echo $options['width'] ? 'width:'.$options['width'].'px;':''?>">
<div id="monitor<?php echo $monitor->Id() ?>" class="monitor idle"> <div id="monitor<?php echo $monitor->Id() ?>" class="monitor idle">
<div id="imageFeed<?php echo $monitor->Id() ?>" class="imageFeed" onclick="createPopup( '?view=watch&amp;mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo reScale( $monitor->Width(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->Height(), $monitor->PopupScale() ); ?> );"> <div
id="imageFeed<?php echo $monitor->Id() ?>"
class="imageFeed"
onclick="createPopup('?view=watch&amp;mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo reScale( $monitor->Width(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->Height(), $monitor->PopupScale() ); ?> );">
<?php <?php
$monitor_options = $options; $monitor_options = $options;
if ( $Positions ) { if ( $Positions ) {
@ -204,59 +216,67 @@ foreach ( $monitors as $monitor ) {
} }
} }
if ( $monitor->Type() == "WebSite" ) { if ( $monitor->Type() == 'WebSite' ) {
echo getWebSiteUrl( 'liveStream'.$monitor->Id(), $monitor->Path(), reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() ); echo getWebSiteUrl(
'liveStream'.$monitor->Id(),
$monitor->Path(),
reScale($monitor->Width(), $scale),
reScale($monitor->Height(), $scale),
$monitor->Name()
);
} else { } else {
echo getStreamHTML( $monitor, $monitor_options ); echo getStreamHTML($monitor, $monitor_options);
} }
if ( $showZones ) { if ( $showZones ) {
$height = null; $height = null;
$width = null; $width = null;
if ( $options['width'] ) { if ( $options['width'] ) {
$width = $options['width']; $width = $options['width'];
if ( ! $options['height'] ) { if ( !$options['height'] ) {
$scale = (int)( 100 * $options['width'] / $monitor->Width() ); $scale = (int)( 100 * $options['width'] / $monitor->Width() );
$height = reScale( $monitor->Height(), $scale ); $height = reScale($monitor->Height(), $scale);
} }
} else if ( $options['height'] ) { } else if ( $options['height'] ) {
$height = $options['height']; $height = $options['height'];
if ( ! $options['width'] ) { if ( !$options['width'] ) {
$scale = (int)( 100 * $options['height'] / $monitor->Height() ); $scale = (int)( 100 * $options['height'] / $monitor->Height() );
$width = reScale( $monitor->Width(), $scale ); $width = reScale($monitor->Width(), $scale);
} }
} else if ( $scale ) { } else if ( $scale ) {
$width = reScale( $monitor->Width(), $scale ); $width = reScale($monitor->Width(), $scale);
$height = reScale( $monitor->Height(), $scale ); $height = reScale($monitor->Height(), $scale);
} }
$zones = array(); $zones = array();
foreach( dbFetchAll( 'SELECT * FROM Zones WHERE MonitorId=? ORDER BY Area DESC', NULL, array($monitor->Id()) ) as $row ) { foreach( dbFetchAll('SELECT * FROM Zones WHERE MonitorId=? ORDER BY Area DESC', NULL, array($monitor->Id()) ) as $row ) {
$row['Points'] = coordsToPoints( $row['Coords'] ); $row['Points'] = coordsToPoints($row['Coords']);
if ( $scale ) { if ( $scale ) {
limitPoints( $row['Points'], 0, 0, $monitor->Width(), $monitor->Height() ); limitPoints($row['Points'], 0, 0, $monitor->Width(), $monitor->Height());
scalePoints( $row['Points'], $scale ); scalePoints($row['Points'], $scale);
} else { } else {
limitPoints( $row['Points'], 0, 0, limitPoints($row['Points'], 0, 0,
( $width ? $width-1 : $monitor->Width()-1 ), ( $width ? $width-1 : $monitor->Width()-1 ),
( $height ? $height-1 : $monitor->Height()-1 ) ( $height ? $height-1 : $monitor->Height()-1 )
); );
} }
$row['Coords'] = pointsToCoords( $row['Points'] ); $row['Coords'] = pointsToCoords($row['Points']);
$row['AreaCoords'] = preg_replace( '/\s+/', ',', $row['Coords'] ); $row['AreaCoords'] = preg_replace('/\s+/', ',', $row['Coords']);
$zones[] = $row; $zones[] = $row;
} // end foreach Zone } // end foreach Zone
?> ?>
<svg class="zones" id="zones<?php echo $monitor->Id() ?>" style="position:absolute; top: 0; left: 0; background: none; width: <?php echo $width ?>px; height: <?php echo $height ?>px;"> <svg class="zones" id="zones<?php echo $monitor->Id() ?>" style="position:absolute; top: 0; left: 0; background: none; width: <?php echo $width ?>px; height: <?php echo $height ?>px;">
<?php <?php
foreach( array_reverse($zones) as $zone ) { foreach( array_reverse($zones) as $zone ) {
echo '<polygon points="'. $zone['AreaCoords'] .'" class="'. $zone['Type'].'" />'; echo '<polygon points="'. $zone['AreaCoords'] .'" class="'. $zone['Type'].'" />';
} // end foreach zone } // end foreach zone
?> ?>
Sorry, your browser does not support inline SVG Sorry, your browser does not support inline SVG
</svg> </svg>
<?php } # end if showZones ?> <?php
} # end if showZones
?>
</div> </div>
<?php <?php
if ( (!ZM_WEB_COMPACT_MONTAGE) && ($monitor->Type() != 'WebSite') ) { if ( (!ZM_WEB_COMPACT_MONTAGE) && ($monitor->Type() != 'WebSite') ) {
@ -268,7 +288,7 @@ foreach ( $monitors as $monitor ) {
</div> </div>
</div> </div>
<?php <?php
} } # end foreach monitor
?> ?>
</div> </div>
</div> </div>

View File

@ -37,7 +37,6 @@ if ( ! visibleMonitor($mid) ) {
return; return;
} }
$monitor = new Monitor($mid); $monitor = new Monitor($mid);
#Whether to show the controls button #Whether to show the controls button
@ -68,7 +67,7 @@ xhtmlHeaders( __FILE__, $monitor->Name().' - '.translate('Feed') );
<div id="monitorName"><?php echo $monitor->Name() ?></div> <div id="monitorName"><?php echo $monitor->Name() ?></div>
<div id="menuControls"> <div id="menuControls">
<?php <?php
if ( canView( 'Control' ) && $monitor->Type() == 'Local' ) { if ( canView('Control') && $monitor->Type() == 'Local' ) {
?> ?>
<div id="settingsControl"><?php echo makePopupLink( '?view=settings&amp;mid='.$monitor->Id(), 'zmSettings'.$monitor->Id(), 'settings', translate('Settings'), true, 'id="settingsLink"' ) ?></div> <div id="settingsControl"><?php echo makePopupLink( '?view=settings&amp;mid='.$monitor->Id(), 'zmSettings'.$monitor->Id(), 'settings', translate('Settings'), true, 'id="settingsLink"' ) ?></div>
<?php <?php