From 5817709562502b8bb823633da85eb51f93aea502 Mon Sep 17 00:00:00 2001 From: Matthias Moritz Date: Wed, 7 Dec 2022 22:57:11 +0100 Subject: [PATCH 1/4] Move vier version of calendat/calendar_head template to base - With the support for the remaining themes dropped, the base template wasn't used anymore --- view/templates/calendar/calendar_head.tpl | 80 ++++---- .../vier/templates/calendar/calendar_head.tpl | 178 ------------------ 2 files changed, 32 insertions(+), 226 deletions(-) delete mode 100644 view/theme/vier/templates/calendar/calendar_head.tpl diff --git a/view/templates/calendar/calendar_head.tpl b/view/templates/calendar/calendar_head.tpl index 50fb3fe4d..73b0d5e7b 100644 --- a/view/templates/calendar/calendar_head.tpl +++ b/view/templates/calendar/calendar_head.tpl @@ -1,3 +1,8 @@ + + + + + diff --git a/view/theme/vier/templates/calendar/calendar_head.tpl b/view/theme/vier/templates/calendar/calendar_head.tpl deleted file mode 100644 index e0c5b9e75..000000000 --- a/view/theme/vier/templates/calendar/calendar_head.tpl +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - - - From 83e34ef8e7f2e36cd98cfa754e524fcc18b9a5ec Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 17 Dec 2022 02:07:46 -0500 Subject: [PATCH 2/4] Move first_day_of_week pconfig key to calendar category --- database.sql | 2 +- src/Model/Event.php | 100 ++++++++++++++++---------------- src/Module/Settings/Display.php | 2 +- static/dbstructure.config.php | 2 +- update.php | 8 ++- 5 files changed, 59 insertions(+), 55 deletions(-) diff --git a/database.sql b/database.sql index 49f282db0..ebae14436 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2022.12-rc (Giant Rhubarb) --- DB_UPDATE_VERSION 1501 +-- DB_UPDATE_VERSION 1502 -- ------------------------------------------ diff --git a/src/Model/Event.php b/src/Model/Event.php index 06d391745..28e325dba 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -412,66 +412,64 @@ class Event public static function getStrings(): array { // First day of the week (0 = Sunday). - $firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week', 0); + $firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week') ?? 0; - $i18n = [ - "firstDay" => $firstDay, - "allday" => DI::l10n()->t("all-day"), + return [ + 'firstDay' => $firstDay, + 'allday' => DI::l10n()->t('all-day'), - "Sun" => DI::l10n()->t("Sun"), - "Mon" => DI::l10n()->t("Mon"), - "Tue" => DI::l10n()->t("Tue"), - "Wed" => DI::l10n()->t("Wed"), - "Thu" => DI::l10n()->t("Thu"), - "Fri" => DI::l10n()->t("Fri"), - "Sat" => DI::l10n()->t("Sat"), + 'Sun' => DI::l10n()->t('Sun'), + 'Mon' => DI::l10n()->t('Mon'), + 'Tue' => DI::l10n()->t('Tue'), + 'Wed' => DI::l10n()->t('Wed'), + 'Thu' => DI::l10n()->t('Thu'), + 'Fri' => DI::l10n()->t('Fri'), + 'Sat' => DI::l10n()->t('Sat'), - "Sunday" => DI::l10n()->t("Sunday"), - "Monday" => DI::l10n()->t("Monday"), - "Tuesday" => DI::l10n()->t("Tuesday"), - "Wednesday" => DI::l10n()->t("Wednesday"), - "Thursday" => DI::l10n()->t("Thursday"), - "Friday" => DI::l10n()->t("Friday"), - "Saturday" => DI::l10n()->t("Saturday"), + 'Sunday' => DI::l10n()->t('Sunday'), + 'Monday' => DI::l10n()->t('Monday'), + 'Tuesday' => DI::l10n()->t('Tuesday'), + 'Wednesday' => DI::l10n()->t('Wednesday'), + 'Thursday' => DI::l10n()->t('Thursday'), + 'Friday' => DI::l10n()->t('Friday'), + 'Saturday' => DI::l10n()->t('Saturday'), - "Jan" => DI::l10n()->t("Jan"), - "Feb" => DI::l10n()->t("Feb"), - "Mar" => DI::l10n()->t("Mar"), - "Apr" => DI::l10n()->t("Apr"), - "May" => DI::l10n()->t("May"), - "Jun" => DI::l10n()->t("Jun"), - "Jul" => DI::l10n()->t("Jul"), - "Aug" => DI::l10n()->t("Aug"), - "Sep" => DI::l10n()->t("Sept"), - "Oct" => DI::l10n()->t("Oct"), - "Nov" => DI::l10n()->t("Nov"), - "Dec" => DI::l10n()->t("Dec"), + 'Jan' => DI::l10n()->t('Jan'), + 'Feb' => DI::l10n()->t('Feb'), + 'Mar' => DI::l10n()->t('Mar'), + 'Apr' => DI::l10n()->t('Apr'), + 'May' => DI::l10n()->t('May'), + 'Jun' => DI::l10n()->t('Jun'), + 'Jul' => DI::l10n()->t('Jul'), + 'Aug' => DI::l10n()->t('Aug'), + 'Sep' => DI::l10n()->t('Sept'), + 'Oct' => DI::l10n()->t('Oct'), + 'Nov' => DI::l10n()->t('Nov'), + 'Dec' => DI::l10n()->t('Dec'), - "January" => DI::l10n()->t("January"), - "February" => DI::l10n()->t("February"), - "March" => DI::l10n()->t("March"), - "April" => DI::l10n()->t("April"), - "June" => DI::l10n()->t("June"), - "July" => DI::l10n()->t("July"), - "August" => DI::l10n()->t("August"), - "September" => DI::l10n()->t("September"), - "October" => DI::l10n()->t("October"), - "November" => DI::l10n()->t("November"), - "December" => DI::l10n()->t("December"), + 'January' => DI::l10n()->t('January'), + 'February' => DI::l10n()->t('February'), + 'March' => DI::l10n()->t('March'), + 'April' => DI::l10n()->t('April'), + 'June' => DI::l10n()->t('June'), + 'July' => DI::l10n()->t('July'), + 'August' => DI::l10n()->t('August'), + 'September' => DI::l10n()->t('September'), + 'October' => DI::l10n()->t('October'), + 'November' => DI::l10n()->t('November'), + 'December' => DI::l10n()->t('December'), - "today" => DI::l10n()->t("today"), - "month" => DI::l10n()->t("month"), - "week" => DI::l10n()->t("week"), - "day" => DI::l10n()->t("day"), + 'today' => DI::l10n()->t('today'), + 'month' => DI::l10n()->t('month'), + 'week' => DI::l10n()->t('week'), + 'day' => DI::l10n()->t('day'), - "noevent" => DI::l10n()->t("No events to display"), + 'noevent' => DI::l10n()->t('No events to display'), - "dtstart_label" => DI::l10n()->t("Starts:"), - "dtend_label" => DI::l10n()->t("Finishes:"), - "location_label" => DI::l10n()->t("Location:") + 'dtstart_label' => DI::l10n()->t('Starts:'), + 'dtend_label' => DI::l10n()->t('Finishes:'), + 'location_label' => DI::l10n()->t('Location:') ]; - - return $i18n; } /** diff --git a/src/Module/Settings/Display.php b/src/Module/Settings/Display.php index 1484790d9..a263d2992 100644 --- a/src/Module/Settings/Display.php +++ b/src/Module/Settings/Display.php @@ -93,9 +93,9 @@ class Display extends BaseSettings DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike' , !$enable_dislike); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'display_resharer' , $display_resharer); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'stay_local' , $stay_local); - DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week' , $first_day_of_week); 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); if (in_array($theme, Theme::getAllowedList())) { if ($theme == $user['theme']) { // call theme_post only if theme has not been changed diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index d9ff07178..f621da2eb 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -55,7 +55,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1501); + define('DB_UPDATE_VERSION', 1502); } return [ diff --git a/update.php b/update.php index 12a3fb74e..82f4fba58 100644 --- a/update.php +++ b/update.php @@ -1138,4 +1138,10 @@ function update_1497() { DBA::e("UPDATE `user` SET `last-activity` = DATE(`login_date`) WHERE `last-activity` IS NULL"); return Update::SUCCESS; -} \ No newline at end of file +} + +function update_1502() +{ + DBA::e("UPDATE `pconfig` SET `cat` = 'calendar' WHERE `k` = 'first_day_of_week'"); + return Update::SUCCESS; +} From cdf180c58d8f95ea019498fe99f9dc9b4ce1130c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 17 Dec 2022 02:13:33 -0500 Subject: [PATCH 3/4] Add new calendar.default_view pconfig key --- src/Model/Event.php | 2 ++ src/Module/Settings/Display.php | 14 +++++++++++++- view/templates/calendar/calendar_head.tpl | 1 + view/templates/settings/display.tpl | 1 + view/theme/frio/js/mod_events.js | 2 +- .../frio/templates/calendar/calendar_head.tpl | 1 + view/theme/frio/templates/settings/display.tpl | 1 + 7 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Model/Event.php b/src/Model/Event.php index 28e325dba..4e7a6a861 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 a263d2992..c1885182d 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 73b0d5e7b..b5bf8f6fe 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 7e3efc920..e7488b124 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 3e3c6f422..191742e3b 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 15f3fbcc2..481da5f72 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 530a40a96..19a22eb07 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}}