diff --git a/ckeditor.module b/ckeditor.module index 717b062..bd7cb85 100644 --- a/ckeditor.module +++ b/ckeditor.module @@ -301,7 +301,7 @@ function ckeditor_path($local = FALSE, $refresh = FALSE) { if ($refresh || (!$cke_path)) { $mod_path = drupal_get_path('module', 'ckeditor'); - $lib_path = 'sites/all/libraries'; + $lib_path = _ckeditor_get_lib_path(); $global_profile = ckeditor_profile_load('CKEditor Global Profile', $refresh); //default: path to ckeditor subdirectory in the ckeditor module directory (starting from the document root) @@ -328,7 +328,7 @@ function ckeditor_path($local = FALSE, $refresh = FALSE) { $gs['ckeditor_local_path'] = strtr($gs['ckeditor_path'], array("%m" => $mod_path)); } if (FALSE !== strpos($gs['ckeditor_path'], "%l")) { - $gs['ckeditor_local_path'] = strtr($gs['ckeditor_path'], array("%l" => 'sites/all/libraries')); + $gs['ckeditor_local_path'] = strtr($gs['ckeditor_path'], array("%l" => _ckeditor_get_lib_path())); } } } @@ -367,7 +367,7 @@ function ckeditor_plugins_path($local = FALSE, $refresh = FALSE) { if ($refresh || (!$cke_plugins_path)) { $mod_path = drupal_get_path('module', 'ckeditor'); - $lib_path = 'sites/all/libraries'; + $lib_path = _ckeditor_get_lib_path(); $global_profile = ckeditor_profile_load('CKEditor Global Profile', $refresh); //default: path to ckeditor subdirectory in the ckeditor module directory (starting from the document root) @@ -401,7 +401,7 @@ function ckeditor_plugins_path($local = FALSE, $refresh = FALSE) { $gs['ckeditor_plugins_local_path'] = strtr($gs['ckeditor_plugins_path'], array("%b" => ".")); } if (FALSE !== strpos($gs['ckeditor_plugins_path'], "%l")) { - $gs['ckeditor_plugins_local_path'] = strtr($gs['ckeditor_plugins_path'], array("%l" => "sites/all/libraries")); + $gs['ckeditor_plugins_local_path'] = strtr($gs['ckeditor_plugins_path'], array("%l" => _ckeditor_get_lib_path())); } } } @@ -477,3 +477,18 @@ function ckeditor_file_download($uri) { } } } + +/** + * Return the appropriate library path for ckeditor. + */ +function _ckeditor_get_lib_path() { + if (function_exists('libraries_get_path')) { + $lib_path = libraries_get_path('ckeditor'); + // Remove the final /ckeditor from the path + $lib_path = drupal_substr($lib_path, 0, strlen($lib_path) - 9); + } + else { + $lib_path = 'sites/all/libraries'; + } + return $lib_path; +} diff --git a/includes/ckeditor.admin.inc b/includes/ckeditor.admin.inc index b01d364..b1909b8 100644 --- a/includes/ckeditor.admin.inc +++ b/includes/ckeditor.admin.inc @@ -45,8 +45,8 @@ function ckeditor_admin_main() { //check if CKEditor plugin is installed if (!_ckeditor_requirements_isinstalled()) { - drupal_set_message(t('Checking for %filename or %file.', array('%filename' => $ckconfig_file, '%file' => 'sites/all/libraries/ckeditor/ckeditor.js'))); - drupal_set_message(t('The CKEditor component is not installed correctly. Please go to the !ckeditorlink in order to download the latest version. After that you must extract the files to the %ckeditorpath or %librarypath directory and make sure that the %ckeditorfile or %ckeditorlibrary file exists. Refer to the !readme file for more information.', array('!ckeditorlink' => l(t('CKEditor homepage'), 'http://ckeditor.com/download'), '!readme' => l(t('README.txt'), $base_url . '/' . drupal_get_path('module', 'ckeditor') . '/README.txt', array('absolute' => TRUE)), '%ckeditorpath' => 'sites/all/modules/ckeditor/ckeditor', '%ckeditorsubdir' => $editor_path . '/editor', '%ckeditorfile' => 'sites/all/modules/ckeditor/ckeditor/ckeditor.js', '%ckeditorlibrary' => 'sites/all/libraries/ckeditor/ckeditor.js', '%librarypath' => 'sites/all/libraries/ckeditor')), 'error'); + drupal_set_message(t('Checking for %filename or %file.', array('%filename' => $ckconfig_file, '%file' => _ckeditor_get_lib_path() . '/ckeditor/ckeditor.js'))); + drupal_set_message(t('The CKEditor component is not installed correctly. Please go to the !ckeditorlink in order to download the latest version. After that you must extract the files to the %ckeditorpath or %librarypath directory and make sure that the %ckeditorfile or %ckeditorlibrary file exists. Refer to the !readme file for more information.', array('!ckeditorlink' => l(t('CKEditor homepage'), 'http://ckeditor.com/download'), '!readme' => l(t('README.txt'), $base_url . '/' . drupal_get_path('module', 'ckeditor') . '/README.txt', array('absolute' => TRUE)), '%ckeditorpath' => 'sites/all/modules/ckeditor/ckeditor', '%ckeditorsubdir' => $editor_path . '/editor', '%ckeditorfile' => 'sites/all/modules/ckeditor/ckeditor/ckeditor.js', '%ckeditorlibrary' => _ckeditor_get_lib_path() . '/ckeditor/ckeditor.js', '%librarypath' => _ckeditor_get_lib_path() . '/ckeditor')), 'error'); drupal_set_message(t('If you have CKEditor already installed, edit the @editg and update the CKEditor path.', array('@editg' => l(t('CKEditor Global Profile'), 'admin/config/content/ckeditor/editg'))), 'warning'); return ''; } diff --git a/includes/ckeditor.lib.inc b/includes/ckeditor.lib.inc index adf25f1..4c508e1 100644 --- a/includes/ckeditor.lib.inc +++ b/includes/ckeditor.lib.inc @@ -631,7 +631,7 @@ function _ckeditor_script_path() { elseif (file_exists($module_path . '/ckeditor/ckeditor/ckeditor.js')) { $jspath = '%m/ckeditor/ckeditor'; } - elseif (file_exists('sites/all/libraries/ckeditor/ckeditor.js')) { + elseif (file_exists(_ckeditor_get_lib_path() . '/ckeditor/ckeditor.js')) { $jspath = '%l/ckeditor'; } return $jspath;