braces,whitespace

This commit is contained in:
Isaac Connor 2017-05-25 14:26:49 -04:00
parent 9cbafde1ac
commit 043d722651
1 changed files with 85 additions and 112 deletions

View File

@ -91,31 +91,25 @@ $maxSequence = 1;
$seqIdList = array(); $seqIdList = array();
$monitors = dbFetchAll( "select * from Monitors order by Sequence asc" ); $monitors = dbFetchAll( "select * from Monitors order by Sequence asc" );
$displayMonitors = array(); $displayMonitors = array();
for ( $i = 0; $i < count($monitors); $i++ ) for ( $i = 0; $i < count($monitors); $i++ ) {
{ if ( !visibleMonitor( $monitors[$i]['Id'] ) ) {
if ( !visibleMonitor( $monitors[$i]['Id'] ) )
{
continue; continue;
} }
if ( $group && !empty($groupIds) && !array_key_exists( $monitors[$i]['Id'], $groupIds ) ) if ( $group && !empty($groupIds) && !array_key_exists( $monitors[$i]['Id'], $groupIds ) ) {
{
continue; continue;
} }
$monitors[$i]['Show'] = true; $monitors[$i]['Show'] = true;
if ( empty($minSequence) || ($monitors[$i]['Sequence'] < $minSequence) ) if ( empty($minSequence) || ($monitors[$i]['Sequence'] < $minSequence) ) {
{
$minSequence = $monitors[$i]['Sequence']; $minSequence = $monitors[$i]['Sequence'];
} }
if ( $monitors[$i]['Sequence'] > $maxSequence ) if ( $monitors[$i]['Sequence'] > $maxSequence ) {
{
$maxSequence = $monitors[$i]['Sequence']; $maxSequence = $monitors[$i]['Sequence'];
} }
$monitors[$i]['zmc'] = zmcStatus( $monitors[$i] ); $monitors[$i]['zmc'] = zmcStatus( $monitors[$i] );
$monitors[$i]['zma'] = zmaStatus( $monitors[$i] ); $monitors[$i]['zma'] = zmaStatus( $monitors[$i] );
$monitors[$i]['ZoneCount'] = dbFetchOne( 'select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitors[$i]['Id']) ); $monitors[$i]['ZoneCount'] = dbFetchOne( 'select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitors[$i]['Id']) );
$counts = array(); $counts = array();
for ( $j = 0; $j < count($eventCounts); $j++ ) for ( $j = 0; $j < count($eventCounts); $j++ ) {
{
$filter = addFilterTerm( $eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['terms']), array( "cnj" => "and", "attr" => "MonitorId", "op" => "=", "val" => $monitors[$i]['Id'] ) ); $filter = addFilterTerm( $eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['terms']), array( "cnj" => "and", "attr" => "MonitorId", "op" => "=", "val" => $monitors[$i]['Id'] ) );
parseFilter( $filter ); parseFilter( $filter );
$counts[] = "count(if(1".$filter['sql'].",1,NULL)) as EventCount$j"; $counts[] = "count(if(1".$filter['sql'].",1,NULL)) as EventCount$j";
@ -123,8 +117,7 @@ for ( $i = 0; $i < count($monitors); $i++ )
} }
$sql = "select ".join($counts,", ")." from Events as E where MonitorId = ?"; $sql = "select ".join($counts,", ")." from Events as E where MonitorId = ?";
$counts = dbFetchOne( $sql, NULL, array($monitors[$i]['Id']) ); $counts = dbFetchOne( $sql, NULL, array($monitors[$i]['Id']) );
if ( $monitors[$i]['Function'] != 'None' ) if ( $monitors[$i]['Function'] != 'None' ) {
{
$cycleCount++; $cycleCount++;
$scaleWidth = reScale( $monitors[$i]['Width'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $scaleWidth = reScale( $monitors[$i]['Width'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
$scaleHeight = reScale( $monitors[$i]['Height'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $scaleHeight = reScale( $monitors[$i]['Height'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
@ -137,8 +130,7 @@ for ( $i = 0; $i < count($monitors); $i++ )
} }
$lastId = 0; $lastId = 0;
$seqIdUpList = array(); $seqIdUpList = array();
foreach ( $seqIdList as $seqId ) foreach ( $seqIdList as $seqId ) {
{
if ( !empty($lastId) ) if ( !empty($lastId) )
$seqIdUpList[$seqId] = $lastId; $seqIdUpList[$seqId] = $lastId;
else else
@ -147,8 +139,7 @@ foreach ( $seqIdList as $seqId )
} }
$lastId = 0; $lastId = 0;
$seqIdDownList = array(); $seqIdDownList = array();
foreach ( array_reverse($seqIdList) as $seqId ) foreach ( array_reverse($seqIdList) as $seqId ) {
{
if ( !empty($lastId) ) if ( !empty($lastId) )
$seqIdDownList[$seqId] = $lastId; $seqIdDownList[$seqId] = $lastId;
else else
@ -163,15 +154,12 @@ $eventsView = ZM_WEB_EVENTS_VIEW;
$eventsWindow = 'zm'.ucfirst(ZM_WEB_EVENTS_VIEW); $eventsWindow = 'zm'.ucfirst(ZM_WEB_EVENTS_VIEW);
$eventCount = 0; $eventCount = 0;
for ( $i = 0; $i < count($eventCounts); $i++ ) for ( $i = 0; $i < count($eventCounts); $i++ ) {
{
$eventCounts[$i]['total'] = 0; $eventCounts[$i]['total'] = 0;
} }
$zoneCount = 0; $zoneCount = 0;
foreach( $displayMonitors as $monitor ) foreach( $displayMonitors as $monitor ) {
{ for ( $i = 0; $i < count($eventCounts); $i++ ) {
for ( $i = 0; $i < count($eventCounts); $i++ )
{
$eventCounts[$i]['total'] += $monitor['EventCount'.$i]; $eventCounts[$i]['total'] += $monitor['EventCount'.$i];
} }
$zoneCount += $monitor['ZoneCount']; $zoneCount += $monitor['ZoneCount'];
@ -201,20 +189,17 @@ xhtmlHeaders( __FILE__, translate('Console') );
<h3 id="development"><center><?php echo ZM_WEB_CONSOLE_BANNER ?></center></h3> <h3 id="development"><center><?php echo ZM_WEB_CONSOLE_BANNER ?></center></h3>
<div id="monitorSummary"><?php echo makePopupLink( '?view=groups', 'zmGroups', 'groups', sprintf( $CLANG['MonitorCount'], count($displayMonitors), zmVlang( $VLANG['Monitor'], count($displayMonitors) ) ).($group?' ('.$group['Name'].')':''), canView( 'Groups' ) ); ?></div> <div id="monitorSummary"><?php echo makePopupLink( '?view=groups', 'zmGroups', 'groups', sprintf( $CLANG['MonitorCount'], count($displayMonitors), zmVlang( $VLANG['Monitor'], count($displayMonitors) ) ).($group?' ('.$group['Name'].')':''), canView( 'Groups' ) ); ?></div>
<?php <?php
if ( ZM_OPT_X10 && canView( 'Devices' ) ) if ( ZM_OPT_X10 && canView( 'Devices' ) ) {
{
?> ?>
<div id="devices"><?php echo makePopupLink( '?view=devices', 'zmDevices', 'devices', translate('Devices') ) ?></div> <div id="devices"><?php echo makePopupLink( '?view=devices', 'zmDevices', 'devices', translate('Devices') ) ?></div>
<?php <?php
} }
if ( canView( 'System' ) ) if ( canView( 'System' ) ) {
{
?> ?>
<div id="options"><?php echo makePopupLink( '?view=options', 'zmOptions', 'options', translate('Options') ) ?><?php if ( logToDatabase() > Logger::NOLOG ) { ?> / <?php echo makePopupLink( '?view=log', 'zmLog', 'log', '<span class="'.logState().'">'.translate('Log').'</span>' ) ?><?php } ?></div> <div id="options"><?php echo makePopupLink( '?view=options', 'zmOptions', 'options', translate('Options') ) ?><?php if ( logToDatabase() > Logger::NOLOG ) { ?> / <?php echo makePopupLink( '?view=log', 'zmLog', 'log', '<span class="'.logState().'">'.translate('Log').'</span>' ) ?><?php } ?></div>
<?php <?php
} }
if ( canView( 'Stream' ) && $cycleCount > 1 ) if ( canView( 'Stream' ) && $cycleCount > 1 ) {
{
$cycleGroup = isset($_COOKIE['zmGroup'])?$_COOKIE['zmGroup']:0; $cycleGroup = isset($_COOKIE['zmGroup'])?$_COOKIE['zmGroup']:0;
?> ?>
<div id="cycleMontage"> <div id="cycleMontage">
@ -223,20 +208,15 @@ if ( canView( 'Stream' ) && $cycleCount > 1 )
<?php echo makePopupLink( '?view=montagereview&amp;group='.$cycleGroup, 'zmMontage'.$cycleGroup, 'montagereview', translate('Montage Review'), $running ) ?> <?php echo makePopupLink( '?view=montagereview&amp;group='.$cycleGroup, 'zmMontage'.$cycleGroup, 'montagereview', translate('Montage Review'), $running ) ?>
</div> </div>
<?php <?php
} } else {
else
{
?> ?>
<?php <?php
} }
?> ?>
<h3 id="loginBandwidth"><?php <h3 id="loginBandwidth"><?php
if ( ZM_OPT_USE_AUTH ) if ( ZM_OPT_USE_AUTH ) {
{
?><?php echo translate('LoggedInAs') ?> <?php echo makePopupLink( '?view=logout', 'zmLogout', 'logout', $user['Username'], (ZM_AUTH_TYPE == "builtin") ) ?>, <?php echo strtolower( translate('ConfiguredFor') ) ?><?php ?><?php echo translate('LoggedInAs') ?> <?php echo makePopupLink( '?view=logout', 'zmLogout', 'logout', $user['Username'], (ZM_AUTH_TYPE == "builtin") ) ?>, <?php echo strtolower( translate('ConfiguredFor') ) ?><?php
} } else {
else
{
?><?php echo translate('ConfiguredFor') ?><?php ?><?php echo translate('ConfiguredFor') ?><?php
} }
?>&nbsp;<?php echo makePopupLink( '?view=bandwidth', 'zmBandwidth', 'bandwidth', $bwArray[$_COOKIE['zmBandwidth']], ($user && $user['MaxBandwidth'] != 'low' ) ) ?> <?php echo translate('BandwidthHead') ?></h3> ?>&nbsp;<?php echo makePopupLink( '?view=bandwidth', 'zmBandwidth', 'bandwidth', $bwArray[$_COOKIE['zmBandwidth']], ($user && $user['MaxBandwidth'] != 'low' ) ) ?> <?php echo translate('BandwidthHead') ?></h3>
@ -255,8 +235,7 @@ else
<?php } ?> <?php } ?>
<th class="colSource"><?php echo translate('Source') ?></th> <th class="colSource"><?php echo translate('Source') ?></th>
<?php <?php
for ( $i = 0; $i < count($eventCounts); $i++ ) for ( $i = 0; $i < count($eventCounts); $i++ ) {
{
?> ?>
<th class="colEvents"><?php echo $eventCounts[$i]['title'] ?></th> <th class="colEvents"><?php echo $eventCounts[$i]['title'] ?></th>
<?php <?php
@ -264,8 +243,7 @@ for ( $i = 0; $i < count($eventCounts); $i++ )
?> ?>
<th class="colZones"><?php echo translate('Zones') ?></th> <th class="colZones"><?php echo translate('Zones') ?></th>
<?php <?php
if ( canEdit('Monitors') ) if ( canEdit('Monitors') ) {
{
?> ?>
<th class="colOrder"><?php echo translate('Order') ?></th> <th class="colOrder"><?php echo translate('Order') ?></th>
<?php <?php
@ -283,8 +261,7 @@ if ( canEdit('Monitors') )
<?php echo makePopupButton( '?view=filter&amp;filter[terms][0][attr]=DateTime&amp;filter[terms][0][op]=%3c&amp;filter[terms][0][val]=now', 'zmFilter', 'filter', translate('Filters'), canView( 'Events' ) ) ?> <?php echo makePopupButton( '?view=filter&amp;filter[terms][0][attr]=DateTime&amp;filter[terms][0][op]=%3c&amp;filter[terms][0][val]=now', 'zmFilter', 'filter', translate('Filters'), canView( 'Events' ) ) ?>
</td> </td>
<?php <?php
for ( $i = 0; $i < count($eventCounts); $i++ ) for ( $i = 0; $i < count($eventCounts); $i++ ) {
{
parseFilter( $eventCounts[$i]['filter'] ); parseFilter( $eventCounts[$i]['filter'] );
?> ?>
<td class="colEvents"><?php echo makePopupLink( '?view='.$eventsView.'&amp;page=1'.$eventCounts[$i]['filter']['query'], $eventsWindow, $eventsView, $eventCounts[$i]['total'], canView( 'Events' ) ) ?></td> <td class="colEvents"><?php echo makePopupLink( '?view='.$eventsView.'&amp;page=1'.$eventCounts[$i]['filter']['query'], $eventsWindow, $eventsView, $eventCounts[$i]['total'], canView( 'Events' ) ) ?></td>
@ -297,15 +274,13 @@ for ( $i = 0; $i < count($eventCounts); $i++ )
</tfoot> </tfoot>
<tbody> <tbody>
<?php <?php
foreach( $displayMonitors as $monitor ) foreach( $displayMonitors as $monitor ) {
{
?> ?>
<tr> <tr>
<?php <?php
if ( !$monitor['zmc'] ) if ( !$monitor['zmc'] ) {
$dclass = "errorText"; $dclass = "errorText";
else } else {
{
// https://github.com/ZoneMinder/ZoneMinder/issues/1082 // https://github.com/ZoneMinder/ZoneMinder/issues/1082
if ( !$monitor['zma'] && $monitor['Function']!='Monitor' ) if ( !$monitor['zma'] && $monitor['Function']!='Monitor' )
$dclass = "warnText"; $dclass = "warnText";
@ -353,8 +328,7 @@ echo $Server->Name();
<td class="colSource">&nbsp;</td> <td class="colSource">&nbsp;</td>
<?php } ?> <?php } ?>
<?php <?php
for ( $i = 0; $i < count($eventCounts); $i++ ) for ( $i = 0; $i < count($eventCounts); $i++ ) {
{
?> ?>
<td class="colEvents"><?php echo makePopupLink( '?view='.$eventsView.'&amp;page=1'.$monitor['eventCounts'][$i]['filter']['query'], $eventsWindow, $eventsView, $monitor['EventCount'.$i], canView( 'Events' ) ) ?></td> <td class="colEvents"><?php echo makePopupLink( '?view='.$eventsView.'&amp;page=1'.$monitor['eventCounts'][$i]['filter']['query'], $eventsWindow, $eventsView, $monitor['EventCount'.$i], canView( 'Events' ) ) ?></td>
<?php <?php
@ -362,8 +336,7 @@ echo $Server->Name();
?> ?>
<td class="colZones"><?php echo makePopupLink( '?view=zones&amp;mid='.$monitor['Id'], 'zmZones', array( 'zones', $monitor['Width'], $monitor['Height'] ), $monitor['ZoneCount'], $running && canView( 'Monitors' ) ) ?></td> <td class="colZones"><?php echo makePopupLink( '?view=zones&amp;mid='.$monitor['Id'], 'zmZones', array( 'zones', $monitor['Width'], $monitor['Height'] ), $monitor['ZoneCount'], $running && canView( 'Monitors' ) ) ?></td>
<?php <?php
if ( canEdit('Monitors') ) if ( canEdit('Monitors') ) {
{
?> ?>
<td class="colOrder"><?php echo makeLink( '?view='.$view.'&amp;action=sequence&amp;mid='.$monitor['Id'].'&amp;smid='.$seqIdUpList[$monitor['Id']], '<img src="'.$seqUpFile.'" alt="Up"/>', $monitor['Sequence']>$minSequence ) ?><?php echo makeLink( '?view='.$view.'&amp;action=sequence&amp;mid='.$monitor['Id'].'&amp;smid='.$seqIdDownList[$monitor['Id']], '<img src="'.$seqDownFile.'" alt="Down"/>', $monitor['Sequence']<$maxSequence ) ?></td> <td class="colOrder"><?php echo makeLink( '?view='.$view.'&amp;action=sequence&amp;mid='.$monitor['Id'].'&amp;smid='.$seqIdUpList[$monitor['Id']], '<img src="'.$seqUpFile.'" alt="Up"/>', $monitor['Sequence']>$minSequence ) ?><?php echo makeLink( '?view='.$view.'&amp;action=sequence&amp;mid='.$monitor['Id'].'&amp;smid='.$seqIdDownList[$monitor['Id']], '<img src="'.$seqDownFile.'" alt="Down"/>', $monitor['Sequence']<$maxSequence ) ?></td>
<?php <?php