View source
<?php
function wysiwyg_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {wysiwyg} (\n format int NOT NULL default '0',\n editor varchar(128) NOT NULL default '',\n settings text,\n PRIMARY KEY (format)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */");
break;
case 'pgsql':
db_query("CREATE TABLE {wysiwyg} (\n format int NOT NULL default '0',\n editor varchar(128) NOT NULL default '',\n settings text,\n PRIMARY KEY (format)\n )");
break;
}
}
function wysiwyg_uninstall() {
db_query('DROP TABLE {wysiwyg}');
}
function wysiwyg_enable() {
module_disable(array(
'ckeditor',
'editarea',
'editonpro',
'editor',
'fckeditor',
'freerte',
'htmlarea',
'htmlbox',
'jwysiwyg',
'markitup',
'nicedit',
'openwysiwyg',
'pegoeditor',
'quicktext',
'tinymce',
'tinymce_autoconf',
'tinytinymce',
'whizzywig',
'widgeditor',
'wymeditor',
'xstandard',
'yui_editor',
));
}
function _wysiwyg_install_get_formats() {
$formats = array();
$result = db_query("SELECT format, name FROM {filter_formats}");
while ($format = db_fetch_object($result)) {
$formats[$format->format] = $format->name;
$result2 = db_query("SELECT module, delta FROM {filters} WHERE format = %d", $format->format);
while ($filter = db_fetch_object($result2)) {
if ($filter->module == 'filter' && $filter->delta == 1) {
unset($formats[$format->format]);
break;
}
}
}
return $formats;
}
function wysiwyg_update_5001() {
$ret = array();
if (db_table_exists('wysiwyg')) {
return $ret;
}
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("CREATE TABLE {wysiwyg} (\n format int NOT NULL default '0',\n editor varchar(128) NOT NULL default '',\n settings text,\n PRIMARY KEY (format)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */");
break;
case 'pgsql':
$ret[] = update_sql("CREATE TABLE {wysiwyg} (\n format int NOT NULL default '0',\n editor varchar(128) NOT NULL default '',\n settings text,\n PRIMARY KEY (format)\n )");
break;
}
$formats = _wysiwyg_install_get_formats();
$result = db_query("SELECT name, settings FROM {wysiwyg_profile}");
while ($profile = db_fetch_object($result)) {
$profile->settings = unserialize($profile->settings);
$profile->editor = $profile->settings['editor'];
unset($profile->settings['editor']);
unset($profile->settings['old_name']);
unset($profile->settings['name']);
unset($profile->settings['rids']);
break;
}
if ($profile) {
foreach ($formats as $format => $name) {
db_query("INSERT INTO {wysiwyg} (format, editor, settings) VALUES (%d, '%s', '%s')", $format, $profile->editor, serialize($profile->settings));
$ret[] = array(
'success' => TRUE,
'query' => strtr('Wysiwyg profile %profile converted and associated with input format %format.', array(
'%profile' => check_plain($profile->name),
'%format' => check_plain($name),
)),
);
}
}
$ret[] = update_sql("DROP TABLE {wysiwyg_profile}");
$ret[] = update_sql("DROP TABLE {wysiwyg_role}");
return $ret;
}
function wysiwyg_update_5200() {
$ret = array();
drupal_clear_css_cache();
menu_rebuild();
cache_clear_all();
$ret[] = array(
'success' => TRUE,
'query' => 'Caches have been flushed.',
);
return $ret;
}
function wysiwyg_update_5201() {
$ret = array();
$results = db_query("SELECT format, settings FROM {wysiwyg} WHERE editor = 'tinymce'");
while ($profile = db_fetch_object($results)) {
$settings = unserialize($profile->settings);
$changed = FALSE;
foreach (array(
'formatselect',
'fontselect',
'fontsizeselect',
'styleselect',
) as $button) {
if (isset($settings['buttons']['font'][$button])) {
$settings['buttons']['default'][$button] = $settings['buttons']['font'][$button];
unset($settings['buttons']['font'][$button]);
$changed = TRUE;
}
}
if ($changed) {
db_query("UPDATE {wysiwyg} SET settings='%s' WHERE format = '%s'", array(
serialize($settings),
$profile->format,
));
}
}
$ret[] = array(
'success' => TRUE,
'query' => 'TinyMCE profiles have been updated.',
);
return $ret;
}