more merges/fixes from SA

pull/1894/merge
Isaac Connor 2017-05-30 13:50:24 -04:00
parent 8b3b9eb30e
commit b96f5cf49d
2 changed files with 58 additions and 56 deletions

View File

@ -18,9 +18,8 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
if ( !canView( 'Monitors' ) )
{
$view = "error";
if ( !canView( 'Monitors' ) ) {
$view = 'error';
return;
}
@ -34,29 +33,25 @@ $hicolor = '0x00ff00'; // Green
$presets = array();
$presetNames = array();
$presetNames[0] = translate('ChoosePreset');
$sql = "select *, Units-1 as UnitsIndex, CheckMethod-1 as CheckMethodIndex from ZonePresets order by Id asc";
foreach( dbFetchAll( $sql ) as $preset )
{
$presetNames[$preset['Id']] = $preset['Name'];
$presets[] = $preset;
$sql = 'SELECT *, Units-1 AS UnitsIndex, CheckMethod-1 AS CheckMethodIndex FROM ZonePresets ORDER BY Id ASC';
foreach( dbFetchAll( $sql ) as $preset ) {
$presetNames[$preset['Id']] = $preset['Name'];
$presets[] = $preset;
}
$optTypes = array();
foreach ( getEnumValues( 'Zones', 'Type' ) as $optType )
{
$optTypes[$optType] = $optType;
foreach ( getEnumValues( 'Zones', 'Type' ) as $optType ) {
$optTypes[$optType] = $optType;
}
$optUnits = array();
foreach ( getEnumValues( 'Zones', 'Units' ) as $optUnit )
{
$optUnits[$optUnit] = $optUnit;
foreach ( getEnumValues( 'Zones', 'Units' ) as $optUnit ) {
$optUnits[$optUnit] = $optUnit;
}
$optCheckMethods = array();
foreach ( getEnumValues( 'Zones', 'CheckMethod' ) as $optCheckMethod )
{
$optCheckMethods[$optCheckMethod] = $optCheckMethod;
foreach ( getEnumValues( 'Zones', 'CheckMethod' ) as $optCheckMethod ) {
$optCheckMethods[$optCheckMethod] = $optCheckMethod;
}
$monitor = new Monitor( $mid );
@ -66,14 +61,10 @@ $maxX = $monitor->Width()-1;
$minY = 0;
$maxY = $monitor->Height()-1;
if ( !isset($newZone) )
{
if ( $zid > 0 )
{
if ( !isset($newZone) ) {
if ( $zid > 0 ) {
$zone = dbFetchOne( 'SELECT * FROM Zones WHERE MonitorId = ? AND Id=?', NULL, array( $monitor->Id(), $zid ) );
}
else
{
} else {
$zone = array(
'Id' => 0,
'Name' => translate('New'),
@ -104,17 +95,16 @@ if ( !isset($newZone) )
$zone['AreaCoords'] = preg_replace( '/\s+/', ',', $zone['Coords'] );
$newZone = $zone;
}
} # end if new Zone
//if ( !$points )
//{
//$points = $zone['Points'];
//}
# Ensure Zone fits within the limits of the Monitor
limitPoints( $newZone['Points'], $minX, $minY, $maxX, $maxY );
ksort( $newZone['Points'], SORT_NUMERIC );
$newZone['Coords'] = pointsToCoords( $newZone['Points'] );
$newZone['Area'] = getPolyArea( $newZone['Points'] );
$newZone['AreaCoords'] = preg_replace( '/\s+/', ',', $newZone['Coords'] );
$selfIntersecting = isSelfIntersecting( $newZone['Points'] );
$focusWindow = true;
@ -122,7 +112,7 @@ $connkey = generateConnKey();
$streamSrc = '';
$streamMode = '';
# Have to do this here, because the .js.php references somethings figured out when generating the streamHTML
$StreamHTML = getStreamHTML( $monitor, $scale );
$StreamHTML = getStreamHTML( $monitor, array('scale'=>$scale) );
xhtmlHeaders(__FILE__, translate('Zone') );
?>
@ -162,7 +152,13 @@ xhtmlHeaders(__FILE__, translate('Zone') );
</tr>
<tr>
<th scope="row"><?php echo translate('ZoneAlarmColour') ?></th>
<td colspan="2"><input type="text" name="newAlarmRgbR" value="<?php echo ($newZone['AlarmRGB']>>16)&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/>&nbsp;/&nbsp;<input type="text" name="newAlarmRgbG" value="<?php echo ($newZone['AlarmRGB']>>8)&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/>&nbsp;/&nbsp;<input type="text" name="newAlarmRgbB" value="<?php echo $newZone['AlarmRGB']&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/></td>
<td colspan="2">
<input type="text" name="newAlarmRgbR" value="<?php echo ($newZone['AlarmRGB']>>16)&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/>
/
<input type="text" name="newAlarmRgbG" value="<?php echo ($newZone['AlarmRGB']>>8)&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/>
/
<input type="text" name="newAlarmRgbB" value="<?php echo $newZone['AlarmRGB']&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/>
</td>
</tr>
<tr>
<th scope="row"><?php echo translate('CheckMethod') ?></th>

View File

@ -18,23 +18,27 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
if ( !canView( 'Monitors' ) )
{
$view = "error";
return;
if ( !canView( 'Monitors' ) ) {
$view = 'error';
return;
}
$mid = validInt($_REQUEST['mid']);
$monitor = new Monitor( $mid );
# Width() and Height() are already rotated
$minX = 0;
$maxX = $monitor->Width()-1;
$minY = 0;
$maxY = $monitor->Height()-1;
$zones = array();
foreach( dbFetchAll( 'select * from Zones where MonitorId = ? order by Area desc', NULL, array($mid) ) as $row )
{
if ( $row['Points'] = coordsToPoints( $row['Coords'] ) )
{
$row['AreaCoords'] = preg_replace( '/\s+/', ',', $row['Coords'] );
$zones[] = $row;
}
foreach( dbFetchAll( 'SELECT * FROM Zones WHERE MonitorId=? ORDER BY Area DESC', NULL, array($mid) ) as $row ) {
$row['Points'] = coordsToPoints( $row['Coords'] );
limitPoints( $row['Points'], $minX, $minY, $maxX, $maxY );
$row['Coords'] = pointsToCoords( $row['Points'] );
$row['AreaCoords'] = preg_replace( '/\s+/', ',', $row['Coords'] );
$zones[] = $row;
}
$connkey = generateConnKey();
@ -48,21 +52,14 @@ xhtmlHeaders(__FILE__, translate('Zones') );
<h2><?php echo translate('Zones') ?></h2>
</div>
<div id="content" style="width:<?php echo $monitor->Width() ?>px; height:<?php echo $monitor->Height() ?>px; position:relative; margin: 0 auto;">
<?php echo getStreamHTML( $monitor ); ?>
<svg class="zones" width="<?php echo $monitor->Width() ?>" height="<?php echo $monitor->Height() ?>" style="position:absolute; top: 0; left: 0; background: none;">
<?php
foreach( array_reverse($zones) as $zone ) {
?>
<polygon points="<?php echo $zone['AreaCoords'] ?>" class="<?php echo $zone['Type']?>" onclick="streamCmdQuit( true ); createPopup( '?view=zone&amp;mid=<?php echo $mid ?>&amp;zid=<?php echo $zone['Id'] ?>', 'zmZone', 'zone', <?php echo $monitor->Width ?>, <?php echo $monitor->Height ?> ); return( false );"/>
<?php
} // end foreach zone
?>
Sorry, your browser does not support inline SVG
</svg>
<form name="contentForm" id="contentForm" method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<input type="hidden" name="view" value="<?php echo $view ?>"/>
<input type="hidden" name="action" value="delete"/>
<input type="hidden" name="mid" value="<?php echo $mid ?>"/>
<div id="contentButtons">
<input type="button" value="<?php echo translate('AddNewZone') ?>" onclick="createPopup( '?view=zone&amp;mid=<?php echo $mid ?>&amp;zid=0', 'zmZone', 'zone', <?php echo $monitor->Width() ?>, <?php echo $monitor->Height() ?> );"<?php if ( !canEdit( 'Monitors' ) ) { ?> disabled="disabled"<?php } ?>/>
<input type="submit" name="deleteBtn" value="<?php echo translate('Delete') ?>" disabled="disabled"/>
</div>
<table id="contentTable" class="major" cellspacing="0">
<thead>
<tr>
@ -88,9 +85,18 @@ foreach( $zones as $zone )
?>
</tbody>
</table>
<div id="contentButtons">
<input type="button" value="<?php echo translate('AddNewZone') ?>" onclick="createPopup( '?view=zone&amp;mid=<?php echo $mid ?>&amp;zid=0', 'zmZone', 'zone', <?php echo $monitor->Width() ?>, <?php echo $monitor->Height() ?> );"<?php if ( !canEdit( 'Monitors' ) ) { ?> disabled="disabled"<?php } ?>/>
<input type="submit" name="deleteBtn" value="<?php echo translate('Delete') ?>" disabled="disabled"/>
<div class="ZonesImage" style="position:relative; clear:both;">
<?php echo getStreamHTML( $monitor ); ?>
<svg class="zones" width="<?php echo $monitor->Width() ?>" height="<?php echo $monitor->Height() ?>" style="position:absolute; top: 0; left: 0; background: none;">
<?php
foreach( array_reverse($zones) as $zone ) {
?>
<polygon points="<?php echo $zone['AreaCoords'] ?>" class="<?php echo $zone['Type']?>" onclick="streamCmdQuit( true ); createPopup( '?view=zone&amp;mid=<?php echo $mid ?>&amp;zid=<?php echo $zone['Id'] ?>', 'zmZone', 'zone', <?php echo $monitor->Width ?>, <?php echo $monitor->Height ?> ); return( false );"/>
<?php
} // end foreach zone
?>
Sorry, your browser does not support inline SVG
</svg>
</div>
</form>
</div>