+ extract($date_matches); // Just for easier access to match variables
+
+ // Bail out on nonsensical dates
+ if (isset($start_date) && isset($end_date) && ($start_date > $end_date)) {
+ return false;
+ }
+
+ return $date_matches;
+ }
+
+ // Since the report date can be in different formats (ie. YYYY, YYYY-MM or a full range)
+ // and this format determines the report mode (range, month or year), we have to figure out
+ // the mode and full starting and ending dates, as necessary
+ public function getReportSettings($date, $fluidbook)
+ {
+ $date_matches = $this->parseDate($date);
+
+ // ...
+
+ // TODO: centralise all mode + start / end date logic here... then in the main report function, we can use the returned mode in a switch() statement to clean things up a lot.
+
+
+ }
+
+ // Figure out the best period to use for the stats according to the date range
+ public function determinePeriod($dates, $fluidbook)
+ {
+
+ // TODO: refactor this into getReportSettings() so that this function can simply take the determined start and end dates, calculate the number of days and give an answer based on that. No extra logic to try to figure out which mode it is...
+
+ // If no valid date range is given, use the Fluidbook's lifetime