t('Stores Wysiwyg Editor profiles.'), 'fields' => array( 'name' => array( 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', ), 'settings' => array( 'type' => 'text', 'size' => 'normal', ), 'plugin_count' => array( 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), ), 'primary key' => array('name'), ); $schema['wysiwyg_editor_role'] = array( 'description' => t('Stores user role access permissions for Wysiwyg Editor profiles.'), 'fields' => array( 'name' => array( 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', ), 'rid' => array( 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), ), 'primary key' => array('name', 'rid'), ); return $schema; } /** * Implementation of hook_install(). */ function wysiwyg_editor_install() { drupal_install_schema('wysiwyg_editor'); // Import data from old editor modules. wysiwyg_editor_migrate_tinymce(); } /** * Implementation of hook_uninstall() */ function wysiwyg_editor_uninstall() { drupal_uninstall_schema('wysiwyg_editor'); } /** * Migrate from TinyMCE. */ function wysiwyg_editor_migrate_tinymce() { if (db_table_exists('tinymce_settings')) { $schema = db_result(db_query("SELECT schema_version FROM {system} WHERE name = 'tinymce'")); if ($schema >= 1) { // Import TinyMCE settings. db_query('INSERT INTO {wysiwyg_editor_profile} (name, settings) SELECT name, settings FROM {tinymce_settings}'); // Import TinyMCE profile role assignments. db_query('INSERT INTO {wysiwyg_editor_role} (name, rid) SELECT name, rid FROM {tinymce_role}'); // Disable TinyMCE module. module_disable(array('tinymce')); // Update configuration. wysiwyg_editor_update_5001(); } else { drupal_set_message(t('To migrate your existing TinyMCE settings to Wysiwyg Editor, please update TinyMCE module to the latest official release, and re-install Wysiwyg Editor module.')); } } } /** * Convert buttons and plugins into associative array and fix plugin count for old profiles. * * Note: This update is required for wysiwyg_editor_migrate_tinymce(). */ function wysiwyg_editor_update_5001() { $ret = array(); $profiles = db_query("SELECT name, settings, plugin_count FROM {wysiwyg_editor_profile}"); while ($profile = db_fetch_array($profiles)) { $settings = unserialize($profile['settings']); if (isset($settings['form_id'])) { $old_buttons = $settings['buttons']; $settings['buttons'] = array(); $plugin_count = 0; foreach ($old_buttons as $old_button => $enabled) { list($plugin, $button) = explode('-', $old_button, 2); $settings['buttons'][$plugin][$button] = 1; $plugin_count++; } // We can't use update_sql() here because of curly braces in serialized // array. db_query("UPDATE {wysiwyg_editor_profile} SET settings = '%s', plugin_count = %d WHERE name = '%s'", serialize($settings), $plugin_count, $profile['name']); } } return $ret; }