diff --git a/web/skins/classic/views/zone.php b/web/skins/classic/views/zone.php index b0dd88508..ba0cb7328 100644 --- a/web/skins/classic/views/zone.php +++ b/web/skins/classic/views/zone.php @@ -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') );