Add new calendar.default_view pconfig key

This commit is contained in:
Hypolite Petovan 2022-12-17 02:13:33 -05:00
parent 83e34ef8e7
commit cdf180c58d
7 changed files with 20 additions and 2 deletions

View 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'),

View 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;

View 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'}}',

View 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}}"/>

View file

@ -39,7 +39,7 @@ $(document).ready(function () {
});
}
},
defaultView: "month",
defaultView: aStr.defaultView,
aspectRatio: 1,
eventRender: function (event, element, view) {
switch (view.name) {

View 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}}';

View 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>