Issue #1073106 by scottrouse: Fixed 'Input Format' should be 'Text Format'.
[project/wysiwyg.git] / editors / whizzywig.inc
CommitLineData
f2446499 1<?php
f2446499 2
54a65ca8 3/**
4 * @file
5 * Editor integration functions for Whizzywig.
6 */
f2446499 7
8/**
9 * Plugin implementation of hook_editor().
10 */
11function wysiwyg_whizzywig_editor() {
f2446499 12 $editor['whizzywig'] = array(
13 'title' => 'Whizzywig',
14 'vendor url' => 'http://www.unverse.net',
15 'download url' => 'http://www.unverse.net/whizzywig-download.html',
f2446499 16 'libraries' => array(
17 '' => array(
18 'title' => 'Default',
19 'files' => array('whizzywig.js', 'xhtml.js'),
20 ),
21 ),
22 'version callback' => 'wysiwyg_whizzywig_version',
23 'settings callback' => 'wysiwyg_whizzywig_settings',
24 'plugin callback' => 'wysiwyg_whizzywig_plugins',
25 'versions' => array(
26 '55' => array(
27 'js files' => array('whizzywig.js'),
28 ),
bae1780d 29 '56' => array(
30 'js files' => array('whizzywig-56.js'),
31 ),
33054619 32 '60' => array(
33 'js files' => array('whizzywig-60.js'),
34 ),
f2446499 35 ),
36 );
37 return $editor;
38}
39
40/**
41 * Detect editor version.
42 *
43 * @param $editor
44 * An array containing editor properties as returned from hook_editor().
45 *
46 * @return
47 * The installed editor version.
48 */
49function wysiwyg_whizzywig_version($editor) {
c18af709 50 $script = $editor['library path'] . '/whizzywig.js';
eb20f245 51 if (!file_exists($script)) {
52 return;
53 }
f2446499 54 $script = fopen($script, 'r');
55 $line = fgets($script, 43);
767c92a5 56 // 55: Whizzywig v55i
57 // 60: Whizzywig 60
58 if (preg_match('@Whizzywig v?([0-9]+)@', $line, $version)) {
f2446499 59 fclose($script);
60 return $version[1];
61 }
54a65ca8 62 fclose($script);
f2446499 63}
64
65/**
66 * Return runtime editor settings for a given wysiwyg profile.
67 *
68 * @param $editor
69 * A processed hook_editor() array of editor properties.
70 * @param $config
71 * An array containing wysiwyg editor profile settings.
72 * @param $theme
73 * The name of a theme/GUI/skin to use.
74 *
75 * @return
76 * A settings array to be populated in
77 * Drupal.settings.wysiwyg.configs.{editor}
78 */
79function wysiwyg_whizzywig_settings($editor, $config, $theme) {
80 $settings = array();
81
82 // Add path to button images, if available.
c18af709 83 if (is_dir($editor['library path'] . '/btn')) {
84 $settings['buttonPath'] = base_path() . $editor['library path'] . '/btn/';
f2446499 85 }
bae1780d 86 if (file_exists($editor['library path'] . '/WhizzywigToolbar.png')) {
87 $settings['toolbarImagePath'] = base_path() . $editor['library path'] . '/WhizzywigToolbar.png';
88 }
767c92a5 89 // Filename changed in version 60.
90 elseif (file_exists($editor['library path'] . '/icons.png')) {
91 $settings['toolbarImagePath'] = base_path() . $editor['library path'] . '/icons.png';
92 }
f2446499 93
94 // Add configured buttons or all available.
76bbca67 95 $settings['buttons'] = array();
f2446499 96 if (!empty($config['buttons'])) {
97 $buttons = array();
98 foreach ($config['buttons'] as $plugin) {
99 $buttons = array_merge($buttons, $plugin);
100 }
101 $settings['buttons'] = implode(' ', array_keys($buttons));
102 }
f2446499 103
104 // Add editor content stylesheet.
105 if (isset($config['css_setting'])) {
106 if ($config['css_setting'] == 'theme') {
54a65ca8 107 $css = path_to_theme() . '/style.css';
f2446499 108 if (file_exists($css)) {
109 $settings['externalCSS'] = base_path() . $css;
110 }
111 }
9d5e7fc0 112 elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
f2446499 113 $settings['externalCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
114 }
115 }
116
117 return $settings;
118}
119
120/**
54a65ca8 121 * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().
f2446499 122 */
123function wysiwyg_whizzywig_plugins($editor) {
124 return array(
125 'default' => array(
126 'buttons' => array(
127 'formatblock' => t('HTML block format'), 'fontname' => t('Font'), 'fontsize' => t('Font size'),
128 'bold' => t('Bold'), 'italic' => t('Italic'), 'underline' => t('Underline'),
129 'left' => t('Align left'), 'center' => t('Align center'), 'right' => t('Align right'),
130 'bullet' => t('Bullet list'), 'number' => t('Numbered list'),
131 'outdent' => t('Outdent'), 'indent' => t('Indent'),
132 'undo' => t('Undo'), 'redo' => t('Redo'),
133 'image' => t('Image'),
134 'color' => t('Forecolor'), 'hilite' => t('Backcolor'),
135 'rule' => t('Horizontal rule'),
136 'link' => t('Link'),
137 'image' => t('Image'),
138 'table' => t('Table'),
139 'clean' => t('Clean-up'),
140 'html' => t('Source code'),
141 'spellcheck' => t('Spell check'),
142 ),
143 'internal' => TRUE,
144 ),
145 );
146}
147