function wysiwyg_wymeditor_settings in Wysiwyg 5.2
Same name and namespace in other branches
- 6.2 editors/wymeditor.inc \wysiwyg_wymeditor_settings()
- 7.2 editors/wymeditor.inc \wysiwyg_wymeditor_settings()
Return runtime editor settings for a given wysiwyg profile.
Parameters
$editor: A processed hook_editor() array of editor properties.
$config: An array containing wysiwyg editor profile settings.
$theme: The name of a theme/GUI/skin to use.
Return value
A settings array to be populated in Drupal.settings.wysiwyg.configs.{editor}
1 string reference to 'wysiwyg_wymeditor_settings'
- wysiwyg_wymeditor_editor in editors/
wymeditor.inc - Plugin implementation of hook_editor().
File
- editors/
wymeditor.inc, line 98 - Editor integration functions for WYMeditor.
Code
function wysiwyg_wymeditor_settings($editor, $config, $theme) {
// @todo Setup $library in wysiwyg_load_editor() already.
$library = isset($editor['library']) ? $editor['library'] : key($editor['libraries']);
$settings = array(
'basePath' => base_path() . $editor['library path'] . '/',
'wymPath' => $editor['libraries'][$library]['files'][0],
// @todo Does not work in Drupal; jQuery can live anywhere.
'jQueryPath' => base_path() . 'misc/jquery.js',
'updateSelector' => '.form-submit',
'skin' => $theme,
);
if (isset($config['language'])) {
$settings['lang'] = $config['language'];
}
// Add configured buttons.
$settings['toolsItems'] = array();
if (!empty($config['buttons'])) {
$buttoninfo = _wysiwyg_wymeditor_button_info();
$plugins = wysiwyg_get_plugins($editor['name']);
foreach ($config['buttons'] as $plugin => $buttons) {
foreach ($buttons as $button => $enabled) {
// Iterate separately over buttons and extensions properties.
foreach (array(
'buttons',
'extensions',
) as $type) {
// Skip unavailable plugins.
if (!isset($plugins[$plugin][$type][$button])) {
continue;
}
// Add buttons.
if ($type == 'buttons') {
// Merge meta-data for internal default buttons.
if (isset($buttoninfo[$button])) {
$buttoninfo[$button] += array(
'name' => $button,
);
$settings['toolsItems'][] = $buttoninfo[$button];
}
else {
$settings['toolsItems'][] = array(
'name' => $button,
'title' => $plugins[$plugin][$type][$button],
'css' => 'wym_tools_' . $button,
);
}
}
}
}
}
}
if (!empty($config['block_formats'])) {
$containers = array(
'p' => 'Paragraph',
'h1' => 'Heading_1',
'h2' => 'Heading_2',
'h3' => 'Heading_3',
'h4' => 'Heading_4',
'h5' => 'Heading_5',
'h6' => 'Heading_6',
'pre' => 'Preformatted',
'blockquote' => 'Blockquote',
'th' => 'Table_Header',
);
foreach (explode(',', $config['block_formats']) as $tag) {
if (isset($containers[$tag])) {
$settings['containersItems'][] = array(
'name' => strtoupper($tag),
'title' => $containers[$tag],
'css' => 'wym_containers_' . $tag,
);
}
}
}
if (isset($config['css_setting'])) {
if ($config['css_setting'] == 'theme') {
// WYMeditor only supports one CSS file currently.
$css = wysiwyg_get_css();
$settings['stylesheet'] = reset($css);
}
else {
if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
$settings['stylesheet'] = strtr($config['css_path'], array(
'%b' => base_path(),
'%t' => path_to_theme(),
));
}
}
}
return $settings;
}