From 043d72265151d77c3ab06530ff40a35da1df9c69 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 25 May 2017 14:26:49 -0400 Subject: [PATCH] braces,whitespace --- web/skins/classic/views/console.php | 197 ++++++++++++---------------- 1 file changed, 85 insertions(+), 112 deletions(-) diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index e34a24607..628d92859 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -77,8 +77,8 @@ $run_state = dbFetchOne('select Name from States where IsActive = 1', 'Name' ); $group = NULL; if ( ! empty($_COOKIE['zmGroup']) ) { - if ( $group = dbFetchOne( 'select * from Groups where Id = ?', NULL, array($_COOKIE['zmGroup'])) ) - $groupIds = array_flip(explode( ',', $group['MonitorIds'] )); + if ( $group = dbFetchOne( 'select * from Groups where Id = ?', NULL, array($_COOKIE['zmGroup'])) ) + $groupIds = array_flip(explode( ',', $group['MonitorIds'] )); } noCacheHeaders(); @@ -91,69 +91,60 @@ $maxSequence = 1; $seqIdList = array(); $monitors = dbFetchAll( "select * from Monitors order by Sequence asc" ); $displayMonitors = array(); -for ( $i = 0; $i < count($monitors); $i++ ) -{ - if ( !visibleMonitor( $monitors[$i]['Id'] ) ) - { - continue; - } - if ( $group && !empty($groupIds) && !array_key_exists( $monitors[$i]['Id'], $groupIds ) ) - { - continue; - } - $monitors[$i]['Show'] = true; - if ( empty($minSequence) || ($monitors[$i]['Sequence'] < $minSequence) ) - { - $minSequence = $monitors[$i]['Sequence']; - } - if ( $monitors[$i]['Sequence'] > $maxSequence ) - { - $maxSequence = $monitors[$i]['Sequence']; - } - $monitors[$i]['zmc'] = zmcStatus( $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']) ); - $counts = array(); - 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'] ) ); - parseFilter( $filter ); - $counts[] = "count(if(1".$filter['sql'].",1,NULL)) as EventCount$j"; - $monitors[$i]['eventCounts'][$j]['filter'] = $filter; - } - $sql = "select ".join($counts,", ")." from Events as E where MonitorId = ?"; - $counts = dbFetchOne( $sql, NULL, array($monitors[$i]['Id']) ); - if ( $monitors[$i]['Function'] != 'None' ) - { - $cycleCount++; - $scaleWidth = reScale( $monitors[$i]['Width'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); - $scaleHeight = reScale( $monitors[$i]['Height'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); - if ( $maxWidth < $scaleWidth ) $maxWidth = $scaleWidth; - if ( $maxHeight < $scaleHeight ) $maxHeight = $scaleHeight; - } - if ( $counts ) $monitors[$i] = array_merge( $monitors[$i], $counts ); - $seqIdList[] = $monitors[$i]['Id']; - $displayMonitors[] = $monitors[$i]; +for ( $i = 0; $i < count($monitors); $i++ ) { + if ( !visibleMonitor( $monitors[$i]['Id'] ) ) { + continue; + } + if ( $group && !empty($groupIds) && !array_key_exists( $monitors[$i]['Id'], $groupIds ) ) { + continue; + } + $monitors[$i]['Show'] = true; + if ( empty($minSequence) || ($monitors[$i]['Sequence'] < $minSequence) ) { + $minSequence = $monitors[$i]['Sequence']; + } + if ( $monitors[$i]['Sequence'] > $maxSequence ) { + $maxSequence = $monitors[$i]['Sequence']; + } + $monitors[$i]['zmc'] = zmcStatus( $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']) ); + $counts = array(); + 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'] ) ); + parseFilter( $filter ); + $counts[] = "count(if(1".$filter['sql'].",1,NULL)) as EventCount$j"; + $monitors[$i]['eventCounts'][$j]['filter'] = $filter; + } + $sql = "select ".join($counts,", ")." from Events as E where MonitorId = ?"; + $counts = dbFetchOne( $sql, NULL, array($monitors[$i]['Id']) ); + if ( $monitors[$i]['Function'] != 'None' ) { + $cycleCount++; + $scaleWidth = reScale( $monitors[$i]['Width'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); + $scaleHeight = reScale( $monitors[$i]['Height'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); + if ( $maxWidth < $scaleWidth ) $maxWidth = $scaleWidth; + if ( $maxHeight < $scaleHeight ) $maxHeight = $scaleHeight; + } + if ( $counts ) $monitors[$i] = array_merge( $monitors[$i], $counts ); + $seqIdList[] = $monitors[$i]['Id']; + $displayMonitors[] = $monitors[$i]; } $lastId = 0; $seqIdUpList = array(); -foreach ( $seqIdList as $seqId ) -{ - if ( !empty($lastId) ) - $seqIdUpList[$seqId] = $lastId; - else - $seqIdUpList[$seqId] = $seqId; - $lastId = $seqId; +foreach ( $seqIdList as $seqId ) { + if ( !empty($lastId) ) + $seqIdUpList[$seqId] = $lastId; + else + $seqIdUpList[$seqId] = $seqId; + $lastId = $seqId; } $lastId = 0; $seqIdDownList = array(); -foreach ( array_reverse($seqIdList) as $seqId ) -{ - if ( !empty($lastId) ) - $seqIdDownList[$seqId] = $lastId; - else - $seqIdDownList[$seqId] = $seqId; - $lastId = $seqId; +foreach ( array_reverse($seqIdList) as $seqId ) { + if ( !empty($lastId) ) + $seqIdDownList[$seqId] = $lastId; + else + $seqIdDownList[$seqId] = $seqId; + $lastId = $seqId; } $cycleWidth = $maxWidth; @@ -163,18 +154,15 @@ $eventsView = ZM_WEB_EVENTS_VIEW; $eventsWindow = 'zm'.ucfirst(ZM_WEB_EVENTS_VIEW); $eventCount = 0; -for ( $i = 0; $i < count($eventCounts); $i++ ) -{ - $eventCounts[$i]['total'] = 0; +for ( $i = 0; $i < count($eventCounts); $i++ ) { + $eventCounts[$i]['total'] = 0; } $zoneCount = 0; -foreach( $displayMonitors as $monitor ) -{ - for ( $i = 0; $i < count($eventCounts); $i++ ) - { - $eventCounts[$i]['total'] += $monitor['EventCount'.$i]; - } - $zoneCount += $monitor['ZoneCount']; +foreach( $displayMonitors as $monitor ) { + for ( $i = 0; $i < count($eventCounts); $i++ ) { + $eventCounts[$i]['total'] += $monitor['EventCount'.$i]; + } + $zoneCount += $monitor['ZoneCount']; } $seqUpFile = getSkinFile( 'graphics/seq-u.png' ); @@ -201,42 +189,34 @@ xhtmlHeaders( __FILE__, translate('Console') );

Logger::NOLOG ) { ?> / '.translate('Log').'' ) ?>
1 ) -{ +if ( canView( 'Stream' ) && $cycleCount > 1 ) { $cycleGroup = isset($_COOKIE['zmGroup'])?$_COOKIE['zmGroup']:0; ?>
-  /  -  /  - +  /  +  /  +

,  

@@ -255,8 +235,7 @@ else - + @@ -343,7 +318,7 @@ echo $Server->Name(); $domain = parse_url( $monitor['Path'], PHP_URL_HOST ); $shortpath = $domain ? $domain : preg_replace( '/^.*\//', '', $monitor['Path'] ); if ( $shortpath == '' ) { - $shortpath = 'Monitor ' . $monitor['Id']; + $shortpath = 'Monitor ' . $monitor['Id']; } ?> '.$shortpath.'', canEdit( 'Monitors' ) ) ?> @@ -353,8 +328,7 @@ echo $Server->Name();   Name(); ?> ', $monitor['Sequence']>$minSequence ) ?>', $monitor['Sequence']<$maxSequence ) ?>