You are here

function ckeditor_path in CKEditor - WYSIWYG HTML editor 7

Same name and namespace in other branches
  1. 6 ckeditor.module \ckeditor_path()

Read the CKEditor path from the Global profile.

Return value

Path to CKEditor folder.

18 calls to ckeditor_path()
ckeditor_admin_global_profile_form in includes/ckeditor.admin.inc
Form builder for a global profile
ckeditor_admin_main in includes/ckeditor.admin.inc
Main administrative page
ckeditor_admin_profile_form in includes/ckeditor.admin.inc
Form builder for a profile
ckeditor_ckeditor_plugin in ./ckeditor.ckeditor.inc
Implements hook_ckeditor_plugin().
ckeditor_get_version in ./ckeditor.module
Check CKEditor version

... See full list

File

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

Code

function ckeditor_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);
    switch ($mode) {
      default:
      case 'relative':
        if ($global_profile && isset($global_profile->settings['ckeditor_path'])) {

          // http:// OR https:// OR //
          if (preg_match("|^(http(s)?:)?//|i", $global_profile->settings['ckeditor_path'])) {
            return '<URL>';
          }
          $cke_path = $global_profile->settings['ckeditor_path'];
          $cke_path = strtr($cke_path, array(
            "%b" => ckeditor_base_path('relative'),
            "%m" => ckeditor_module_path('relative'),
            "%l" => ckeditor_library_path('relative'),
          ));
          $cke_path = str_replace('\\', '/', $cke_path);
          $cke_path = str_replace('//', '/', $cke_path);
          return $cke_static[$mode] = $cke_path;
        }
        return $cke_static[$mode] = ckeditor_module_path('relative') . '/ckeditor';
      case 'local':
        if ($global_profile) {
          if (!empty($global_profile->settings['ckeditor_local_path'])) {
            return $cke_static[$mode] = $global_profile->settings['ckeditor_local_path'];
          }
          if (isset($global_profile->settings['ckeditor_path'])) {

            // http:// OR https:// OR //
            if (preg_match("|^(http(s)?:)?//|i", $global_profile->settings['ckeditor_path'])) {
              return '<URL>';
            }
            $cke_local_path = $global_profile->settings['ckeditor_path'];
            $cke_local_path = strtr($cke_local_path, array(
              "%b" => ckeditor_base_path('local'),
              "%m" => ckeditor_module_path('local'),
              "%l" => ckeditor_library_path('local'),
            ));
            return $cke_static[$mode] = $cke_local_path;
          }
        }
        return $cke_static[$mode] = ckeditor_module_path('local') . '/ckeditor';
      case 'url':
        if ($global_profile && isset($global_profile->settings['ckeditor_path'])) {

          // http:// OR https:// OR //
          if (preg_match("|^(http(s)?:)?//|i", $global_profile->settings['ckeditor_path'])) {
            $cke_path = $global_profile->settings['ckeditor_path'];
          }
          else {
            $cke_path = $global_profile->settings['ckeditor_path'];
            $cke_path = strtr($cke_path, array(
              "%m" => ckeditor_module_path('url'),
              "%l" => ckeditor_library_path('url'),
            ));
            $cke_path = str_replace('\\', '/', $cke_path);
            $cke_path = str_replace('//', '/', $cke_path);

            //In D7 base path in URL mode is not needed, so we need to remove it with trailing slash (if exists)
            $cke_path = str_replace(array(
              "%b/",
              "%b",
            ), '', $cke_path);
          }
          return $cke_static[$mode] = $cke_path;
        }
        return $cke_static[$mode] = ckeditor_module_path('url') . '/ckeditor';
    }
  }
  return $cke_static[$mode];
}