function ckeditor_plugins_path in CKEditor - WYSIWYG HTML editor 6
Same name and namespace in other branches
- 7 ckeditor.module \ckeditor_plugins_path()
Read the CKEditor plugins path from the Global profile.
Return value
Path to CKEditor plugins folder.
4 calls to ckeditor_plugins_path()
- ckeditor_admin_global_profile_form in includes/
ckeditor.admin.inc - ckeditor_load_plugins in includes/
ckeditor.lib.inc - List of CKEditor plugins
- ckeditor_plugins_render in includes/
ckeditor.lib.inc - Render CKEditor plugins path
- ckeditor_update_6101 in ./
ckeditor.install - Implementation of hook_update_N().
File
- ./
ckeditor.module, line 1277 - CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
Code
function ckeditor_plugins_path($local = FALSE, $refresh = FALSE) {
static $cke_plugins_path;
static $cke_plugins_local_path;
if ($refresh || !$cke_plugins_path) {
$mod_path = drupal_get_path('module', 'ckeditor');
$lib_path = 'sites/all/libraries';
$global_profile = ckeditor_profile_load('CKEditor Global Profile', $refresh);
//default: path to plugins subdirectory in the ckeditor module directory (starting from the document root)
//e.g. for http://example.com/drupal it will be /drupal/sites/all/modules/ckeditor/plugins
$cke_plugins_path = base_path() . $mod_path . '/plugins';
//default: path to plugins subdirectory in the ckeditor module directory (relative to index.php)
//e.g.: sites/all/modules/ckeditor/plugins
$cke_plugins_local_path = $mod_path . '/plugins';
if ($global_profile) {
$gs = $global_profile->settings;
if (isset($gs['ckeditor_plugins_path'])) {
$tmp_path = $gs['ckeditor_plugins_path'];
$tmp_path = strtr($tmp_path, array(
"%b" => base_path(),
"%m" => base_path() . $mod_path,
"%l" => base_path() . $lib_path,
));
$tmp_path = str_replace('\\', '/', $tmp_path);
$tmp_path = str_replace('//', '/', $tmp_path);
$tmp_path = rtrim($tmp_path, ' \\/');
if (substr($tmp_path, 0, 1) != '/') {
$tmp_path = '/' . $tmp_path;
//starts with '/'
}
$cke_plugins_path = $tmp_path;
if (empty($gs['ckeditor_plugins_local_path'])) {
//fortunately wildcards are used, we can easily get the right server path
if (FALSE !== strpos($gs['ckeditor_plugins_path'], "%m")) {
$gs['ckeditor_plugins_local_path'] = strtr($gs['ckeditor_plugins_path'], array(
"%m" => $mod_path,
));
}
if (FALSE !== strpos($gs['ckeditor_plugins_path'], "%b")) {
$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",
));
}
}
}
//ckeditor_plugins_path is defined, but wildcards are not used, we need to try to find out where is
//the document root located and append ckeditor_plugins_path to it.
if (!empty($gs['ckeditor_plugins_local_path']) && !is_null($gs['ckeditor_plugins_local_path'])) {
$cke_plugins_local_path = $gs['ckeditor_plugins_local_path'];
}
elseif (!empty($gs['ckeditor_plugins_path'])) {
module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
$local_path = ckeditor_resolve_url($gs['ckeditor_plugins_path'] . "/");
if (FALSE !== $local_path) {
$cke_plugins_local_path = $local_path;
}
}
}
}
if ($local) {
return $cke_plugins_local_path;
}
else {
return $cke_plugins_path;
}
}