diff --git a/editors/ckeditor.inc b/editors/ckeditor.inc index 896fc84..05ee5ed 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()); + $settings['contentsCss'] = reset(wysiwyg_get_css($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(); + $settings['contentsCss'] = wysiwyg_get_css($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 fba81f6..69bc627 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()); + $settings['EditorAreaCSS'] = implode(',', wysiwyg_get_css($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/wymeditor.inc b/editors/wymeditor.inc index 042bc23..1765675 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()); + $settings['stylesheet'] = reset(wysiwyg_get_css($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 845a1af..67753ff 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(); + $settings['extracss'] = wysiwyg_get_css($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 ff23b28..4bf73ef 100644 --- a/wysiwyg.admin.inc +++ b/wysiwyg.admin.inc @@ -18,6 +18,12 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { if (empty($profile['settings'])) { $profile['settings'] = array(); } + if (variable_get('node_admin_theme')) { + $css_theme = variable_get('admin_theme'); + } + else { + $css_theme = variable_get('theme_default'); + } $profile['settings'] += array( 'default' => TRUE, 'user_choose' => FALSE, @@ -40,6 +46,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { 'apply_source_formatting' => FALSE, 'paste_auto_cleanup_on_paste' => FALSE, 'css_setting' => 'theme', + 'css_theme' => $css_theme, 'css_path' => NULL, 'css_classes' => NULL, ); @@ -270,7 +277,25 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { '#title' => t('Editor CSS'), '#default_value' => $profile->settings['css_setting'], '#options' => array('theme' => t('Use theme CSS'), 'self' => t('Define CSS'), 'none' => t('Editor default CSS')), - '#description' => t('Defines the CSS to be used in the editor area.
Use theme CSS - loads stylesheets from current site theme.
Define CSS - enter path for stylesheet files below.
Editor default CSS - uses default stylesheets from editor.'), + '#description' => t('Defines the CSS to be used in the editor area.
Use theme CSS - loads stylesheets from the specified theme below.
Define CSS - enter path for stylesheet files below.
Editor default CSS - uses default stylesheets from editor.'), + ); + + $themes = list_themes(); + $theme_list = array(); + foreach($themes as $theme) { + if ($theme->status) { + $theme_list[$theme->name] = $theme->info['name']; + } + } + $form['css']['css_theme'] = array( + '#type' => 'select', + '#title' => t('Theme'), + '#default_value' => $profile->settings['css_theme'], + '#description' => t("Select which theme's CSS to apply to the editor.
Note: This is only applied when 'Editor CSS' field above is set to 'Use theme CSS'"), + '#options' => $theme_list, + '#states' => array( + 'visible' => array('select[name="css_setting"]' => array('value' => 'theme')), + ), ); $form['css']['css_path'] = array( diff --git a/wysiwyg.module b/wysiwyg.module index 31f3228..590f9dc 100644 --- a/wysiwyg.module +++ b/wysiwyg.module @@ -605,7 +605,7 @@ function wysiwyg_get_editor_config($profile, $theme) { * @return * An array containing CSS files, including proper base path. */ -function wysiwyg_get_css() { +function wysiwyg_get_css($theme) { static $files; if (isset($files)) { @@ -617,13 +617,13 @@ function wysiwyg_get_css() { } $files = array(); - foreach (drupal_add_css() as $filepath => $info) { - if ($info['group'] >= CSS_THEME && $info['media'] != 'print') { - if (file_exists($filepath)) { - $files[] = base_path() . $filepath; - } + $stylesheets = array(); + $themes = list_themes(); + if (isset($themes[$theme]->info['base theme'])) { + foreach($themes[$themes[$theme]->info['base theme']]->stylesheets['all'] as $stylesheet) { + $stylesheets[] = $stylesheet; } } + foreach($themes[$theme]->stylesheets['all'] as $stylesheet) { + $stylesheets[] = $stylesheet; + } + foreach($stylesheets as $path) { + if (file_exists($path)) { + $files[] = base_path() . $path; + } + } + return $files; }