diff --git a/editors/ckeditor.inc b/editors/ckeditor.inc index 1f9df0b..39de9c5 100644 --- a/editors/ckeditor.inc +++ b/editors/ckeditor.inc @@ -164,7 +164,7 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) { // Versions below 3.0.1 could only handle one stylesheet. if (version_compare($editor['installed version'], '3.0.1.4391', '<')) { if ($config['css_setting'] == 'theme') { - $settings['contentsCss'] = reset(wysiwyg_get_css($config['css_theme'])); + $settings['contentsCss'] = reset(wysiwyg_get_css(isset($config['css_theme']) ? $config['css_theme'] : '')); } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { $settings['contentsCss'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); @@ -172,7 +172,7 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) { } else { if ($config['css_setting'] == 'theme') { - $settings['contentsCss'] = wysiwyg_get_css($config['css_theme']); + $settings['contentsCss'] = wysiwyg_get_css(isset($config['css_theme']) ? $config['css_theme'] : ''); } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { $settings['contentsCss'] = explode(',', strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()))); diff --git a/editors/fckeditor.inc b/editors/fckeditor.inc index 69bc627..15099f1 100644 --- a/editors/fckeditor.inc +++ b/editors/fckeditor.inc @@ -129,7 +129,7 @@ function wysiwyg_fckeditor_settings($editor, $config, $theme) { if (isset($config['css_setting'])) { if ($config['css_setting'] == 'theme') { - $settings['EditorAreaCSS'] = implode(',', wysiwyg_get_css($config['css_theme'])); + $settings['EditorAreaCSS'] = implode(',', wysiwyg_get_css(isset($config['css_theme']) ? $config['css_theme'] : '')); } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { $settings['EditorAreaCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); diff --git a/editors/openwysiwyg.inc b/editors/openwysiwyg.inc index e780b4e..6d147c6 100644 --- a/editors/openwysiwyg.inc +++ b/editors/openwysiwyg.inc @@ -100,7 +100,7 @@ function wysiwyg_openwysiwyg_settings($editor, $config, $theme) { if (isset($config['css_setting'])) { if ($config['css_setting'] == 'theme') { - $settings['CSSFile'] = reset(wysiwyg_get_css($config['css_theme'])); + $settings['CSSFile'] = reset(wysiwyg_get_css(isset($config['css_theme']) ? $config['css_theme'] : '')); } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { $settings['CSSFile'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); diff --git a/editors/tinymce.inc b/editors/tinymce.inc index 4ff667b..a7d9f79 100644 --- a/editors/tinymce.inc +++ b/editors/tinymce.inc @@ -188,7 +188,7 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) { if (isset($config['css_setting'])) { if ($config['css_setting'] == 'theme') { - $settings['content_css'] = implode(',', wysiwyg_get_css($config['css_theme'])); + $settings['content_css'] = implode(',', wysiwyg_get_css(isset($config['css_theme']) ? $config['css_theme'] : '')); } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { $settings['content_css'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); diff --git a/editors/wymeditor.inc b/editors/wymeditor.inc index 1765675..b107893 100644 --- a/editors/wymeditor.inc +++ b/editors/wymeditor.inc @@ -172,7 +172,7 @@ function wysiwyg_wymeditor_settings($editor, $config, $theme) { if (isset($config['css_setting'])) { if ($config['css_setting'] == 'theme') { // WYMeditor only supports one CSS file currently. - $settings['stylesheet'] = reset(wysiwyg_get_css($config['css_theme'])); + $settings['stylesheet'] = reset(wysiwyg_get_css(isset($config['css_theme']) ? $config['css_theme'] : '')); } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { $settings['stylesheet'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); diff --git a/editors/yui.inc b/editors/yui.inc index 67753ff..dce3dd8 100644 --- a/editors/yui.inc +++ b/editors/yui.inc @@ -200,7 +200,7 @@ function wysiwyg_yui_settings($editor, $config, $theme) { if (isset($config['css_setting'])) { if ($config['css_setting'] == 'theme') { - $settings['extracss'] = wysiwyg_get_css($config['css_theme']); + $settings['extracss'] = wysiwyg_get_css(isset($config['css_theme']) ? $config['css_theme'] : ''); } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { $settings['extracss'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); diff --git a/wysiwyg.admin.inc b/wysiwyg.admin.inc index df73c18..4074fff 100644 --- a/wysiwyg.admin.inc +++ b/wysiwyg.admin.inc @@ -275,7 +275,9 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { ); $themes = list_themes(); - $theme_list = array(); + $theme_list = array( + '' => t('Node admin theme'), + ); foreach ($themes as $theme) { if ($theme->status) { $theme_list[$theme->name] = $theme->info['name']; diff --git a/wysiwyg.install b/wysiwyg.install index 07fbe1a..038ba46 100644 --- a/wysiwyg.install +++ b/wysiwyg.install @@ -310,24 +310,3 @@ function wysiwyg_update_7200() { )); } } - -/** - * Add config value to set editor theme, set default value for existing profiles. - */ -function wysiwyg_update_7201() { - $css_theme = variable_get('node_admin_theme') ? variable_get('admin_theme') : variable_get('theme_default'); - - $profiles = db_query('SELECT format, settings FROM {wysiwyg}'); - foreach ($profiles as $profile) { - $profile->settings = unserialize($profile->settings); - $profile->settings['css_theme'] = $css_theme; - db_update('wysiwyg') - ->fields(array( - 'settings' => serialize($profile->settings), - )) - ->condition('format', $profile->format) - ->execute(); - } - - wysiwyg_profile_cache_clear(); -} diff --git a/wysiwyg.module b/wysiwyg.module index 595dafc..31c914e 100644 --- a/wysiwyg.module +++ b/wysiwyg.module @@ -603,18 +603,23 @@ function wysiwyg_get_editor_config($profile, $theme) { * for the scope 'theme'. * * @param $theme - * The theme to retrieve stylesheets for. + * (optional) The theme to retrieve stylesheets for. Defaults to '' which is + * the current node admin theme. * * @return * An array containing CSS files, including proper base path. */ -function wysiwyg_get_css($theme) { +function wysiwyg_get_css($theme = '') { static $files; if (isset($files)) { return $files; } + if (empty($theme)) { + $theme = variable_get('node_admin_theme') ? variable_get('admin_theme') : variable_get('theme_default'); + } + $files = array(); $stylesheets = array(); $themes = list_themes(); @@ -637,9 +642,7 @@ function wysiwyg_get_css($theme) { } } foreach ($stylesheets as $path) { - if (file_exists($path)) { - $files[] = base_path() . $path; - } + $files[] = base_path() . $path; } return $files;