You are here

function wysiwyg_ckeditor_init in Wysiwyg 6.2

Same name and namespace in other branches
  1. 7.2 editors/ckeditor.inc \wysiwyg_ckeditor_init()

Returns an initialization JavaScript for this editor library.

Parameters

array $editor: The editor library definition.

string $library: The library variant key from $editor['libraries'].

object $profile: The (first) wysiwyg editor profile.

Return value

string A string containing inline JavaScript to execute before the editor library script is loaded.

2 string references to 'wysiwyg_ckeditor_init'
hook_INCLUDE_editor in ./wysiwyg.api.php
Define a Wysiwyg editor library.
wysiwyg_ckeditor_editor in editors/ckeditor.inc
Plugin implementation of hook_editor().

File

editors/ckeditor.inc, line 446
Editor integration functions for CKEditor.

Code

function wysiwyg_ckeditor_init($editor) {

  // Pass Drupal's JS cache-busting string via settings along to CKEditor.
  drupal_add_js(array(
    'wysiwyg' => array(
      'ckeditor' => array(
        'timestamp' => variable_get('css_js_query_string', '0'),
      ),
    ),
  ), 'setting');

  // CKEditor unconditionally searches for its library filename in SCRIPT tags
  // on the page upon loading the library in order to determine the base path to
  // itself. When JavaScript aggregation is enabled, this search fails and all
  // relative constructed paths within CKEditor are broken. The library has a
  // CKEditor.basePath property, but it is not publicly documented and thus not
  // reliable. The official documentation suggests to solve the issue through
  // the global window variable.
  // @see http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Specifying_the_Editor_Path
  $library_path = base_path() . $editor['library path'] . '/';
  return <<<EOL
window.CKEDITOR_BASEPATH = '{<span class="php-variable">$library_path</span>}';
EOL;
}