You are here

function ckfinder_path in CKEditor - WYSIWYG HTML editor 7

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

Read the CKFinder path from the Global profile.

Return value

Path to CKFinder folder.

4 calls to ckfinder_path()
ckeditor_admin_global_profile_form in includes/ckeditor.admin.inc
Form builder for a global profile
ckeditor_permission in ./ckeditor.module
Implementation of hook_permission().
ckeditor_profile_settings_compile in includes/ckeditor.lib.inc
Compile settings of profile
_ckeditor_requirements_ckfinder_config_check in ./ckeditor.install
Executed when the built-in file browser is enabled. Returns FALSE if no errors are found in the config.php file, otherwise it returns an error message.

File

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

Code

function ckfinder_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['ckfinder_path'])) {
          $ckfinder_path = $global_profile->settings['ckfinder_path'];
          $ckfinder_path = strtr($ckfinder_path, array(
            "%b" => ckeditor_base_path('relative'),
            "%m" => ckeditor_module_path('relative'),
            "%l" => ckeditor_library_path('relative'),
          ));
          $ckfinder_path = str_replace('\\', '/', $ckfinder_path);
          $ckfinder_path = str_replace('//', '/', $ckfinder_path);
          return $cke_static[$mode] = $ckfinder_path;
        }
        return $cke_static[$mode] = ckeditor_module_path('relative') . '/ckfinder';
      case 'local':
        if ($global_profile) {
          if (!empty($global_profile->settings['ckfinder_local_path'])) {
            return $cke_static[$mode] = $global_profile->settings['ckfinder_local_path'];
          }
          if (isset($global_profile->settings['ckfinder_path'])) {
            $ckfinder_path = $global_profile->settings['ckfinder_path'];
            $ckfinder_path = strtr($ckfinder_path, array(
              "%b" => ckeditor_base_path('local'),
              "%m" => ckeditor_module_path('local'),
              "%l" => ckeditor_library_path('local'),
            ));
            return $cke_static[$mode] = $ckfinder_path;
          }
        }
        return $cke_static[$mode] = ckeditor_module_path('local') . '/ckfinder';
      case 'url':
        if ($global_profile && isset($global_profile->settings['ckfinder_path'])) {
          $ckfinder_path = $global_profile->settings['ckfinder_path'];
          $ckfinder_path = strtr($ckfinder_path, array(
            "%m" => ckeditor_module_path('url'),
            "%l" => ckeditor_library_path('url'),
          ));
          $ckfinder_path = str_replace('\\', '/', $ckfinder_path);
          $ckfinder_path = str_replace('//', '/', $ckfinder_path);

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