From 13fff7dcd5c39ffa987550c71b50989fd917f3f8 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 5 Feb 2017 16:02:07 +0100 Subject: [PATCH] Close #12: Implement optional hourly interval For several purposes hourly intervals are not suitable, so we make the interval configurable. For now, we only accept integral intervals, because fractions would require a modification of the storage format, and that feature has not yet been requested. --- classes/Controller.php | 2 +- classes/WeekCalendar.php | 2 +- config/config.php | 13 +++++----- languages/de.php | 55 ++++++++++++++++++++-------------------- languages/en.php | 55 ++++++++++++++++++++-------------------- 5 files changed, 65 insertions(+), 62 deletions(-) diff --git a/classes/Controller.php b/classes/Controller.php index 955eeb4..5ea5638 100644 --- a/classes/Controller.php +++ b/classes/Controller.php @@ -231,7 +231,7 @@ protected function saveHourlyStates($name) foreach (get_object_vars($states) as $week => $states) { foreach ($states as $i => $state) { $day = $i % 7 + 1; - $hour = $i / 7 + $plugin_cf['ocal']['hour_first']; + $hour = $plugin_cf['ocal']['hour_interval'] * (int) ($i / 7) + $plugin_cf['ocal']['hour_first']; $date = sprintf('%s-%02d-%02d', $week, $day, $hour); $occupancy->setState($date, $state); } diff --git a/classes/WeekCalendar.php b/classes/WeekCalendar.php index 451fe42..4319a73 100644 --- a/classes/WeekCalendar.php +++ b/classes/WeekCalendar.php @@ -22,7 +22,7 @@ public function render() $html = ''; $html .= '' . $this->renderHeading() . $this->renderDaynames() . ''; - for ($i = $pcf['hour_first']; $i <= $pcf['hour_last']; $i++) { + for ($i = $pcf['hour_first']; $i <= $pcf['hour_last']; $i += $plugin_cf['ocal']['hour_interval']) { $html .= ''; for ($j = 1; $j <= 7; $j++) { $html .= $this->renderHour($j, $i); diff --git a/config/config.php b/config/config.php index c6f7b93..af3e2d1 100644 --- a/config/config.php +++ b/config/config.php @@ -1,6 +1,7 @@ - + diff --git a/languages/de.php b/languages/de.php index 7df1143..aa4af53 100644 --- a/languages/de.php +++ b/languages/de.php @@ -1,27 +1,28 @@ - + diff --git a/languages/en.php b/languages/en.php index 0850a3b..19e4f08 100644 --- a/languages/en.php +++ b/languages/en.php @@ -1,27 +1,28 @@ - +