From 27ac7a585c93e3d3c40e46cec2b40247fa121f83 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 18 Aug 2022 10:37:17 -0400 Subject: [PATCH] If current time is specified, calculate minTime and maxTime from it. --- web/skins/classic/views/montagereview.php | 68 +++++++++++++---------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/web/skins/classic/views/montagereview.php b/web/skins/classic/views/montagereview.php index 4c9b5557b..b02570d7c 100644 --- a/web/skins/classic/views/montagereview.php +++ b/web/skins/classic/views/montagereview.php @@ -29,12 +29,14 @@ // Valid query string: // // &maxTime, minTime = string formats (locale) of starting and ending time for history (pass both or none), default = last hour +// if not specified, but current is, then should center 1 hour on current // // ¤t = string format of time, where the slider is positioned first in history mode (normally only used in reloads, default = half scale) +// also used when jumping from event view to montagereview // // &speed = one of the valid speeds below (see $speeds in php section, default = 1.0) // -// &scale = image sie scale (.1 to 1.0, or 1.1 = fit, default = fit) +// &scale = image size scale (.1 to 1.0, or 1.1 = fit, default = fit) // // &live=1 whether to start in live mode, 1 = yes, 0 = no // @@ -59,12 +61,47 @@ include('_monitor_filters.php'); $filter_bar = ob_get_contents(); ob_end_clean(); +// Parse input parameters -- note for future, validate/clean up better in case we don't get called from self. +// Live overrides all the min/max stuff but it is still processed + +// The default (nothing at all specified) is for 1 hour so we do not read the whole database + +if (isset($_REQUEST['current'])) { + $defaultCurrentTime = validHtmlStr($_REQUEST['current']); + $defaultCurrentTimeSecs = strtotime($defaultCurrentTime); +} + +if ( !isset($_REQUEST['minTime']) && !isset($_REQUEST['maxTime']) ) { + if (isset($defaultCurrentTimeSecs)) { + $minTime = date('c', $defaultCurrentTimeSecs - 1800); + $maxTime = date('c', $defaultCurrentTimeSecs + 1800); + } else { + $time = time(); + $maxTime = date('c', $time); + $minTime = date('c', $time - 3600); + } +} else { + if (isset($_REQUEST['minTime'])) + $minTime = validHtmlStr($_REQUEST['minTime']); + + if (isset($_REQUEST['maxTime'])) + $maxTime = validHtmlStr($_REQUEST['maxTime']); +} + +// AS a special case a "all" is passed in as an extreme interval - if so, clear them here and let the database query find them + +if ( (strtotime($maxTime) - strtotime($minTime))/(365*24*3600) > 30 ) { + // test years + $minTime = null; + $maxTime = null; +} + $filter = array(); -if ( isset($_REQUEST['filter']) ) { +if (isset($_REQUEST['filter'])) { $filter = $_REQUEST['filter']; # Try to guess min/max time from filter - foreach ( $filter['Query'] as $term ) { + foreach ($filter['Query'] as $term) { if ( $term['attr'] == 'StartDateTime' ) { if ( $term['op'] == '<=' or $term['op'] == '<' ) { $maxTime = $term['val']; @@ -160,29 +197,6 @@ if ( isset($_SESSION['archive_status']) ) { } } -// Parse input parameters -- note for future, validate/clean up better in case we don't get called from self. -// Live overrides all the min/max stuff but it is still processed - -// The default (nothing at all specified) is for 1 hour so we do not read the whole database - -if ( !isset($_REQUEST['minTime']) && !isset($_REQUEST['maxTime']) ) { - $time = time(); - $maxTime = date('c', $time); - $minTime = date('c', $time - 3600); -} -if ( isset($_REQUEST['minTime']) ) - $minTime = validHtmlStr($_REQUEST['minTime']); - -if ( isset($_REQUEST['maxTime']) ) - $maxTime = validHtmlStr($_REQUEST['maxTime']); - -// AS a special case a "all" is passed in as an extreme interval - if so, clear them here and let the database query find them - -if ( (strtotime($maxTime) - strtotime($minTime))/(365*24*3600) > 30 ) { - // test years - $minTime = null; - $maxTime = null; -} $fitMode = 1; if ( isset($_REQUEST['fit']) && ($_REQUEST['fit'] == '0') ) @@ -208,8 +222,6 @@ for ( $i = 0; $i < count($speeds); $i++ ) { } } -if ( isset($_REQUEST['current']) ) - $defaultCurrentTime = validHtmlStr($_REQUEST['current']); $liveMode = 1; // default to live if ( isset($_REQUEST['live']) && ($_REQUEST['live'] == '0') )