diff --git a/src/Model/Event.php b/src/Model/Event.php index 28e325dbae..4e7a6a8610 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -413,9 +413,11 @@ class Event { // First day of the week (0 = Sunday). $firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week') ?? 0; + $defaultView = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'defaultView') ?? 'month'; return [ 'firstDay' => $firstDay, + 'defaultView' => $defaultView, 'allday' => DI::l10n()->t('all-day'), 'Sun' => DI::l10n()->t('Sun'), diff --git a/src/Module/Settings/Display.php b/src/Module/Settings/Display.php index a263d2992a..c1885182d3 100644 --- a/src/Module/Settings/Display.php +++ b/src/Module/Settings/Display.php @@ -51,6 +51,7 @@ class Display extends BaseSettings $mobile_theme = !empty($_POST['mobile_theme']) ? trim($_POST['mobile_theme']) : ''; $enable_smile = !empty($_POST['enable_smile']) ? intval($_POST['enable_smile']) : 0; $first_day_of_week = !empty($_POST['first_day_of_week']) ? intval($_POST['first_day_of_week']) : 0; + $calendar_default_view = !empty($_POST['calendar_default_view']) ? trim($_POST['calendar_default_view']): 'month'; $infinite_scroll = !empty($_POST['infinite_scroll']) ? intval($_POST['infinite_scroll']) : 0; $no_auto_update = !empty($_POST['no_auto_update']) ? intval($_POST['no_auto_update']) : 0; $enable_smart_threading = !empty($_POST['enable_smart_threading']) ? intval($_POST['enable_smart_threading']) : 0; @@ -96,6 +97,8 @@ class Display extends BaseSettings DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'preview_mode' , $preview_mode); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week' , $first_day_of_week); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'calendar', 'default_view' , $calendar_default_view); + if (in_array($theme, Theme::getAllowedList())) { if ($theme == $user['theme']) { // call theme_post only if theme has not been changed @@ -199,6 +202,14 @@ class Display extends BaseSettings BBCode::PREVIEW_LARGE => DI::l10n()->t('Large Image'), ]; + $calendar_default_view = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'default_view', 'month'); + $calendarViews = [ + 'month' => DI::l10n()->t('month'), + 'agendaWeek' => DI::l10n()->t('week'), + 'agendaDay' => DI::l10n()->t('day'), + 'listMonth' => DI::l10n()->t('list') + ]; + $theme_config = ''; if ($themeconfigfile = Theme::getConfigFile($theme_selected)) { require_once $themeconfigfile; @@ -235,7 +246,8 @@ class Display extends BaseSettings '$stay_local' => ['stay_local' , DI::l10n()->t('Stay local'), $stay_local, DI::l10n()->t("Don't go to a remote system when following a contact link.")], '$preview_mode' => ['preview_mode' , DI::l10n()->t('Link preview mode'), $preview_mode, 'Appearance of the link preview that is added to each post with a link.', $preview_modes, false], - '$first_day_of_week' => ['first_day_of_week', DI::l10n()->t('Beginning of week:'), $first_day_of_week, '', $weekdays, false], + '$first_day_of_week' => ['first_day_of_week' , DI::l10n()->t('Beginning of week:') , $first_day_of_week , '', $weekdays , false], + '$calendar_default_view' => ['calendar_default_view', DI::l10n()->t('Default calendar view:'), $calendar_default_view, '', $calendarViews, false], ]); return $o; diff --git a/view/templates/calendar/calendar_head.tpl b/view/templates/calendar/calendar_head.tpl index 73b0d5e7bd..b5bf8f6fec 100644 --- a/view/templates/calendar/calendar_head.tpl +++ b/view/templates/calendar/calendar_head.tpl @@ -31,6 +31,7 @@ $(document).ready(function() { $('#events-calendar').fullCalendar({ + defaultView: '{{$i18n.defaultView|escape:'quotes'}}', firstDay: '{{$i18n.firstDay|escape:'quotes'}}', monthNames: [ '{{$i18n.January|escape:'quotes'}}', diff --git a/view/templates/settings/display.tpl b/view/templates/settings/display.tpl index 7e3efc9201..e7488b1242 100644 --- a/view/templates/settings/display.tpl +++ b/view/templates/settings/display.tpl @@ -24,6 +24,7 @@

{{$calendar_title}}

{{include file="field_select.tpl" field=$first_day_of_week}} + {{include file="field_select.tpl" field=$calendar_default_view}}
diff --git a/view/theme/frio/js/mod_events.js b/view/theme/frio/js/mod_events.js index 3e3c6f422d..191742e3bd 100644 --- a/view/theme/frio/js/mod_events.js +++ b/view/theme/frio/js/mod_events.js @@ -39,7 +39,7 @@ $(document).ready(function () { }); } }, - defaultView: "month", + defaultView: aStr.defaultView, aspectRatio: 1, eventRender: function (event, element, view) { switch (view.name) { diff --git a/view/theme/frio/templates/calendar/calendar_head.tpl b/view/theme/frio/templates/calendar/calendar_head.tpl index 15f3fbcc2c..481da5f724 100644 --- a/view/theme/frio/templates/calendar/calendar_head.tpl +++ b/view/theme/frio/templates/calendar/calendar_head.tpl @@ -63,6 +63,7 @@ aStr.dtendLabel = '{{$i18n.dtend_label|escape:'quotes'}}'; aStr.locationLabel = '{{$i18n.location_label|escape:'quotes'}}'; + aStr.defaultView = '{{$i18n.defaultView|escape:'quotes'}}'; var calendar_api = '{{$calendar_api}}'; var event_api = '{{$event_api}}'; diff --git a/view/theme/frio/templates/settings/display.tpl b/view/theme/frio/templates/settings/display.tpl index 530a40a969..19a22eb070 100644 --- a/view/theme/frio/templates/settings/display.tpl +++ b/view/theme/frio/templates/settings/display.tpl @@ -86,6 +86,7 @@
{{include file="field_select.tpl" field=$first_day_of_week}} + {{include file="field_select.tpl" field=$calendar_default_view}}