Move code to generate Source from console into Monitor Object

This commit is contained in:
Isaac Connor committed 2018-05-04 06:46:46 -07:00
1 parent 8f45b50947
commit 3fd953a4eb
2 files changed
+30 -26

No files matched your search

+28
View File
@@ -467,5 +467,33 @@ private $control_fields = array(
}
return $this->{'Storage'};
}
public function Source( ) {
$source = '';
if ( $this->{'Type'} == 'Local' ) {
$source = $this->{'Device'}.' ('.$this->{'Channel'}.')';
} elseif ( $this->{'Type'} == 'Remote' ) {
$source = preg_replace( '/^.*@/', '', $this->{'Host'} );
if ( $this->{'Port'} != '80' and $this->{'Port'} != '554' ) {
$source .= ':'.$this->{'Port'};
}
} elseif ( $this->{'Type'} == 'File' || $this->{'Type'} == 'cURL' ) {
$source = preg_replace( '/^.*\//', '', $this->{'Path'} );
} elseif ( $this->{'Type'} == 'Ffmpeg' || $this->{'Type'} == 'Libvlc' || $this->{'Type'} == 'WebSite' ) {
$url_parts = parse_url( $this->{'Path'} );
unset($url_parts['user']);
unset($url_parts['pass']);
unset($url_parts['scheme']);
unset($url_parts['query']);
unset($url_parts['path']);
if ( isset($url_parts['port']) and ( $url_parts['port'] == '80' or $url_parts['port'] == '554' ) )
unset($url_parts['port']);
$source = unparse_url($url_parts);
}
if ( $source == '' ) {
$source = 'Monitor ' . $this->{'Id'};
}
return $source;
} // end function Source
} // end class Monitor
?>
+2 -26
View File
@@ -304,31 +304,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
<td class="colServer"><?php $Server = isset($ServersById[$monitor['ServerId']]) ? $ServersById[$monitor['ServerId']] : new Server( $monitor['ServerId'] ); echo $Server->Name(); ?></td>
<?php
}
$source = '';
if ( $monitor['Type'] == 'Local' ) {
$source = $monitor['Device'].' ('.$monitor['Channel'].')';
} elseif ( $monitor['Type'] == 'Remote' ) {
$source = preg_replace( '/^.*@/', '', $monitor['Host'] );
if ( $monitor['Port'] != '80' and $monitor['Port'] != '554' ) {
$source .= ':'.$monitor['Port'];
}
} elseif ( $monitor['Type'] == 'File' || $monitor['Type'] == 'cURL' ) {
$source = preg_replace( '/^.*\//', '', $monitor['Path'] );
} elseif ( $monitor['Type'] == 'Ffmpeg' || $monitor['Type'] == 'Libvlc' || $monitor['Type'] == 'WebSite' ) {
$url_parts = parse_url( $monitor['Path'] );
unset($url_parts['user']);
unset($url_parts['pass']);
unset($url_parts['scheme']);
unset($url_parts['query']);
unset($url_parts['path']);
if ( isset($url_parts['port']) and ( $url_parts['port'] == '80' or $url_parts['port'] == '554' ) )
unset($url_parts['port']);
$source = unparse_url( $url_parts );
}
if ( $source == '' ) {
$source = 'Monitor ' . $monitor['Id'];
}
echo '<td class="colSource">'. makePopupLink( '?view=monitor&amp;mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$source_class.'">'.$source.'</span>', canEdit( 'Monitors' ) ).'</td>';
echo '<td class="colSource">'. makePopupLink( '?view=monitor&amp;mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$source_class.'">'.$Monitor->Source().'</span>', canEdit('Monitors') ).'</td>';
if ( $show_storage_areas ) {
?>
<td class="colStorage"><?php if ( isset($StorageById[$monitor['StorageId']]) ) { echo $StorageById[ $monitor['StorageId'] ]->Name(); } ?></td>
@@ -342,7 +318,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
<?php
}
?>
<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
if ( canEdit('Monitors') ) {
?>