function wysiwyg_tinymce_init in Wysiwyg 7.2
Same name and namespace in other branches
- 6.2 editors/tinymce.inc \wysiwyg_tinymce_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.
1 string reference to 'wysiwyg_tinymce_init'
- wysiwyg_tinymce_editor in editors/
tinymce.inc - Plugin implementation of hook_editor().
File
- editors/
tinymce.inc, line 683 - Editor integration functions for TinyMCE.
Code
function wysiwyg_tinymce_init($editor, $library) {
// TinyMCE unconditionally searches for its library filename in SCRIPT tags on
// 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 TinyMCE are broken. The library has a
// tinyMCE.baseURL property, but it is not publicly documented and thus not
// reliable. The official support forum suggests to solve the issue through
// the global window.tinyMCEPreInit variable also used by various serverside
// compressor scrips available from the official website.
// @see http://www.tinymce.com/forum/viewtopic.php?id=23286
$settings = drupal_json_encode(array(
'base' => base_path() . $editor['library path'],
'suffix' => strpos($library, 'src') !== FALSE || strpos($library, 'dev') !== FALSE ? '_src' : (strpos($library, 'min') !== FALSE ? '.min' : ''),
'query' => '',
));
return <<<EOL
window.tinyMCEPreInit = {<span class="php-variable">$settings</span>};
EOL;
}