]> git.mxchange.org Git - friendica.git/commitdiff
Add new calendar.default_view pconfig key
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 17 Dec 2022 07:13:33 +0000 (02:13 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 17 Dec 2022 17:20:43 +0000 (12:20 -0500)
src/Model/Event.php
src/Module/Settings/Display.php
view/templates/calendar/calendar_head.tpl
view/templates/settings/display.tpl
view/theme/frio/js/mod_events.js
view/theme/frio/templates/calendar/calendar_head.tpl
view/theme/frio/templates/settings/display.tpl

index 28e325dbae31601ffbf1a844bc5e55e2e15c83e4..4e7a6a86105771c750a52c23ada775b8bda9eb2a 100644 (file)
@@ -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'),
index a263d2992a76d36e5d25c1550cac60d05e0f2efa..c1885182d3d8947295ae2367658603489dde2d96 100644 (file)
@@ -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;
index 73b0d5e7bde808dbb83d0daa6238333d3aee8e5a..b5bf8f6fecb39ec11447b9051f6714c203ff327e 100644 (file)
@@ -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'}}',
index 7e3efc920121be8f92c067f03214d8468ee78385..e7488b1242244eb59e6fa111965c76dd08a499dd 100644 (file)
@@ -24,6 +24,7 @@
 
        <h2>{{$calendar_title}}</h2>
        {{include file="field_select.tpl" field=$first_day_of_week}}
+       {{include file="field_select.tpl" field=$calendar_default_view}}
 
        <div class="settings-submit-wrapper">
                <input type="submit" name="submit" class="settings-submit" value="{{$submit}}"/>
index 3e3c6f422d3f54523c8a9def7d5d7e1535490e0c..191742e3bd9674365c2ac3a6b841eb96b20073ad 100644 (file)
@@ -39,7 +39,7 @@ $(document).ready(function () {
                                });
                        }
                },
-               defaultView: "month",
+               defaultView: aStr.defaultView,
                aspectRatio: 1,
                eventRender: function (event, element, view) {
                        switch (view.name) {
index 15f3fbcc2c1f2d76aa3d50a6ee14af67ec57c563..481da5f724a65fe02b9845d8471dcecf461ee6b0 100644 (file)
@@ -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}}';
 
index 530a40a96934e67c19f1f33107ef0e659bc2c881..19a22eb0701d4821f50dd33582653a5b42880801 100644 (file)
@@ -86,6 +86,7 @@
                                <div id="calendar-settings-content" class="panel-collapse collapse{{if !$theme && !$mobile_theme && !$theme_config}} in{{/if}}" role="tabpanel" aria-labelledby="calendar-settings">
                                        <div class="panel-body">
                                                {{include file="field_select.tpl" field=$first_day_of_week}}
+                                               {{include file="field_select.tpl" field=$calendar_default_view}}
                                        </div>
                                        <div class="panel-footer">
                                                <button type="submit" name="submit" class="btn btn-primary" value="{{$submit}}">{{$submit}}</button>