diff --git a/web/includes/functions.php b/web/includes/functions.php index 29293afde..e1016bb82 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -1077,13 +1077,28 @@ function parseSort( $saveToSession=false, $querySep='&' ) { case 'MaxScore' : $sortColumn = 'E.MaxScore'; break; + case 'FramesFrameId' : + $sortColumn = 'F.FrameId'; + break; + case 'FramesType' : + $sortColumn = 'F.Type'; + break; + case 'FramesTimeStamp' : + $sortColumn = 'F.TimeStamp'; + break; + case 'FramesDelta' : + $sortColumn = 'F.Delta'; + break; + case 'FramesScore' : + $sortColumn = 'F.Score'; + break; default: $sortColumn = 'E.StartTime'; break; } - $sortOrder = $_REQUEST['sort_asc']?'asc':'desc'; if ( !$_REQUEST['sort_asc'] ) $_REQUEST['sort_asc'] = 0; + $sortOrder = $_REQUEST['sort_asc']?'asc':'desc'; $sortQuery = $querySep.'sort_field='.validHtmlStr($_REQUEST['sort_field']).$querySep.'sort_asc='.validHtmlStr($_REQUEST['sort_asc']); if ( !isset($_REQUEST['limit']) ) $_REQUEST['limit'] = ''; @@ -1168,6 +1183,9 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') { case 'StartDateTime': $filter['sql'] .= 'E.StartTime'; break; + case 'FramesEventId': + $filter['sql'] .= 'F.EventId'; + break; case 'StartDate': $filter['sql'] .= 'to_days( E.StartTime )'; break; diff --git a/web/skins/classic/views/frames.php b/web/skins/classic/views/frames.php index 17ed9c2f2..9a877ae3b 100644 --- a/web/skins/classic/views/frames.php +++ b/web/skins/classic/views/frames.php @@ -22,8 +22,44 @@ if ( !canView('Events') ) { $view = 'error'; return; } + require_once('includes/Frame.php'); -$Event = new ZM\Event($_REQUEST['eid']); + +$countSql = 'SELECT COUNT(*) AS FrameCount FROM Frames AS F WHERE 1 '; +$frameSql = 'SELECT *, unix_timestamp( TimeStamp ) AS UnixTimeStamp FROM Frames AS F WHERE 1 '; + +$eid = $_REQUEST['eid']; + +// override the sort_field handling in parseSort for frames +if ( empty($_REQUEST['sort_field']) ) + $_REQUEST['sort_field'] = 'FramesTimeStamp'; + +if ( !isset($_REQUEST['sort_asc']) ) + $_REQUEST['sort_asc'] = true; + +if( ! isset($_REQUEST['filter'])){ + // generate a dummy filter from the eid for pagination + $_REQUEST['filter'] = array('Query' => array( 'terms' => array( ) ) ); + $_REQUEST['filter'] = addFilterTerm( + $_REQUEST['filter'], + 0, + array( 'cnj' => 'and', 'attr' => 'FramesEventId', 'op' => '=', 'val' => $eid ) + ); +} + +parseSort(); +parseFilter($_REQUEST['filter']); +$filterQuery = $_REQUEST['filter']['query']; + + +if ( $_REQUEST['filter']['sql'] ) { + $countSql .= $_REQUEST['filter']['sql']; + $frameSql .= $_REQUEST['filter']['sql']; +} + +$frameSql .= " ORDER BY $sortColumn $sortOrder,Id $sortOrder"; + +$Event = new ZM\Event($eid); $Monitor = $Event->Monitor(); if ( isset( $_REQUEST['scale'] ) ) { @@ -35,8 +71,40 @@ if ( isset( $_REQUEST['scale'] ) ) { } else { $scale = max(reScale(SCALE_BASE, $Monitor->DefaultScale(), ZM_WEB_DEFAULT_SCALE), SCALE_BASE); } -$sql = 'SELECT *, unix_timestamp(TimeStamp) AS UnixTimeStamp FROM Frames WHERE EventID = ? ORDER BY FrameId'; -$frames = dbFetchAll($sql, NULL, array($_REQUEST['eid'])); + +$page = isset($_REQUEST['page']) ? validInt($_REQUEST['page']) : 1; +$limit = isset($_REQUEST['limit']) ? validInt($_REQUEST['limit']) : 0; + +$nEvents = dbFetchOne($countSql, 'FrameCount' ); + +if ( !empty($limit) && $nEvents > $limit ) { + $nEvents = $limit; +} + +$pages = (int)ceil($nEvents/ZM_WEB_EVENTS_PER_PAGE); + +if ( !empty($page) ) { + if ( $page < 0 ) + $page = 1; + else if ( $pages and ( $page > $pages ) ) + $page = $pages; + + $limitStart = (($page-1)*ZM_WEB_EVENTS_PER_PAGE); + if ( empty( $limit ) ) { + $limitAmount = ZM_WEB_EVENTS_PER_PAGE; + } else { + $limitLeft = $limit - $limitStart; + $limitAmount = ($limitLeft>ZM_WEB_EVENTS_PER_PAGE)?ZM_WEB_EVENTS_PER_PAGE:$limitLeft; + } + $frameSql .= " limit $limitStart, $limitAmount"; +} elseif ( !empty($limit) ) { + $frameSql .= ' limit 0, '.$limit; +} + +$maxShortcuts = 5; +$pagination = getPagination($pages, $page, $maxShortcuts, $sortQuery.'&eid='.$eid.$limitQuery.$filterQuery); + +$frames = dbFetchAll( $frameSql ); $focusWindow = true; @@ -47,18 +115,48 @@ xhtmlHeaders(__FILE__, translate('Frames').' - '.$Event->Id());
+ + + + + + + + - - - - - + + + + + @@ -122,6 +220,15 @@ if ( count($frames) ) { ?>
+ + +

+ +