Allow editor themes to fall back safely

This commit is contained in:
Damian Mooyman 2017-07-03 10:38:30 +12:00
parent cddaaf1444
commit 92903d883e
2 changed files with 8 additions and 12 deletions

View File

@ -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
*

View File

@ -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);
}