You are here

function ckeditor_skins_path in CKEditor - WYSIWYG HTML editor 7

Read the CKEditor skins path from the Global profile.

Return value

string Path to CKEditor skins folder.

4 calls to ckeditor_skins_path()
ckeditor_admin_global_profile_form in includes/ckeditor.admin.inc
Form builder for a global profile
ckeditor_admin_global_profile_form_validate in includes/ckeditor.admin.inc
Form validation for a global profile
ckeditor_load_skin_options in includes/ckeditor.lib.inc
List of installed CKEditor skins
ckeditor_profile_settings_compile in includes/ckeditor.lib.inc
Compile settings of profile
1 string reference to 'ckeditor_skins_path'
ckeditor_admin_global_profile_form_validate in includes/ckeditor.admin.inc
Form validation for a global profile

File

./ckeditor.module, line 548
CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

Code

function ckeditor_skins_path($mode = 'relative', $refresh = FALSE) {
  static $cke_static;
  if (!isset($cke_static)) {
    $cke_static = array();
  }
  if ($refresh || !isset($cke_static[$mode])) {
    $global_profile = ckeditor_profile_load('CKEditor Global Profile', $refresh);
    if (!$global_profile) {
      return '';
    }
    switch ($mode) {
      default:
      case 'relative':
        if (empty($global_profile->settings['ckeditor_skins_path'])) {
          return '';
        }
        $cke_skins_path = $global_profile->settings['ckeditor_skins_path'];
        $cke_skins_path = strtr($cke_skins_path, array(
          "%b" => ckeditor_base_path('relative'),
          "%m" => ckeditor_module_path('relative'),
          "%l" => ckeditor_library_path('relative'),
        ));
        $cke_skins_path = str_replace('\\', '/', $cke_skins_path);
        $cke_skins_path = str_replace('//', '/', $cke_skins_path);
        $cke_skins_path = rtrim($cke_skins_path, ' \\/');
        return $cke_static[$mode] = $cke_skins_path;
        break;
      case 'local':
        if (empty($global_profile->settings['ckeditor_skins_local_path']) && empty($global_profile->settings['ckeditor_skins_path'])) {
          return '';
        }
        if (!empty($global_profile->settings['ckeditor_skins_local_path'])) {
          return $cke_static[$mode] = $global_profile->settings['ckeditor_skins_local_path'];
        }
        if (!empty($global_profile->settings['ckeditor_skins_path'])) {
          $cke_skins_local_path = $global_profile->settings['ckeditor_skins_path'];
          $cke_skins_local_path = strtr($cke_skins_local_path, array(
            "%b" => ckeditor_base_path('local'),
            "%m" => ckeditor_module_path('local'),
            "%l" => ckeditor_library_path('local'),
          ));
          return $cke_static[$mode] = $cke_skins_local_path;
        }
        break;
      case 'url':
        if (empty($global_profile->settings['ckeditor_skins_path'])) {
          return '';
        }
        $cke_skins_path = $global_profile->settings['ckeditor_skins_path'];
        $cke_skins_path = strtr($cke_skins_path, array(
          "%m" => ckeditor_module_path('url'),
          "%l" => ckeditor_library_path('url'),
        ));
        $cke_skins_path = str_replace('\\', '/', $cke_skins_path);
        $cke_skins_path = str_replace('//', '/', $cke_skins_path);
        $cke_skins_path = rtrim($cke_skins_path, ' \\/');

        //In D7 base path in URL mode is not needed, so we need to remove it with trailing slash (if exists)
        $cke_skins_path = str_replace(array(
          "%b/",
          "%b",
        ), '', $cke_skins_path);
        return $cke_static[$mode] = $cke_skins_path;
        break;
    }
  }
  return isset($cke_static[$mode]) ? $cke_static[$mode] : '';
}