5 * Editor integration functions for openWYSIWYG.
9 * Plugin implementation of hook_editor().
11 function wysiwyg_openwysiwyg_editor() {
12 $editor['openwysiwyg'] = array(
13 'title' => 'openWYSIWYG',
14 'vendor url' => 'http://www.openwebware.com',
15 'download url' => 'http://www.openwebware.com/download.shtml',
16 'library path' => wysiwyg_get_path('openwysiwyg') .
'/scripts',
20 'files' => array('wysiwyg.js'),
23 'version callback' => 'wysiwyg_openwysiwyg_version',
24 'themes callback' => 'wysiwyg_openwysiwyg_themes',
25 'settings callback' => 'wysiwyg_openwysiwyg_settings',
26 'plugin callback' => 'wysiwyg_openwysiwyg_plugins',
29 'js files' => array('openwysiwyg.js'),
30 'css files' => array('openwysiwyg.css'),
38 * Detect editor version.
41 * An array containing editor properties as returned from hook_editor().
44 * The installed editor version.
46 function wysiwyg_openwysiwyg_version($editor) {
47 // 'library path' has '/scripts' appended already.
48 $changelog = $editor['editor path'] .
'/changelog';
49 if (!file_exists($changelog)) {
52 $changelog = fopen($changelog, 'r');
53 $line = fgets($changelog, 20);
54 if (preg_match('@v([\d\.]+)@', $line, $version)) {
62 * Determine available editor themes or check/reset a given one.
65 * A processed hook_editor() array of editor properties.
67 * A wysiwyg editor profile.
70 * An array of theme names. The first returned name should be the default
73 function wysiwyg_openwysiwyg_themes($editor, $profile) {
74 return array('default');
78 * Return runtime editor settings for a given wysiwyg profile.
81 * A processed hook_editor() array of editor properties.
83 * An array containing wysiwyg editor profile settings.
85 * The name of a theme/GUI/skin to use.
88 * A settings array to be populated in
89 * Drupal.settings.wysiwyg.configs.{editor}
91 function wysiwyg_openwysiwyg_settings($editor, $config, $theme) {
93 'path' => base_path() .
$editor['editor path'] .
'/',
97 if (isset($config['path_loc']) && $config['path_loc'] == 'none') {
98 $settings['StatusBarEnabled'] = FALSE
;
101 if (isset($config['css_setting'])) {
102 if ($config['css_setting'] == 'theme') {
103 $settings['CSSFile'] = reset(wysiwyg_get_css());
105 else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
106 $settings['CSSFile'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
110 $settings['Toolbar'] = array();
111 if (!empty($config['buttons'])) {
112 $plugins = wysiwyg_get_plugins($editor['name']);
113 foreach ($config['buttons'] as
$plugin => $buttons) {
114 foreach ($buttons as
$button => $enabled) {
115 foreach (array('buttons', 'extensions') as
$type) {
116 // Skip unavailable plugins.
117 if (!isset($plugins[$plugin][$type][$button])) {
121 if ($type == 'buttons') {
122 $settings['Toolbar'][0][] = $button;
130 // if (isset($config['block_formats'])) {
131 // $settings['DropDowns']['headings']['elements'] = explode(',', $config['block_formats']);
138 * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().
140 function wysiwyg_openwysiwyg_plugins($editor) {
144 'bold' => t('Bold'), 'italic' => t('Italic'), 'underline' => t('Underline'),
145 'strikethrough' => t('Strike-through'),
146 'justifyleft' => t('Align left'), 'justifycenter' => t('Align center'), 'justifyright' => t('Align right'), 'justifyfull' => t('Justify'),
147 'unorderedlist' => t('Bullet list'), 'orderedlist' => t('Numbered list'),
148 'outdent' => t('Outdent'), 'indent' => t('Indent'),
149 'undo' => t('Undo'), 'redo' => t('Redo'),
150 'createlink' => t('Link'),
151 'insertimage' => t('Image'),
152 'cleanup' => t('Clean-up'),
153 'forecolor' => t('Forecolor'), 'backcolor' => t('Backcolor'),
154 'superscript' => t('Sup'), 'subscript' => t('Sub'),
155 'blockquote' => t('Blockquote'), 'viewSource' => t('Source code'),
156 'hr' => t('Horizontal rule'),
157 'cut' => t('Cut'), 'copy' => t('Copy'), 'paste' => t('Paste'),
158 'visualaid' => t('Visual aid'),
159 'removeformat' => t('Remove format'),
160 'charmap' => t('Character map'),
161 'headings' => t('HTML block format'), 'font' => t('Font'), 'fontsize' => t('Font size'),
162 'maximize' => t('Fullscreen'),
163 'preview' => t('Preview'),
164 'print' => t('Print'),
165 'inserttable' => t('Table'),