summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsun2009-09-26 05:37:57 (GMT)
committer sun2009-09-26 05:37:57 (GMT)
commit150bc86b2ce3fd0fedb04b622d64679a99e5e597 (patch)
tree01784efaa0bb0a359b30e5e1c9b6e8cc5cd1be48
parent619e0388ad912054436823f6e5cd4310f299cde1 (diff)
#585932 by sun: Ported to Drupal 7.
-rw-r--r--CHANGELOG.txt5
-rw-r--r--README.txt14
-rw-r--r--editors/js/ckeditor-3.0.js2
-rw-r--r--editors/js/fckeditor-2.6.js2
-rw-r--r--editors/js/jwysiwyg.js2
-rw-r--r--editors/js/markitup.js2
-rw-r--r--editors/js/nicedit.js2
-rw-r--r--editors/js/none.js9
-rw-r--r--editors/js/openwysiwyg.js3
-rw-r--r--editors/js/tinymce-2.js2
-rw-r--r--editors/js/tinymce-3.js6
-rw-r--r--editors/js/whizzywig.js2
-rw-r--r--editors/js/wymeditor.js3
-rw-r--r--editors/js/yui.js2
-rw-r--r--wysiwyg.admin.inc58
-rw-r--r--wysiwyg.info15
-rw-r--r--wysiwyg.install15
-rw-r--r--wysiwyg.js68
-rw-r--r--wysiwyg.module231
19 files changed, 233 insertions, 210 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index a7d768b..05c0b94 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -4,6 +4,11 @@ Wysiwyg x.x-x.x, xxxx-xx-xx
---------------------------
+Wysiwyg 7.x-3.x, xxxx-xx-xx
+---------------------------
+#585932 by sun: Ported to Drupal 7.
+
+
Wysiwyg 6.x-3.x, xxxx-xx-xx
---------------------------
#489156 by sun: Removed orphan global 'showToggle' JS setting.
diff --git a/README.txt b/README.txt
index afeb041..9d8d422 100644
--- a/README.txt
+++ b/README.txt
@@ -21,22 +21,24 @@ Bug reports, feature suggestions and latest developments:
* Install as usual, see http://drupal.org/node/70151 for further information.
-* Go to Administer > Site configuration > Wysiwyg, and follow the displayed
- installation instructions to download and install one of the supported
- editors.
+* Go to Administer > Configuration and modules > Content authoring > Wysiwyg,
+ and follow the displayed installation instructions to download and install one
+ of the supported editors.
-- CONFIGURATION --
-* Go to Administer > Site configuration > Input formats and
+* Go to Administer > Configuration and modules > Content authoring > Text
+ formats and
- either configure the Full HTML format, assign it to trusted roles, and
disable "HTML filter", "Line break converter", and (optionally) "URL filter".
- - or add a new input format, assign it to trusted roles, and ensure that above
+ - or add a new text format, assign it to trusted roles, and ensure that above
mentioned input filters are disabled.
-* Setup editor profiles in Administer > Site configuration > Wysiwyg.
+* Setup editor profiles in Administer > Configuration and modules > Content
+ authoring > Wysiwyg.
-- CONTACT --
diff --git a/editors/js/ckeditor-3.0.js b/editors/js/ckeditor-3.0.js
index 9982c09..d1b0a7e 100644
--- a/editors/js/ckeditor-3.0.js
+++ b/editors/js/ckeditor-3.0.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Attach this editor to a target element.
@@ -32,3 +33,4 @@ Drupal.wysiwyg.editor.detach.ckeditor = function(context, params) {
}
};
+})(jQuery);
diff --git a/editors/js/fckeditor-2.6.js b/editors/js/fckeditor-2.6.js
index 783fc57..86ed2d0 100644
--- a/editors/js/fckeditor-2.6.js
+++ b/editors/js/fckeditor-2.6.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Attach this editor to a target element.
@@ -154,3 +155,4 @@ Drupal.wysiwyg.editor.instance.fckeditor = {
}
};
+})(jQuery);
diff --git a/editors/js/jwysiwyg.js b/editors/js/jwysiwyg.js
index 50f949c..c573b49 100644
--- a/editors/js/jwysiwyg.js
+++ b/editors/js/jwysiwyg.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Attach this editor to a target element.
@@ -22,3 +23,4 @@ Drupal.wysiwyg.editor.detach.jwysiwyg = function(context, params) {
$field.show();
};
+})(jQuery);
diff --git a/editors/js/markitup.js b/editors/js/markitup.js
index 66e9bab..2fc2c90 100644
--- a/editors/js/markitup.js
+++ b/editors/js/markitup.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Attach this editor to a target element.
@@ -26,3 +27,4 @@ Drupal.wysiwyg.editor.detach.markitup = function(context, params) {
}
};
+})(jQuery);
diff --git a/editors/js/nicedit.js b/editors/js/nicedit.js
index 6fdc603..f62ddb1 100644
--- a/editors/js/nicedit.js
+++ b/editors/js/nicedit.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Attach this editor to a target element.
@@ -35,3 +36,4 @@ Drupal.wysiwyg.editor.detach.nicedit = function(context, params) {
}
};
+})(jQuery);
diff --git a/editors/js/none.js b/editors/js/none.js
index ff9b4df..003ca8d 100644
--- a/editors/js/none.js
+++ b/editors/js/none.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Attach this editor to a target element.
@@ -17,8 +18,8 @@ Drupal.wysiwyg.editor.attach.none = function(context, params, settings) {
if (params.resizable) {
$('#' + params.field).addClass('resizable');
$('#' + params.field).css({display: ''});
- if (Drupal.behaviors.textarea) {
- Drupal.behaviors.textarea();
+ if (Drupal.behaviors.textarea.attach) {
+ Drupal.behaviors.textarea.attach();
}
}
};
@@ -36,7 +37,7 @@ Drupal.wysiwyg.editor.attach.none = function(context, params, settings) {
*/
Drupal.wysiwyg.editor.detach.none = function(context, params) {
if (typeof params != 'undefined') {
- var $textarea = $('#' + params.field, context).removeClass('textarea-processed');
+ var $textarea = $('#' + params.field, context).removeOnce('textarea');
var $div = $textarea.parents('div.resizable-textarea');
$div.before($textarea);
$div.remove();
@@ -68,3 +69,5 @@ Drupal.wysiwyg.editor.instance.none = {
}
}
};
+
+})(jQuery);
diff --git a/editors/js/openwysiwyg.js b/editors/js/openwysiwyg.js
index cc40405..8e941bc 100644
--- a/editors/js/openwysiwyg.js
+++ b/editors/js/openwysiwyg.js
@@ -3,6 +3,8 @@
// Reset $() to jQuery. Yuck!
$ = jQuery;
+(function($) {
+
/**
* Attach this editor to a target element.
*/
@@ -95,3 +97,4 @@ WYSIWYG.viewText = function (n, id) {
$ = jQuery;
};
+})(jQuery);
diff --git a/editors/js/tinymce-2.js b/editors/js/tinymce-2.js
index ae65653..442487a 100644
--- a/editors/js/tinymce-2.js
+++ b/editors/js/tinymce-2.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Initialize editor instances.
@@ -196,3 +197,4 @@ Drupal.wysiwyg.editor.instance.tinymce = {
}
};
+})(jQuery);
diff --git a/editors/js/tinymce-3.js b/editors/js/tinymce-3.js
index 2b4ffaa..3b6fc21 100644
--- a/editors/js/tinymce-3.js
+++ b/editors/js/tinymce-3.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Initialize editor instances.
@@ -11,10 +12,6 @@
* An object containing editor settings for each input format.
*/
Drupal.wysiwyg.editor.init.tinymce = function(settings) {
- // @see #454992: drupal_get_js() must not use 'q' as query string.
- if (tinymce.query == 'q') {
- tinymce.query = '';
- }
// If JS compression is enabled, TinyMCE is unable to find its own base path
// and exec mode, hence we need to define it manually.
// @todo Move global library settings somewhere else.
@@ -212,3 +209,4 @@ Drupal.wysiwyg.editor.instance.tinymce = {
}
};
+})(jQuery);
diff --git a/editors/js/whizzywig.js b/editors/js/whizzywig.js
index df02994..3eb355d 100644
--- a/editors/js/whizzywig.js
+++ b/editors/js/whizzywig.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
var wysiwygWhizzywig = { currentField: null, fields: {} };
var buttonPath = null;
@@ -103,3 +104,4 @@ Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) {
}
};
+})(jQuery);
diff --git a/editors/js/wymeditor.js b/editors/js/wymeditor.js
index 44e956f..f1f59c7 100644
--- a/editors/js/wymeditor.js
+++ b/editors/js/wymeditor.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Attach this editor to a target element.
@@ -52,3 +53,5 @@ Drupal.wysiwyg.editor.instance.wymeditor = {
}
}
};
+
+})(jQuery);
diff --git a/editors/js/yui.js b/editors/js/yui.js
index f8d1577..7cce8fd 100644
--- a/editors/js/yui.js
+++ b/editors/js/yui.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Attach this editor to a target element.
@@ -36,3 +37,4 @@ Drupal.wysiwyg.editor.detach.yui = function(context, params) {
}
};
+})(jQuery);
diff --git a/wysiwyg.admin.inc b/wysiwyg.admin.inc
index 9b58215..f08178b 100644
--- a/wysiwyg.admin.inc
+++ b/wysiwyg.admin.inc
@@ -9,7 +9,7 @@
/**
* Form builder for Wysiwyg profile form.
*/
-function wysiwyg_profile_form($form_state, $profile) {
+function wysiwyg_profile_form($form, &$form_state, $profile) {
// Merge in defaults.
$profile = (array) $profile;
$profile += array(
@@ -48,9 +48,8 @@ function wysiwyg_profile_form($form_state, $profile) {
$formats = filter_formats();
$editor = wysiwyg_get_editor($profile->editor);
- drupal_set_title(t('%editor profile for %format', array('%editor' => $editor['title'], '%format' => $formats[$profile->format]->name)));
+ drupal_set_title(t('%editor profile for %format', array('%editor' => $editor['title'], '%format' => $formats[$profile->format]->name)), PASS_THROUGH);
- $form = array();
$form['format'] = array('#type' => 'value', '#value' => $profile->format);
$form['input_format'] = array('#type' => 'value', '#value' => $formats[$profile->format]->name);
$form['editor'] = array('#type' => 'value', '#value' => $profile->editor);
@@ -312,17 +311,17 @@ function wysiwyg_profile_form_submit($form, &$form_state) {
unset($values['submit'], $values['form_id'], $values['op'], $values['form_token'], $values['form_build_id']);
// Insert new profile data.
- db_query("UPDATE {wysiwyg} SET settings = '%s' WHERE format = %d", serialize($values), $format);
+ db_query("UPDATE {wysiwyg} SET settings = :settings WHERE format = :format", array(':settings' => serialize($values), ':format' => $format));
drupal_set_message(t('Wysiwyg profile for %format has been saved.', array('%format' => $input_format)));
- $form_state['redirect'] = 'admin/settings/wysiwyg';
+ $form_state['redirect'] = 'admin/config/content/wysiwyg';
}
/**
* Layout for the buttons in the Wysiwyg Editor profile form.
*/
-function theme_wysiwyg_admin_button_table(&$form) {
+function theme_wysiwyg_admin_button_table($form) {
$buttons = array();
// Flatten forms array.
@@ -355,9 +354,8 @@ function theme_wysiwyg_admin_button_table(&$form) {
/**
* Display overview of setup Wysiwyg Editor profiles; menu callback.
*/
-function wysiwyg_profile_overview() {
+function wysiwyg_profile_overview($form, &$form_state) {
include_once './includes/install.inc';
- $form = array();
// Check which wysiwyg editors are installed.
$editors = wysiwyg_get_all_editors();
@@ -405,7 +403,7 @@ function wysiwyg_profile_overview() {
'#description' => (!$count ? t('There are no editor libraries installed currently. The following list contains a list of currently supported editors:') : ''),
'#weight' => 10,
);
- $form['status']['report'] = array('#type' => 'markup', '#value' => theme('status_report', $status));
+ $form['status']['report'] = array('#markup' => theme('status_report', $status));
if (!$count) {
return $form;
@@ -414,22 +412,19 @@ function wysiwyg_profile_overview() {
$formats = filter_formats();
$profiles = wysiwyg_profile_load_all();
$form['formats'] = array(
- '#type' => 'fieldset',
- '#title' => t('Wysiwyg profiles'),
- '#description' => t('Once an editor has been associated with an input format, the editor association cannot be changed without first deleting the profile and then creating a new one. Delete a profile by clicking on the "delete" link and afterwards, set up a new profile as usual.'),
+ '#type' => 'item',
+ '#description' => t('To assign a different editor to a text format, click "delete" to remove the existing first.'),
'#tree' => TRUE,
);
foreach ($formats as $id => $format) {
$form['formats'][$id]['name'] = array(
- '#value' => check_plain($format->name),
+ '#markup' => check_plain($format->name),
);
// Only display editor selection for associated input formats to avoid
// confusion about disabled selection.
if (isset($profiles[$id]) && !empty($profiles[$id]->editor)) {
$form['formats'][$id]['editor'] = array(
- '#type' => 'markup',
- '#value' => $options[$profiles[$id]->editor],
- '#id' => "edit-editor-$id",
+ '#markup' => $options[$profiles[$id]->editor],
);
}
else {
@@ -437,15 +432,14 @@ function wysiwyg_profile_overview() {
'#type' => 'select',
'#default_value' => '',
'#options' => $options,
- '#id' => "edit-editor-$id",
);
}
if (isset($profiles[$id]) && !empty($profiles[$id]->editor)) {
$form['formats'][$id]['edit'] = array(
- '#value' => l(t('Edit'), "admin/settings/wysiwyg/profile/$id/edit"),
+ '#markup' => l(t('Edit'), "admin/config/content/wysiwyg/profile/$id/edit"),
);
$form['formats'][$id]['delete'] = array(
- '#value' => l(t('Delete'), "admin/settings/wysiwyg/profile/$id/delete"),
+ '#markup' => l(t('Delete'), "admin/config/content/wysiwyg/profile/$id/delete"),
);
}
}
@@ -457,7 +451,7 @@ function wysiwyg_profile_overview() {
/**
* Return HTML for the Wysiwyg profile overview form.
*/
-function theme_wysiwyg_profile_overview(&$form) {
+function theme_wysiwyg_profile_overview($form) {
if (!isset($form['formats'])) {
return;
}
@@ -473,8 +467,8 @@ function theme_wysiwyg_profile_overview(&$form) {
isset($format['delete']) ? drupal_render($format['delete']) : '',
);
}
- $form['formats']['#children'] = theme('table', $header, $rows);
- $output .= drupal_render($form);
+ $form['formats']['table']['#markup'] = theme('table', $header, $rows);
+ $output .= drupal_render_children($form);
return $output;
}
@@ -483,24 +477,26 @@ function theme_wysiwyg_profile_overview(&$form) {
*/
function wysiwyg_profile_overview_submit($form, &$form_state) {
foreach ($form_state['values']['formats'] as $format => $values) {
- db_query("UPDATE {wysiwyg} SET editor = '%s' WHERE format = %d", $values['editor'], $format);
- if (!db_affected_rows()) {
- db_query("INSERT INTO {wysiwyg} (format, editor) VALUES (%d, '%s')", $format, $values['editor']);
- }
+ db_merge('wysiwyg')
+ ->key(array('format' => $format))
+ ->fields(array(
+ 'editor' => $values['editor'],
+ ))
+ ->execute();
}
}
/**
* Delete editor profile confirmation form.
*/
-function wysiwyg_profile_delete_confirm(&$form_state, $profile) {
+function wysiwyg_profile_delete_confirm($form, &$form_state, $profile) {
$formats = filter_formats();
$format = $formats[$profile->format];
$form['format'] = array('#type' => 'value', '#value' => $format);
return confirm_form(
$form,
t('Are you sure you want to remove the profile for %name?', array('%name' => $format->name)),
- 'admin/settings/wysiwyg',
+ 'admin/config/content/wysiwyg',
t('This action cannot be undone.'), t('Remove'), t('Cancel')
);
}
@@ -514,13 +510,15 @@ function wysiwyg_profile_delete_confirm_submit($form, &$form_state) {
$format = $form_state['values']['format'];
wysiwyg_profile_delete($format->format);
drupal_set_message(t('Wysiwyg profile for %name has been deleted.', array('%name' => $format->name)));
- $form_state['redirect'] = 'admin/settings/wysiwyg';
+ $form_state['redirect'] = 'admin/config/content/wysiwyg';
}
/**
* Remove a profile from the database.
*/
function wysiwyg_profile_delete($format) {
- db_query("DELETE FROM {wysiwyg} WHERE format = %d", $format);
+ db_delete('wysiwyg')
+ ->condition('format', $format)
+ ->execute();
}
diff --git a/wysiwyg.info b/wysiwyg.info
index 8cdd4fc..196b4bd 100644
--- a/wysiwyg.info
+++ b/wysiwyg.info
@@ -2,9 +2,12 @@
name = Wysiwyg
description = Allows users to edit contents with client-side editors.
package = User interface
-dependencies[] = libraries
-dependencies[] = ctools
-dependencies[] = jquery_ui
-dependencies[] = popups
-dependencies[] = debug
-core = 6.x
+;dependencies[] = libraries
+;dependencies[] = ctools
+;dependencies[] = popups
+;dependencies[] = debug
+core = 7.x
+files[] = wysiwyg.module
+files[] = wysiwyg.install
+files[] = wysiwyg.admin.inc
+files[] = wysiwyg.dialog.inc
diff --git a/wysiwyg.install b/wysiwyg.install
index 09d96e4..cfdbc81 100644
--- a/wysiwyg.install
+++ b/wysiwyg.install
@@ -5,7 +5,6 @@
* Implementation of hook_schema().
*/
function wysiwyg_schema() {
- $schema = array();
$schema['wysiwyg'] = array(
'description' => t('Stores Wysiwyg profiles.'),
'fields' => array(
@@ -19,20 +18,6 @@ function wysiwyg_schema() {
}
/**
- * Implementation of hook_install().
- */
-function wysiwyg_install() {
- drupal_install_schema('wysiwyg');
-}
-
-/**
- * Implementation of hook_uninstall()
- */
-function wysiwyg_uninstall() {
- drupal_uninstall_schema('wysiwyg');
-}
-
-/**
* Implementation of hook_enable().
*/
function wysiwyg_enable() {
diff --git a/wysiwyg.js b/wysiwyg.js
index 449fdcb..f279deb 100644
--- a/wysiwyg.js
+++ b/wysiwyg.js
@@ -1,4 +1,5 @@
// $Id$
+(function($) {
/**
* Initialize editor libraries.
@@ -37,39 +38,45 @@ Drupal.wysiwygInit = function() {
* @param context
* A DOM element, supplied by Drupal.attachBehaviors().
*/
-Drupal.behaviors.attachWysiwyg = function(context) {
- // This breaks in Konqueror. Prevent it from running.
- if (/KDE/.test(navigator.vendor)) {
- return;
- }
-
- $('.wysiwyg:not(.wysiwyg-processed)', context).each(function() {
- var params = Drupal.wysiwyg.getParams(this);
- var $this = $(this).addClass('wysiwyg-processed');
- // Directly attach this editor, if the input format is enabled or there is
- // only one input format at all.
- if (($this.is(':input') && $this.is(':checked')) || $this.is('div')) {
- Drupal.wysiwygAttach(context, params);
+Drupal.behaviors.attachWysiwyg = {
+ attach: function(context, settings) {
+ // This breaks in Konqueror. Prevent it from running.
+ if (/KDE/.test(navigator.vendor)) {
+ return;
}
- // Attach onChange handlers to input format selector elements.
- if ($this.is(':input')) {
- $this.change(function() {
- // If not disabled, detach the current and attach a new editor.
- Drupal.wysiwygDetach(context, params);
- Drupal.wysiwygAttach(context, params);
- });
- // IE triggers onChange after blur only.
- if ($.browser.msie) {
- $this.click(function () {
- this.blur();
+
+ $('.wysiwyg', context).once('wysiwyg', function() {
+ if (!this.id || !this.value || typeof Drupal.settings.wysiwyg.triggers[this.id] === undefined) {
+ return;
+ }
+ var $this = $(this);
+ var params = Drupal.settings.wysiwyg.triggers[this.id];
+ for (var format in params) {
+ params[format].format = format;
+ params[format].trigger = this.id;
+ params[format].field = params.field;
+ }
+ var format = 'format' + this.value;
+ // Directly attach this editor, if the input format is enabled or there is
+ // only one input format at all.
+ if ($this.is(':input')) {
+ Drupal.wysiwygAttach(context, params[format]);
+ }
+ // Attach onChange handlers to input format selector elements.
+ if ($this.is('select')) {
+ $this.change(function() {
+ // If not disabled, detach the current and attach a new editor.
+ Drupal.wysiwygDetach(context, params[format]);
+ format = 'format' + this.value;
+ Drupal.wysiwygAttach(context, params[format]);
});
}
- }
- // Detach any editor when the containing form is submitted.
- $('#' + params.field).parents('form').submit(function () {
- Drupal.wysiwygDetach(context, params);
+ // Detach any editor when the containing form is submitted.
+ $('#' + params.field).parents('form').submit(function () {
+ Drupal.wysiwygDetach(context, params[format]);
+ });
});
- });
+ }
};
/**
@@ -169,7 +176,7 @@ Drupal.wysiwygAttachToggleLink = function(context, params) {
// Before enabling the editor, detach default behaviors.
Drupal.wysiwyg.editor.detach.none(context, params);
// Attach new editor using parameters of the currently selected input format.
- Drupal.wysiwyg.getParams($('.wysiwyg-field-' + params.field + ':checked, div.wysiwyg-field-' + params.field, context).get(0), params);
+ params = Drupal.settings.wysiwyg.triggers[params.trigger]['format' + $('#' + params.trigger).val()];
params.status = true;
Drupal.wysiwygAttach(context, params);
$(this).html(Drupal.settings.wysiwyg.disable).blur();
@@ -215,3 +222,4 @@ Drupal.wysiwyg.getParams = function(element, params) {
*/
Drupal.wysiwygInit();
+})(jQuery);
diff --git a/wysiwyg.module b/wysiwyg.module
index daa9317..8199a4c 100644
--- a/wysiwyg.module
+++ b/wysiwyg.module
@@ -10,36 +10,36 @@
* Implementation of hook_menu().
*/
function wysiwyg_menu() {
- $items['admin/settings/wysiwyg'] = array(
- 'title' => 'Wysiwyg',
+ $items['admin/config/content/wysiwyg'] = array(
+ 'title' => 'Wysiwyg profiles',
'page callback' => 'drupal_get_form',
'page arguments' => array('wysiwyg_profile_overview'),
'description' => 'Configure client-side editors.',
'access arguments' => array('administer filters'),
'file' => 'wysiwyg.admin.inc',
);
- $items['admin/settings/wysiwyg/profile'] = array(
- 'title' => 'Profiles',
+ $items['admin/config/content/wysiwyg/profile'] = array(
+ 'title' => 'List',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
- $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/edit'] = array(
+ $items['admin/config/content/wysiwyg/profile/%wysiwyg_profile/edit'] = array(
'title' => 'Edit',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('wysiwyg_profile_form', 4),
+ 'page arguments' => array('wysiwyg_profile_form', 5),
'access arguments' => array('administer filters'),
'file' => 'wysiwyg.admin.inc',
- 'tab_root' => 'admin/settings/wysiwyg/profile',
- 'tab_parent' => 'admin/settings/wysiwyg/profile/%wysiwyg_profile',
+ 'tab_root' => 'admin/config/content/wysiwyg/profile',
+ 'tab_parent' => 'admin/config/content/wysiwyg/profile/%wysiwyg_profile',
'type' => MENU_LOCAL_TASK,
);
- $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/delete'] = array(
+ $items['admin/config/content/wysiwyg/profile/%wysiwyg_profile/delete'] = array(
'title' => 'Remove',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('wysiwyg_profile_delete_confirm', 4),
+ 'page arguments' => array('wysiwyg_profile_delete_confirm', 5),
'access arguments' => array('administer filters'),
'file' => 'wysiwyg.admin.inc',
- 'tab_root' => 'admin/settings/wysiwyg/profile',
- 'tab_parent' => 'admin/settings/wysiwyg/profile/%wysiwyg_profile',
+ 'tab_root' => 'admin/config/content/wysiwyg/profile',
+ 'tab_parent' => 'admin/config/content/wysiwyg/profile/%wysiwyg_profile',
'type' => MENU_LOCAL_TASK,
'weight' => 10,
);
@@ -61,8 +61,12 @@ function wysiwyg_menu() {
*/
function wysiwyg_theme() {
return array(
- 'wysiwyg_profile_overview' => array('arguments' => array('form' => NULL)),
- 'wysiwyg_admin_button_table' => array('arguments' => array('form' => NULL)),
+ 'wysiwyg_profile_overview' => array(
+ 'arguments' => array('form' => NULL),
+ ),
+ 'wysiwyg_admin_button_table' => array(
+ 'arguments' => array('form' => NULL),
+ ),
'wysiwyg_dialog_page' => array(
'arguments' => array('content' => NULL, 'show_messages' => TRUE),
'file' => 'wysiwyg.dialog.inc',
@@ -76,7 +80,7 @@ function wysiwyg_theme() {
*/
function wysiwyg_help($path, $arg) {
switch ($path) {
- case 'admin/settings/wysiwyg':
+ case 'admin/config/content/wysiwyg':
$output = '<p>' . t('A Wysiwyg profile is associated with an input format. A Wysiwyg profile defines which client-side editor is loaded with a particular input format, what buttons or themes are enabled for the editor, how the editor is displayed, and a few other editor-specific functions.') . '</p>';
return $output;
}
@@ -102,96 +106,85 @@ function wysiwyg_form_alter(&$form, &$form_state) {
}
/**
- * Process a textarea for Wysiwyg Editor.
+ * Process a form to attach wysiwyg editors.
*
- * This way, we can recurse into the form and search for certain, hard-coded
- * elements that have been added by filter_form(). If an input format selector
- * or input format guidelines element is found, we assume that the preceding
- * element is the corresponding textarea and use it's #id for attaching
- * client-side editors.
+ * Recurse into the form and if an text format-enabled element is found, use its
+ * #id for attaching client-side editors.
*
- * @see wysiwyg_elements(), filter_form()
+ * @see form_process_text_format()
*/
function wysiwyg_process_form(&$form) {
- // Iterate over element children; resetting array keys to access last index.
- if ($children = array_values(element_children($form))) {
- foreach ($children as $index => $item) {
- $element = &$form[$item];
-
- // filter_form() always uses the key 'format'. We need a type-agnostic
- // match to prevent false positives. Also, there must have been at least
- // one element on this level.
- if ($item === 'format' && $index > 0) {
- // Make sure we either match a input format selector or input format
- // guidelines (displayed if user has access to one input format only).
- if ((isset($element['#type']) && $element['#type'] == 'fieldset') || isset($element['format']['guidelines'])) {
- // The element before this element is the target form field.
- $field = &$form[$children[$index - 1]];
-
- // Disable #resizable to avoid resizable behavior to hi-jack the UI,
- // but load the behavior, so the 'none' editor can attach/detach it.
- $extra_class = '';
- if (!empty($field['#resizable'])) {
- // Due to our CSS class parsing, we can add arbitrary parameters
- // for each input format.
- $extra_class = ' wysiwyg-resizable-1';
- $field['#resizable'] = FALSE;
- drupal_add_js('misc/textarea.js');
- }
+ foreach (element_children($form) as $item) {
+ // filter_form() always uses the key 'format'. We need a type-agnostic
+ // match to prevent false positives.
+ if (isset($form[$item]['#text_format'])) {
+ $element = &$form[$item]['format'];
+ $field = &$form[$item]['value'];
+ $settings = array(
+ 'field' => $field['#id'],
+ );
- // Determine the available input formats. The last child element is a
- // link to "More information about formatting options". When only one
- // input format is displayed, we also have to remove formatting
- // guidelines, stored in the child 'format'.
- $formats = element_children($element);
- array_pop($formats);
- if (($key = array_search('format', $formats)) !== FALSE) {
- unset($formats[$key]);
- }
- foreach ($formats as $format) {
- // Default to 'none' editor (Drupal's default behaviors).
- $editor = 'none';
- $status = 1;
- $toggle = 1;
- // Fetch the profile associated to this input format.
- $profile = wysiwyg_get_profile($format);
- if ($profile) {
- $editor = $profile->editor;
- $status = (int) wysiwyg_user_get_status($profile);
- if (isset($profile->settings['show_toggle'])) {
- $toggle = (int) $profile->settings['show_toggle'];
- }
- // Check editor theme (and reset it if not/no longer available).
- $theme = wysiwyg_get_editor_themes($profile, (isset($profile->settings['theme']) ? $profile->settings['theme'] : ''));
-
- // Add plugin settings (first) for this input format.
- wysiwyg_add_plugin_settings($profile);
- // Add profile settings for this input format.
- wysiwyg_add_editor_settings($profile, $theme);
- }
-
- // Use a prefix/suffix for a single input format, or attach to input
- // format selector radio buttons.
- if (isset($element['format']['guidelines'])) {
- $element['format']['guidelines']['#prefix'] = '<div class="wysiwyg wysiwyg-format-' . $format . ' wysiwyg-editor-' . $editor . ' wysiwyg-field-' . $field['#id'] . ' wysiwyg-status-' . $status . ' wysiwyg-toggle-' . $toggle . $extra_class . '">';
- $element['format']['guidelines']['#suffix'] = '</div>';
- // Edge-case: Default format contains no input filters.
- if (empty($element['format']['guidelines']['#value'])) {
- $element['format']['guidelines']['#value'] = ' ';
- }
- }
- else {
- $element[$format]['#attributes']['class'] = (isset($element[$format]['#attributes']['class']) ? $element[$format]['#attributes']['class'] . ' ' : '');
- $element[$format]['#attributes']['class'] .= 'wysiwyg wysiwyg-format-' . $format . ' wysiwyg-editor-' . $editor . ' wysiwyg-field-' . $field['#id'] . ' wysiwyg-status-' . $status . ' wysiwyg-toggle-' . $toggle . $extra_class;
- }
+ // Disable #resizable to avoid resizable behavior to hi-jack the UI,
+ // but load the behavior, so the 'none' editor can attach/detach it.
+ $resizable = 0;
+ if (!empty($field['#resizable'])) {
+ $resizable = 1;
+ $field['#resizable'] = FALSE;
+ drupal_add_js('misc/textarea.js');
+ }
+ // Determine the available input formats.
+ foreach ($element['format']['#options'] as $format_id => $format_name) {
+ $format = 'format' . $format_id;
+ // Initialize default settings, defaulting to 'none' editor.
+ $settings[$format]['editor'] = 'none';
+ $settings[$format]['status'] = 1;
+ $settings[$format]['toggle'] = 1;
+ $settings[$format]['resizable'] = $resizable;
+ // Fetch the profile associated to this text format.
+ $profile = wysiwyg_get_profile($format_id);
+ if ($profile) {
+ $settings[$format]['editor'] = $profile->editor;
+ $settings[$format]['status'] = (int) wysiwyg_user_get_status($profile);
+ if (isset($profile->settings['show_toggle'])) {
+ $settings[$format]['toggle'] = (int) $profile->settings['show_toggle'];
}
+ // Check editor theme (and reset it if not/no longer available).
+ $theme = wysiwyg_get_editor_themes($profile, (isset($profile->settings['theme']) ? $profile->settings['theme'] : ''));
+
+ // Add plugin settings (first) for this text format.
+ wysiwyg_add_plugin_settings($profile);
+ // Add profile settings for this text format.
+ wysiwyg_add_editor_settings($profile, $theme);
+
}
- // If this element is 'format', do not recurse further.
- continue;
}
- // Recurse into children.
- wysiwyg_process_form($element);
+ // Use a prefix/suffix for a single text format, or attach to text
+ // format selector radio buttons.
+ if (!$element['format']['#access']) {
+ $element['format_guidelines']['format'] = array(
+ '#type' => 'hidden',
+ '#name' => $element['format']['#name'],
+ '#id' => $element['format']['#id'],
+ '#value' => $format_id,
+ '#attributes' => array('class' => array('wysiwyg')),
+ );
+ $element['format_guidelines']['#attached']['js'][] = array(
+ 'data' => array('wysiwyg' => array('triggers' => array($element['format']['#id'] => $settings))),
+ 'type' => 'setting',
+ );
+ }
+ else {
+ $element['format']['#attributes']['class'][] = 'wysiwyg';
+ $element['format']['#attached']['js'][] = array(
+ 'data' => array('wysiwyg' => array('triggers' => array($element['format']['#id'] => $settings))),
+ 'type' => 'setting',
+ );
+ }
+ // If this element is '#text_format', do not recurse further.
+ continue;
}
+ // Recurse into children.
+ wysiwyg_process_form($form[$item]);
}
return $form;
}
@@ -254,7 +247,7 @@ function wysiwyg_load_editor($profile) {
}
foreach ($files as $file => $options) {
if (is_array($options)) {
- $options += array('type' => 'module', 'scope' => 'header', 'defer' => FALSE, 'cache' => TRUE, 'preprocess' => TRUE);
+ $options += array('type' => 'file', 'scope' => 'header', 'defer' => FALSE, 'cache' => TRUE, 'preprocess' => TRUE);
drupal_add_js($editor['library path'] . '/' . $file, $options['type'], $options['scope'], $options['defer'], $options['cache'], $options['preprocess']);
}
else {
@@ -284,7 +277,6 @@ function wysiwyg_load_editor($profile) {
}
drupal_add_js(array('wysiwyg' => array(
- 'configs' => array($editor['name'] => array()),
// @todo Move into (global) editor settings.
// If JS compression is enabled, at least TinyMCE is unable to determine
// its own base path and exec mode since it can't find the script name.
@@ -303,6 +295,7 @@ function wysiwyg_load_editor($profile) {
if (!isset($settings_added) && $loaded[$name]) {
drupal_add_js(array('wysiwyg' => array(
'configs' => array(),
+ 'plugins' => array(),
'disable' => t('Disable rich-text'),
'enable' => t('Enable rich-text'),
)), 'setting');
@@ -310,7 +303,7 @@ function wysiwyg_load_editor($profile) {
$path = drupal_get_path('module', 'wysiwyg');
// Initialize our namespaces in the *header* to do not force editor
// integration scripts to check and define Drupal.wysiwyg on its own.
- drupal_add_js($path . '/wysiwyg.init.js', 'core');
+ drupal_add_js($path . '/wysiwyg.init.js', array('weight' => JS_LIBRARY));
// The 'none' editor is a special editor implementation, allowing us to
// attach and detach regular Drupal behaviors just like any other editor.
@@ -322,7 +315,7 @@ function wysiwyg_load_editor($profile) {
// and Drupal.wysiwygInit() must be executed AFTER editors registered
// their callbacks and BEFORE Drupal.behaviors are applied, this must come
// last.
- drupal_add_js($path . '/wysiwyg.js', 'module', 'footer');
+ drupal_add_js($path . '/wysiwyg.js', array('scope' => 'footer'));
$settings_added = TRUE;
}
@@ -340,7 +333,9 @@ function wysiwyg_add_editor_settings($profile, $theme) {
$config = wysiwyg_get_editor_config($profile, $theme);
// drupal_to_js() does not properly convert numeric array keys, so we need
// to use a string instead of the format id.
- drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array('format' . $profile->format => $config)))), 'setting');
+ if ($config) {
+ drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array('format' . $profile->format => $config)))), 'setting');
+ }
$formats[$profile->format] = TRUE;
}
}
@@ -415,7 +410,9 @@ function wysiwyg_add_plugin_settings($profile) {
// settings for native external plugins with required values.
$settings_native = call_user_func($editor['plugin settings callback'], $editor, $profile, $profile_plugins_native);
- drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('native' => $settings_native)))), 'setting');
+ if ($settings_native) {
+ drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('native' => $settings_native)))), 'setting');
+ }
}
// Process Drupal plugins.
@@ -444,7 +441,9 @@ function wysiwyg_add_plugin_settings($profile) {
// the settings for Drupal plugins with custom, required values.
$settings_drupal = call_user_func($editor['proxy plugin settings callback'], $editor, $profile, $profile_plugins_drupal);
- drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('drupal' => $settings_drupal)))), 'setting');
+ if ($settings_drupal) {
+ drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('drupal' => $settings_drupal)))), 'setting');
+ }
}
}
@@ -547,15 +546,15 @@ function wysiwyg_get_css() {
return $files;
}
// In node form previews, the theme has not been initialized yet.
- init_theme();
+ if (!empty($_POST)) {
+ drupal_theme_initialize();
+ }
$files = array();
- foreach (drupal_add_css() as $media => $css) {
- if ($media != 'print') {
- foreach ($css['theme'] as $filepath => $preprocess) {
- if (file_exists($filepath)) {
- $files[] = base_path() . $filepath;
- }
+ foreach (drupal_add_css() as $filepath => $info) {
+ if ($info['weight'] >= CSS_THEME && $info['media'] != 'print') {
+ if (file_exists($filepath)) {
+ $files[] = base_path() . $filepath;
}
}
}
@@ -569,8 +568,8 @@ function wysiwyg_profile_load($format) {
static $profiles;
if (!isset($profiles) || !array_key_exists($format, $profiles)) {
- $result = db_query('SELECT format, editor, settings FROM {wysiwyg} WHERE format = %d', $format);
- while ($profile = db_fetch_object($result)) {
+ $result = db_query('SELECT format, editor, settings FROM {wysiwyg} WHERE format = :format', array(':format' => $format));
+ foreach ($result as $profile) {
$profile->settings = unserialize($profile->settings);
$profiles[$profile->format] = $profile;
}
@@ -588,7 +587,7 @@ function wysiwyg_profile_load_all() {
if (!isset($profiles)) {
$profiles = array();
$result = db_query('SELECT format, editor, settings FROM {wysiwyg}');
- while ($profile = db_fetch_object($result)) {
+ foreach ($result as $profile) {
$profile->settings = unserialize($profile->settings);
$profiles[$profile->format] = $profile;
}
@@ -783,15 +782,15 @@ function wysiwyg_load_includes($type = 'editors', $hook = 'editor', $file = NULL
$directories['wysiwyg'] = drupal_get_path('module', 'wysiwyg') . '/' . $type;
$file_list = array();
foreach ($directories as $module => $path) {
- $file_list[$module] = drupal_system_listing("$file" . '.inc$', $path, 'name', 0);
+ $file_list[$module] = drupal_system_listing("/{$file}.inc\$/", $path, 'name', 0);
}
// Load implementations.
$info = array();
foreach (array_filter($file_list) as $module => $files) {
foreach ($files as $file) {
- include_once './' . $file->filename;
- $result = _wysiwyg_process_include($module, $module . '_' . $file->name, dirname($file->filename), $hook);
+ include_once './' . $file->uri;
+ $result = _wysiwyg_process_include($module, $module . '_' . $file->name, dirname($file->uri), $hook);
if (is_array($result)) {
$info = array_merge($info, $result);
}