diff --git a/includes/ckeditor.lib.inc b/includes/ckeditor.lib.inc index 3370968..87fbc0c 100644 --- a/includes/ckeditor.lib.inc +++ b/includes/ckeditor.lib.inc @@ -937,87 +937,7 @@ function ckeditor_profile_settings_compile($global_profile, $profile) { $css_files = array(); switch ($conf['css_mode']) { case 'theme': - global $language, $base_theme_info; - $themes = list_themes(); - $theme_info = $themes[$current_theme]; - if (!empty($theme_info->stylesheets)) { - $editorcss = "\""; - foreach ($base_theme_info as $base) { // Grab stylesheets from base theme - if (!empty($base->stylesheets)) { // may be empty when the base theme reference in the info file is invalid - foreach ($base->stylesheets as $type => $stylesheets) { - if ($type != "print") { - foreach ($stylesheets as $name => $path) { - if (file_exists($path)) { - $css_files[$name] = $host . $path . $query_string; - // Grab rtl stylesheets ( will get rtl css files when thay are named with suffix "-rtl.css" (ex: fusion baased themes) ) - if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && substr($path, 0, -8) != "-rtl.css") { - $rtl_path = substr($path, 0, -4) . "-rtl.css"; - if (file_exists($rtl_path)) { - $css_files[$name . "-rtl"] = $host . $rtl_path . $query_string; - } - } - } - } - } - } - } - } - if (!empty($theme_info->stylesheets)) { // Grab stylesheets from current theme - foreach ($theme_info->stylesheets as $type => $stylesheets) { - if ($type != "print") { - foreach ($stylesheets as $name => $path) { - // Checks if less module exists... - if (strstr($path, '.less') && module_exists('less')) { - $path = 'sites/default/files/less/' . $path; // append the less file path - $path = str_replace('.less', '', $path); // remove the .less - } - if (file_exists($path)) { - $css_files[$name] = $host . $path . $query_string; - // Grab rtl stylesheets ( will get rtl css files when thay are named with suffix "-rtl.css" (ex: fusion baased themes) ) - if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && substr($path, 0, -8) != "-rtl.css") { - $rtl_path = substr($path, 0, -4) . "-rtl.css"; - if (file_exists($rtl_path)) { - $css_files[$name . "-rtl"] = $host . $rtl_path . $query_string; - } - } - } - elseif (!empty($css_files[$name])) { - unset($css_files[$name]); - } - } - } - } - } - // Grab stylesheets local.css and local-rtl.css if they exist (fusion based themes) - if (file_exists($themepath . 'css/local.css')) { - $css_files[] = $host . $themepath . 'css/local.css' . $query_string; - } - if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && file_exists($themepath . 'css/local-rtl.css')) { - $css_files[] = $host . $themepath . 'css/local-rtl.css' . $query_string; - } - - // Grab stylesheets from color module - $color_paths = variable_get('color_' . $current_theme . '_stylesheets', array()); - if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) { - if (!empty($color_paths[1])) { - $css_files[] = $host . $color_paths[1] . $query_string; - } - } - elseif (!empty($color_paths[0])) { - $css_files[] = $host . $color_paths[0] . $query_string; - } - } - else { - if (!file_exists($themepath . 'ckeditor.css') && file_exists($themepath . 'style.css')) { - $css_files[] = $host . $themepath . 'style.css' . $query_string; - } - } - if (file_exists($module_drupal_local_path . '/css/ckeditor.css')) { - $css_files[] = $module_drupal_path . '/css/ckeditor.css' . $query_string; - } - if (file_exists($themepath . 'ckeditor.css')) { - $css_files[] = $host . $themepath . 'ckeditor.css' . $query_string; - } + _ckeditor_add_css_from_theme($current_theme, $css_files); break; case 'self': @@ -1090,6 +1010,98 @@ function ckeditor_profile_settings_compile($global_profile, $profile) { return $settings; } +function _ckeditor_add_css_from_theme($current_theme, &$css_files) { + global $language, $base_theme_info; + $query_string = '?' . variable_get('css_js_query_string', '0'); + $host = base_path(); + $themes = list_themes(); + $theme_info = $themes[$current_theme]; + $themepath = drupal_get_path('theme', $current_theme) . '/'; + $module_drupal_local_path = ckeditor_module_path('local'); + $module_drupal_path = drupal_get_path('module', 'ckeditor'); + if (!empty($theme_info->base_theme)) { + _ckeditor_add_css_from_theme($theme_info->base_theme, $css_files); + } + if (!empty($theme_info->stylesheets)) { + $editorcss = "\""; + foreach ($base_theme_info as $base) { // Grab stylesheets from base theme + if (!empty($base->stylesheets)) { // may be empty when the base theme reference in the info file is invalid + foreach ($base->stylesheets as $type => $stylesheets) { + if ($type != "print") { + foreach ($stylesheets as $name => $path) { + if (file_exists($path)) { + $css_files[$name] = $host . $path . $query_string; + // Grab rtl stylesheets ( will get rtl css files when thay are named with suffix "-rtl.css" (ex: fusion baased themes) ) + if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && substr($path, 0, -8) != "-rtl.css") { + $rtl_path = substr($path, 0, -4) . "-rtl.css"; + if (file_exists($rtl_path)) { + $css_files[$name . "-rtl"] = $host . $rtl_path . $query_string; + } + } + } + } + } + } + } + } + if (!empty($theme_info->stylesheets)) { // Grab stylesheets from current theme + foreach ($theme_info->stylesheets as $type => $stylesheets) { + if ($type != "print") { + foreach ($stylesheets as $name => $path) { + // Checks if less module exists... + if (strstr($path, '.less') && module_exists('less')) { + $path = 'sites/default/files/less/' . $path; // append the less file path + $path = str_replace('.less', '', $path); // remove the .less + } + if (file_exists($path)) { + $css_files[$name] = $host . $path . $query_string; + // Grab rtl stylesheets ( will get rtl css files when thay are named with suffix "-rtl.css" (ex: fusion baased themes) ) + if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && substr($path, 0, -8) != "-rtl.css") { + $rtl_path = substr($path, 0, -4) . "-rtl.css"; + if (file_exists($rtl_path)) { + $css_files[$name . "-rtl"] = $host . $rtl_path . $query_string; + } + } + } + elseif (!empty($css_files[$name])) { + unset($css_files[$name]); + } + } + } + } + } + // Grab stylesheets local.css and local-rtl.css if they exist (fusion based themes) + if (file_exists($themepath . 'css/local.css')) { + $css_files[] = $host . $themepath . 'css/local.css' . $query_string; + } + if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && file_exists($themepath . 'css/local-rtl.css')) { + $css_files[] = $host . $themepath . 'css/local-rtl.css' . $query_string; + } + + // Grab stylesheets from color module + $color_paths = variable_get('color_' . $current_theme . '_stylesheets', array()); + if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) { + if (!empty($color_paths[1])) { + $css_files[] = $host . $color_paths[1] . $query_string; + } + } + elseif (!empty($color_paths[0])) { + $css_files[] = $host . $color_paths[0] . $query_string; + } + } + else { + if (!file_exists($themepath . 'ckeditor.css') && file_exists($themepath . 'style.css')) { + $css_files[] = $host . $themepath . 'style.css' . $query_string; + } + } + if (file_exists($module_drupal_local_path . '/css/ckeditor.css')) { + $css_files[] = $module_drupal_path . '/css/ckeditor.css' . $query_string; + } + if (file_exists($themepath . 'ckeditor.css')) { + $css_files[] = $host . $themepath . 'ckeditor.css' . $query_string; + } +} + /** * Load CKEditor for field ID *