From 92903d883ec4f0885814d47082a8166899f4f8f5 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 3 Jul 2017 10:38:30 +1200 Subject: [PATCH] Allow editor themes to fall back safely --- src/Forms/HTMLEditor/HTMLEditorConfig.php | 16 +++++----------- src/Forms/HTMLEditor/TinyMCEConfig.php | 4 +++- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Forms/HTMLEditor/HTMLEditorConfig.php b/src/Forms/HTMLEditor/HTMLEditorConfig.php index 35508d4b6..10b59959a 100644 --- a/src/Forms/HTMLEditor/HTMLEditorConfig.php +++ b/src/Forms/HTMLEditor/HTMLEditorConfig.php @@ -52,7 +52,10 @@ abstract class HTMLEditorConfig private static $default_config = 'default'; /** - * @var List of themes defined for the frontend + * List of themes defined for the frontend + * + * @config + * @var array */ private static $user_themes = []; @@ -108,7 +111,7 @@ abstract class HTMLEditorConfig */ public static function get_active_identifier() { - $identifier = self::$current ?: static::config()->default_config; + $identifier = self::$current ?: static::config()->get('default_config'); return $identifier; } @@ -152,15 +155,6 @@ abstract class HTMLEditorConfig return $configs; } - /** - * Set user defined (non-admin) themes - * @param array $themes - */ - public static function set_user_themes($themes) - { - self::config()->set('user_themes', $themes); - } - /** * Get the current value of an option * diff --git a/src/Forms/HTMLEditor/TinyMCEConfig.php b/src/Forms/HTMLEditor/TinyMCEConfig.php index c62a5adb4..0b8f7c118 100644 --- a/src/Forms/HTMLEditor/TinyMCEConfig.php +++ b/src/Forms/HTMLEditor/TinyMCEConfig.php @@ -616,8 +616,10 @@ class TinyMCEConfig extends HTMLEditorConfig // Add standard editor.css $editor[] = $this->getAdminModule()->getResourceURL('client/dist/styles/editor.css'); + // Themed editor.css - $themedEditor = ThemeResourceLoader::inst()->findThemedCSS('editor', $this->config()->user_themes); + $themes = $this->config()->get('user_themes') ?: SSViewer::get_themes(); + $themedEditor = ThemeResourceLoader::inst()->findThemedCSS('editor', $themes); if ($themedEditor) { $editor[] = Director::absoluteURL($themedEditor, Director::BASE); }