Add thumbnanils to the frames view. Also add a content-disposition header and some url mangling to help browsers give a useful filename when doing Save Image As
This commit is contained in:
parent
4fe6b6f8b7
commit
6bf921a858
|
@ -70,7 +70,7 @@ class Frame {
|
|||
}
|
||||
|
||||
public function getImageSrc( $show='capture' ) {
|
||||
return $_SERVER['PHP_SELF'].'?view=image&fid='.$this->{'Id'}.'&show='.$show;;
|
||||
return $_SERVER['PHP_SELF'].'?view=image&fid='.$this->{'Id'}.'&show='.$show.'&filename='.$this->{'MonitorId'}.'_'.$this->{'EventId'}.'_'.$this->{'FrameId'}.'.jpg';
|
||||
} // end function getImageSrc
|
||||
|
||||
public static function find( $parameters = array(), $limit = NULL ) {
|
||||
|
|
|
@ -40,7 +40,7 @@ var popupSizes = {
|
|||
'filter': { 'width': 820, 'height': 360 },
|
||||
'filtersave': { 'width': 610, 'height': 120 },
|
||||
'frame': { 'addWidth': 32, 'minWidth': 384, 'addHeight': 100 },
|
||||
'frames': { 'width': 500, 'height': 600 },
|
||||
'frames': { 'width': 600, 'height': 600 },
|
||||
'function': { 'width': 300, 'height': 92 },
|
||||
'group': { 'width': 360, 'height': 180 },
|
||||
'groups': { 'width': 440, 'height': 220 },
|
||||
|
|
|
@ -40,7 +40,7 @@ var popupSizes = {
|
|||
'filter': { 'width': 900, 'height': 600 },
|
||||
'filtersave': { 'width': 610, 'height': 260 },
|
||||
'frame': { 'addWidth': 32, 'minWidth': 384, 'addHeight': 100 },
|
||||
'frames': { 'width': 500, 'height': 600 },
|
||||
'frames': { 'width': 600, 'height': 600 },
|
||||
'function': { 'width': 300, 'height': 160 },
|
||||
'group': { 'width': 360, 'height': 300 },
|
||||
'groups': { 'width': 540, 'height': 420 },
|
||||
|
|
|
@ -40,7 +40,7 @@ var popupSizes = {
|
|||
'filter': { 'width': 900, 'height': 600 },
|
||||
'filtersave': { 'width': 610, 'height': 260 },
|
||||
'frame': { 'addWidth': 32, 'minWidth': 384, 'addHeight': 100 },
|
||||
'frames': { 'width': 500, 'height': 600 },
|
||||
'frames': { 'width': 600, 'height': 600 },
|
||||
'function': { 'width': 300, 'height': 160 },
|
||||
'group': { 'width': 360, 'height': 300 },
|
||||
'groups': { 'width': 540, 'height': 420 },
|
||||
|
|
|
@ -18,26 +18,25 @@
|
|||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
if ( !canView( 'Events' ) )
|
||||
{
|
||||
$view = "error";
|
||||
if ( !canView( 'Events' ) ) {
|
||||
$view = 'error';
|
||||
return;
|
||||
}
|
||||
$sql = 'SELECT E.*,M.Name AS MonitorName FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?';
|
||||
$event = dbFetchOne( $sql, NULL, array($_REQUEST['eid']) );
|
||||
require_once( 'includes/Frame.php' );
|
||||
$Event = new Event( $_REQUEST['eid'] );
|
||||
|
||||
$sql = 'SELECT *, unix_timestamp( TimeStamp ) AS UnixTimeStamp FROM Frames WHERE EventID = ? ORDER BY FrameId';
|
||||
$frames = dbFetchAll( $sql, NULL, array( $_REQUEST['eid'] ) );
|
||||
|
||||
$focusWindow = true;
|
||||
|
||||
xhtmlHeaders(__FILE__, translate('Frames')." - ".$event['Id'] );
|
||||
xhtmlHeaders(__FILE__, translate('Frames')." - ".$Event->Id() );
|
||||
?>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div id="header">
|
||||
<div id="headerButtons"><a href="#" onclick="closeWindow();"><?php echo translate('Close') ?></a></div>
|
||||
<h2><?php echo translate('Frames') ?> - <?php echo $event['Id'] ?></h2>
|
||||
<h2><?php echo translate('Frames') ?> - <?php echo $Event->Id() ?></h2>
|
||||
</div>
|
||||
<div id="content">
|
||||
<form name="contentForm" id="contentForm" method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
|
||||
|
@ -50,18 +49,25 @@ xhtmlHeaders(__FILE__, translate('Frames')." - ".$event['Id'] );
|
|||
<th class="colTimeStamp"><?php echo translate('TimeStamp') ?></th>
|
||||
<th class="colTimeDelta"><?php echo translate('TimeDelta') ?></th>
|
||||
<th class="colScore"><?php echo translate('Score') ?></th>
|
||||
<?php
|
||||
if ( ZM_WEB_LIST_THUMBS ) {
|
||||
?>
|
||||
<th class="colThumbnail"><?php echo translate('Thumbnail') ?></th>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( count($frames) )
|
||||
{
|
||||
foreach ( $frames as $frame )
|
||||
{
|
||||
if ( count($frames) ) {
|
||||
foreach ( $frames as $frame ) {
|
||||
$Frame = new Frame( $frame );
|
||||
|
||||
$class = strtolower($frame['Type']);
|
||||
?>
|
||||
<tr class="<?php echo $class ?>">
|
||||
<td class="colId"><?php echo makePopupLink( '?view=frame&eid='.$event['Id'].'&fid='.$frame['FrameId'], 'zmImage', array( 'frame', $event['Width'], $event['Height'] ), $frame['FrameId'] ) ?></td>
|
||||
<td class="colId"><?php echo makePopupLink( '?view=frame&eid='.$Event->Id().'&fid='.$frame['FrameId'], 'zmImage', array( 'frame', $Event->Width(), $Event->Height() ), $frame['FrameId'] ) ?></td>
|
||||
<td class="colType"><?php echo $frame['Type'] ?></td>
|
||||
<td class="colTimeStamp"><?php echo strftime( STRF_FMT_TIME, $frame['UnixTimeStamp'] ) ?></td>
|
||||
<td class="colTimeDelta"><?php echo number_format( $frame['Delta'], 2 ) ?></td>
|
||||
|
@ -69,7 +75,7 @@ if ( count($frames) )
|
|||
if ( ZM_RECORD_EVENT_STATS && ($frame['Type'] == 'Alarm') )
|
||||
{
|
||||
?>
|
||||
<td class="colScore"><?php echo makePopupLink( '?view=stats&eid='.$event['Id'].'&fid='.$frame['FrameId'], 'zmStats', 'stats', $frame['Score'] ) ?></td>
|
||||
<td class="colScore"><?php echo makePopupLink( '?view=stats&eid='.$Event->Id().'&fid='.$frame['FrameId'], 'zmStats', 'stats', $frame['Score'] ) ?></td>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
|
@ -78,7 +84,16 @@ if ( count($frames) )
|
|||
<td class="colScore"><?php echo $frame['Score'] ?></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
if ( ZM_WEB_LIST_THUMBS ) {
|
||||
?>
|
||||
<td class="colThumbnail"><?php echo makePopupLink( '?view=frame&eid='.$Event->Id().'&fid='.$frame['FrameId'], 'zmImage', array( 'image', $Event->Width(), $Event->Height() ), '<img src="?view=image&fid='.$Frame->Id().'&'.
|
||||
(ZM_WEB_LIST_THUMB_WIDTH?'width='.ZM_WEB_LIST_THUMB_WIDTH.'&':'').
|
||||
(ZM_WEB_LIST_THUMB_HEIGHT?'height='.ZM_WEB_LIST_THUMB_HEIGHT.'&':'').'filename='.$Event->MonitorId().'_'.$frame['EventId'].'_'.$frame['FrameId'].'.jpg" '.
|
||||
(ZM_WEB_LIST_THUMB_WIDTH?'width="'.ZM_WEB_LIST_THUMB_WIDTH.'" ':'').
|
||||
(ZM_WEB_LIST_THUMB_HEIGHT?'height="'.ZM_WEB_LIST_THUMB_HEIGHT.'" ':'').'alt="'.$frame['FrameId'].'"/>' ) ?></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
|
|
@ -53,22 +53,27 @@ if (!function_exists('imagescale')) {
|
|||
}
|
||||
|
||||
$errorText = false;
|
||||
$filename = '';
|
||||
|
||||
if ( empty($_REQUEST['path']) ) {
|
||||
if ( ! empty($_REQUEST['fid']) ) {
|
||||
$show = empty($_REQUEST['show']) ? 'capture' : $_REQUEST['show'];
|
||||
$Frame = null;
|
||||
$Event = null;
|
||||
|
||||
if ( ! empty($_REQUEST['eid'] ) ) {
|
||||
$Event = new Event( $_REQUEST['eid'] );
|
||||
$Frame = Frame::find_one( array( 'EventId' => $_REQUEST['eid'], 'FrameId' => $_REQUEST['fid'] ) );
|
||||
if ( ! $Frame ) {
|
||||
Fatal("No Frame found for event(".$_REQUEST['eid'].") and frame id(".$_REQUEST['fid'].")");
|
||||
}
|
||||
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$_REQUEST['fid']).'-'.$show.'.jpg';
|
||||
} else {
|
||||
# If we are only specifying fid, then the fid must be the primary key into the frames table. But when the event is specified, then it is the frame #
|
||||
$Frame = new Frame( $_REQUEST['fid'] );
|
||||
$Event = new Event( $Frame->EventId() );
|
||||
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
|
||||
}
|
||||
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
|
||||
|
||||
} else {
|
||||
$errorText = 'No image path';
|
||||
}
|
||||
|
@ -141,6 +146,10 @@ if( !empty($_REQUEST['height']) ) {
|
|||
}
|
||||
|
||||
header( 'Content-type: image/jpeg' );
|
||||
|
||||
# This is so that Save Image As give a useful filename
|
||||
$filename = $Event->MonitorId().'_'.$Event->Id().'_'.$Frame->FrameId().'.jpg';
|
||||
header('Content-Disposition: inline; filename="' . $filename . '"');
|
||||
ob_clean();
|
||||
flush();
|
||||
|
||||
|
|
Loading…
Reference in New Issue