Skip to content

Commit

Permalink
Close #12: Implement optional hourly interval
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmb69 committed Feb 5, 2017
1 parent 611a77a commit 13fff7d
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 62 deletions.
2 changes: 1 addition & 1 deletion classes/Controller.php
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion classes/WeekCalendar.php
Expand Up @@ -22,7 +22,7 @@ public function render()
$html = '<table class="ocal_calendar" data-ocal_date="'
. $this->week->getIso() . '">';
$html .= '<thead>' . $this->renderHeading() . $this->renderDaynames() . '</thead><tbody>';
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 .= '<tr>';
for ($j = 1; $j <= 7; $j++) {
$html .= $this->renderHour($j, $i);
Expand Down
13 changes: 7 additions & 6 deletions config/config.php
@@ -1,6 +1,7 @@
<?php

$plugin_cf['ocal']['hour_first']="7";
$plugin_cf['ocal']['hour_last']="19";

?>
<?php

$plugin_cf['ocal']['hour_first']="7";
$plugin_cf['ocal']['hour_interval']="1";
$plugin_cf['ocal']['hour_last']="19";

?>
55 changes: 28 additions & 27 deletions languages/de.php
@@ -1,27 +1,28 @@
<?php

$plugin_tx['ocal']['date_months']="Januar,Februar,März,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember";
$plugin_tx['ocal']['date_days']="Mo,Di,Mi,Do,Fr,Sa,So";
$plugin_tx['ocal']['label_calendar_view']="Kalenderansicht";
$plugin_tx['ocal']['label_list_view']="Listenansicht";
$plugin_tx['ocal']['label_prev_interval']="Voriger&nbsp;Zeitraum";
$plugin_tx['ocal']['label_prev_year']="Voriges&nbsp;Jahr";
$plugin_tx['ocal']['label_prev_month']="Voriger&nbsp;Monat";
$plugin_tx['ocal']['label_today']="Heute";
$plugin_tx['ocal']['label_next_month']="Nächster&nbsp;Monat";
$plugin_tx['ocal']['label_next_year']="Nächstes&nbsp;Jahr";
$plugin_tx['ocal']['label_next_interval']="Nächster&nbsp;Zeitraum";
$plugin_tx['ocal']['label_save']="Speichern";
$plugin_tx['ocal']['label_state_0']="";
$plugin_tx['ocal']['label_state_1']="verfügbar";
$plugin_tx['ocal']['label_state_2']="reserviert";
$plugin_tx['ocal']['label_state_3']="gebucht";
$plugin_tx['ocal']['message_saved']="Erfolgreich gespeichert.";
$plugin_tx['ocal']['message_unsaved_changes']="Es gibt ungesicherte Änderungen, die beim Verlassen der Seite verloren gehen!";
$plugin_tx['ocal']['error_occupancy_name']="Ein Belegungs-Name darf nur die Buchstaben a-z, die Ziffern 0-9 and Minus-Zeichen enthalten!";
$plugin_tx['ocal']['alt_logo']="Kalender";

$plugin_tx['ocal']['cf_hour_first']="Die erste Stunde, die in den stündlichen Belegungskalendern angezeigt werden soll.";
$plugin_tx['ocal']['cf_hour_last']="Die letzte Stunde, die in den stündlichen Belegungskalendern angezeigt werden soll.";

?>
<?php

$plugin_tx['ocal']['date_months']="Januar,Februar,März,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember";
$plugin_tx['ocal']['date_days']="Mo,Di,Mi,Do,Fr,Sa,So";
$plugin_tx['ocal']['label_calendar_view']="Kalenderansicht";
$plugin_tx['ocal']['label_list_view']="Listenansicht";
$plugin_tx['ocal']['label_prev_interval']="Voriger&nbsp;Zeitraum";
$plugin_tx['ocal']['label_prev_year']="Voriges&nbsp;Jahr";
$plugin_tx['ocal']['label_prev_month']="Voriger&nbsp;Monat";
$plugin_tx['ocal']['label_today']="Heute";
$plugin_tx['ocal']['label_next_month']="Nächster&nbsp;Monat";
$plugin_tx['ocal']['label_next_year']="Nächstes&nbsp;Jahr";
$plugin_tx['ocal']['label_next_interval']="Nächster&nbsp;Zeitraum";
$plugin_tx['ocal']['label_save']="Speichern";
$plugin_tx['ocal']['label_state_0']="";
$plugin_tx['ocal']['label_state_1']="verfügbar";
$plugin_tx['ocal']['label_state_2']="reserviert";
$plugin_tx['ocal']['label_state_3']="gebucht";
$plugin_tx['ocal']['message_saved']="Erfolgreich gespeichert.";
$plugin_tx['ocal']['message_unsaved_changes']="Es gibt ungesicherte Änderungen, die beim Verlassen der Seite verloren gehen!";
$plugin_tx['ocal']['error_occupancy_name']="Ein Belegungs-Name darf nur die Buchstaben a-z, die Ziffern 0-9 and Minus-Zeichen enthalten!";
$plugin_tx['ocal']['alt_logo']="Kalender";

$plugin_tx['ocal']['cf_hour_first']="Die erste Stunde, die in den stündlichen Belegungskalendern angezeigt werden soll.";
$plugin_tx['ocal']['cf_hour_interval']="Das ganzzahlige stündliche Intervall. Soll beispielsweise nur jede zweite Stunde angezeigt werden, geben Sie \"2\" ein.";
$plugin_tx['ocal']['cf_hour_last']="Die letzte Stunde, die in den stündlichen Belegungskalendern angezeigt werden soll.";

?>
55 changes: 28 additions & 27 deletions languages/en.php
@@ -1,27 +1,28 @@
<?php

$plugin_tx['ocal']['date_months']="January,February,March,April,May,June,July,August,September,October,November,December";
$plugin_tx['ocal']['date_days']="M,T,W,T,F,S,S";
$plugin_tx['ocal']['label_calendar_view']="Calendar view";
$plugin_tx['ocal']['label_list_view']="List view";
$plugin_tx['ocal']['label_prev_interval']="Previous&nbsp;interval";
$plugin_tx['ocal']['label_prev_year']="Previous&nbsp;Year";
$plugin_tx['ocal']['label_prev_month']="Previous&nbsp;Month";
$plugin_tx['ocal']['label_today']="Today";
$plugin_tx['ocal']['label_next_month']="Next&nbsp;Month";
$plugin_tx['ocal']['label_next_year']="Next&nbsp;Year";
$plugin_tx['ocal']['label_next_interval']="Next&nbsp;interval";
$plugin_tx['ocal']['label_save']="Save";
$plugin_tx['ocal']['label_state_0']="";
$plugin_tx['ocal']['label_state_1']="available";
$plugin_tx['ocal']['label_state_2']="reserved";
$plugin_tx['ocal']['label_state_3']="booked";
$plugin_tx['ocal']['message_saved']="Successfully saved.";
$plugin_tx['ocal']['message_unsaved_changes']="There are unsaved changes that will be lost when leaving the page!";
$plugin_tx['ocal']['error_occupancy_name']="An occupancy name may only contain the letters a-z, the digits 0-9 and minus signs!";
$plugin_tx['ocal']['alt_logo']="Calendar";

$plugin_tx['ocal']['cf_hour_first']="The first hour that shall be displayed in the hourly occupancy calendars.";
$plugin_tx['ocal']['cf_hour_last']="The last hour that shall be displayed in the hourly occupancy calendars.";

?>
<?php

$plugin_tx['ocal']['date_months']="January,February,March,April,May,June,July,August,September,October,November,December";
$plugin_tx['ocal']['date_days']="M,T,W,T,F,S,S";
$plugin_tx['ocal']['label_calendar_view']="Calendar view";
$plugin_tx['ocal']['label_list_view']="List view";
$plugin_tx['ocal']['label_prev_interval']="Previous&nbsp;interval";
$plugin_tx['ocal']['label_prev_year']="Previous&nbsp;Year";
$plugin_tx['ocal']['label_prev_month']="Previous&nbsp;Month";
$plugin_tx['ocal']['label_today']="Today";
$plugin_tx['ocal']['label_next_month']="Next&nbsp;Month";
$plugin_tx['ocal']['label_next_year']="Next&nbsp;Year";
$plugin_tx['ocal']['label_next_interval']="Next&nbsp;interval";
$plugin_tx['ocal']['label_save']="Save";
$plugin_tx['ocal']['label_state_0']="";
$plugin_tx['ocal']['label_state_1']="available";
$plugin_tx['ocal']['label_state_2']="reserved";
$plugin_tx['ocal']['label_state_3']="booked";
$plugin_tx['ocal']['message_saved']="Successfully saved.";
$plugin_tx['ocal']['message_unsaved_changes']="There are unsaved changes that will be lost when leaving the page!";
$plugin_tx['ocal']['error_occupancy_name']="An occupancy name may only contain the letters a-z, the digits 0-9 and minus signs!";
$plugin_tx['ocal']['alt_logo']="Calendar";

$plugin_tx['ocal']['cf_hour_first']="The first hour that shall be displayed in the hourly occupancy calendars.";
$plugin_tx['ocal']['cf_hour_interval']="The integral hourly interval. For instance, if only every second hour should be shown, enter \"2\".";
$plugin_tx['ocal']['cf_hour_last']="The last hour that shall be displayed in the hourly occupancy calendars.";

?>

0 comments on commit 13fff7d

Please sign in to comment.