set($_REQUEST['filter']); } parseSort(); $filterQuery = $filter->querystring(); ZM\Debug('Filter '.print_r($filter, true)); if ( $filter->sql() ) { $eventsSql .= ' AND ('.$filter->sql().')'; } else { ZM\Warning('No filters'); exit; } $eventsSql .= ' ORDER BY '.$sortColumn.' '.$sortOrder; if ( $sortColumn != 'E.Id' ) $eventsSql .= ',E.Id '.$sortOrder; $page = isset($_REQUEST['page']) ? validInt($_REQUEST['page']) : 0; $limit = isset($_REQUEST['limit']) ? validInt($_REQUEST['limit']) : $filter['limit']; if ( $_POST ) { // I think this is basically so that a refresh doesn't repost ZM\Debug('Redirecting to ' . $_SERVER['REQUEST_URI']); header('Location: ?view=' . $view.htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page); exit(); } $failed = !$filter->test_pre_sql_conditions(); if ( $failed ) { ZM\Debug('Pre conditions failed, not doing sql'); } $results = $failed ? null : dbQuery($eventsSql); $nEvents = $results ? $results->rowCount() : 0; if ( ! $results ) { global $error_message; $error_message = dbError($eventsSql); } ZM\Debug("Pre conditions succeeded sql return $nEvents events"); if ( !empty($limit) && ($nEvents > $limit) ) { $nEvents = $limit; } $pages = (int)ceil($nEvents/ZM_WEB_EVENTS_PER_PAGE); #Debug("Page $page Limit $limit #vents: $nEvents pages: $pages "); 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; } $eventsSql .= ' LIMIT '.$limitStart.', '.$limitAmount; } else if ( !empty($limit) ) { $eventsSql .= ' LIMIT 0, '.$limit; } $maxShortcuts = 5; $focusWindow = true; $storage_areas = ZM\Storage::find(); $StorageById = array(); foreach ( $storage_areas as $S ) { $StorageById[$S->Id()] = $S; } xhtmlHeaders(__FILE__, translate('Events')); getBodyTopHTML(); ?>
1 ) { ?> test_post_sql_conditions($event) ) { $event->remove_from_cache(); continue; } $events[] = $event; if ( $limit and (count($events) >= $limit) ) { break; } ZM\Debug("Have " . count($events) . " events, limit $limit"); } foreach ( $events as $event ) { $scale = max(reScale(SCALE_BASE, $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE), SCALE_BASE); ?> Archived() ? ' class="archived"' : '' ?>> 1 ) { ?> DiskSpace(); ?> '; $imgSrc = $event->getThumbnailSrc(array(),'&'); $streamSrc = $event->getStreamSrc(array( 'mode'=>'jpeg', 'scale'=>$scale, 'maxfps'=>ZM_WEB_VIDEO_MAXFPS, 'replay'=>'single', 'rate'=>'400'), '&'); $imgHtml = ''. validHtmlStr('Event '.$event->Id()) .''; echo ''.$imgHtml.''; echo ''; } // end if ZM_WEB_LIST_THUMBS ?> 1 ) { ?>