From de2dcd6a2e7daeba59aa239c8a64c478575b6775 Mon Sep 17 00:00:00 2001 From: Daniel Brendel Date: Fri, 20 Sep 2024 20:30:05 +0200 Subject: [PATCH] Resolves #272 --- app/modules/ThemeModule.php | 22 ++++++++++++++++++++++ app/views/mail/calendar_reminder.php | 6 ++++++ app/views/mail/mailacccreated.php | 6 ++++++ app/views/mail/mailreset.php | 6 ++++++ app/views/mail/share_photo.php | 6 ++++++ app/views/mail/task_overdue.php | 6 ++++++ app/views/mail/task_tomorrow.php | 6 ++++++ 7 files changed, 58 insertions(+) diff --git a/app/modules/ThemeModule.php b/app/modules/ThemeModule.php index fe2f0b9..8b8ebd9 100644 --- a/app/modules/ThemeModule.php +++ b/app/modules/ThemeModule.php @@ -88,6 +88,12 @@ class ThemeModule { self::$theme_data->accessory->inline_rules->img .= $key . ': ' . $value . ' !important;'; } } + + if (isset(self::$theme_data->mail)) { + if (!file_exists($path . '/' . self::$theme_data->mail)) { + throw new \Exception('Mail style asset not found'); + } + } } catch (\Exception $e) { throw $e; } @@ -114,6 +120,22 @@ class ThemeModule { return (is_object(self::$theme_data)); } + /** + * @return bool + */ + public static function hasMailStyles() + { + return (static::ready()) && (isset(self::$theme_data->mail)) && (file_exists(public_path() . '/themes/' . self::$theme_data->name . '/' . self::$theme_data->mail)); + } + + /** + * @return string + */ + public static function getMailStyles() + { + return file_get_contents(public_path() . '/themes/' . self::$theme_data->name . '/' . self::$theme_data->mail); + } + /** * @return array * @throws \Exception diff --git a/app/views/mail/calendar_reminder.php b/app/views/mail/calendar_reminder.php index a069460..32b99a1 100644 --- a/app/views/mail/calendar_reminder.php +++ b/app/views/mail/calendar_reminder.php @@ -4,6 +4,12 @@ {{ __('app.mail_info_calendar_reminder') }} + + @if (ThemeModule::hasMailStyles()) + + @endif diff --git a/app/views/mail/mailacccreated.php b/app/views/mail/mailacccreated.php index e87755b..a0db512 100644 --- a/app/views/mail/mailacccreated.php +++ b/app/views/mail/mailacccreated.php @@ -4,6 +4,12 @@ {{ __('app.account_created') }} + + @if (ThemeModule::hasMailStyles()) + + @endif diff --git a/app/views/mail/mailreset.php b/app/views/mail/mailreset.php index 6d279ae..c7143b4 100644 --- a/app/views/mail/mailreset.php +++ b/app/views/mail/mailreset.php @@ -4,6 +4,12 @@ {{ __('app.reset_password') }} + + @if (ThemeModule::hasMailStyles()) + + @endif diff --git a/app/views/mail/share_photo.php b/app/views/mail/share_photo.php index 2f0f0b1..6e1782a 100644 --- a/app/views/mail/share_photo.php +++ b/app/views/mail/share_photo.php @@ -4,6 +4,12 @@ {{ __('app.mail_share_photo') }} + + @if (ThemeModule::hasMailStyles()) + + @endif diff --git a/app/views/mail/task_overdue.php b/app/views/mail/task_overdue.php index 5984e28..cdfe010 100644 --- a/app/views/mail/task_overdue.php +++ b/app/views/mail/task_overdue.php @@ -4,6 +4,12 @@ {{ __('app.mail_info_task_overdue') }} + + @if (ThemeModule::hasMailStyles()) + + @endif diff --git a/app/views/mail/task_tomorrow.php b/app/views/mail/task_tomorrow.php index 7ec0e43..6f29946 100644 --- a/app/views/mail/task_tomorrow.php +++ b/app/views/mail/task_tomorrow.php @@ -4,6 +4,12 @@ {{ __('app.mail_info_task_tomorrow') }} + + @if (ThemeModule::hasMailStyles()) + + @endif