function ckeditor_update_6102 in CKEditor - WYSIWYG HTML editor 6
Implementation of hook_update_N().
Moves toolbar definition from the configuration file to the database - toolbar definition is now set in the CKEditor profile.
File
- ./
ckeditor.install, line 548
Code
function ckeditor_update_6102() {
module_load_include('module', 'ckeditor');
module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
$ret = array();
$result = db_query("SELECT * FROM {ckeditor_settings} WHERE name <> 'CKEditor Global Profile'");
while ($profile = db_fetch_object($result)) {
$name = $profile->name;
$settings = unserialize($profile->settings);
if ($settings['toolbar'] == 'DrupalBasic') {
$settings['toolbar'] = "\n[\n [ 'Format', 'Bold', 'Italic', '-', 'NumberedList','BulletedList', '-', 'Link', 'Unlink', 'Image' ]\n]\n ";
$settings = serialize($settings);
$return = db_query("UPDATE {ckeditor_settings} SET settings = '%s' WHERE name = '%s'", $settings, $name);
$ret[] = array(
'success' => $return !== FALSE,
'query' => "UPDATE PROFILE - {$name}",
);
}
elseif ($settings['toolbar'] == 'DrupalFiltered') {
$settings['toolbar'] = "\n[\n ['Source'],\n ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],\n ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],\n ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],\n ['Maximize', 'ShowBlocks'],\n '/',\n ['Format'],\n ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],\n ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],\n ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiRtl','BidiLtr'],\n ['Link','Unlink','Anchor','Linkit','LinkToNode','LinkToMenu'],\n ['DrupalBreak', 'DrupalPageBreak']\n]\n ";
$settings = serialize($settings);
$return = db_query("UPDATE {ckeditor_settings} SET settings = '%s' WHERE name = '%s'", $settings, $name);
$ret[] = array(
'success' => $return !== FALSE,
'query' => "UPDATE PROFILE - {$name}",
);
}
elseif ($settings['toolbar'] == 'DrupalFull') {
$settings['toolbar'] = "\n[\n ['Source'],\n ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],\n ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],\n ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],\n '/',\n ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],\n ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],\n ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiRtl','BidiLtr'],\n ['Link','Unlink','Anchor','Linkit','LinkToNode', 'LinkToMenu'],\n '/',\n ['Format','Font','FontSize'],\n ['TextColor','BGColor'],\n ['Maximize', 'ShowBlocks'],\n ['DrupalBreak', 'DrupalPageBreak']\n]\n ";
$settings = serialize($settings);
$return = db_query("UPDATE {ckeditor_settings} SET settings = '%s' WHERE name = '%s'", $settings, $name);
$ret[] = array(
'success' => $return !== FALSE,
'query' => "UPDATE PROFILE - {$name}",
);
}
else {
$settings['toolbar'] = "";
$settings = serialize($settings);
$return = db_query("UPDATE {ckeditor_settings} SET settings = '%s' WHERE name = '%s'", $settings, $name);
$ret[] = array(
'success' => $return !== FALSE,
'query' => "[!!] UPDATE PROFILE - {$name} - Custom toolbar cannot be converted, please set this toolbar manually in the CKEditor profile!",
);
}
}
return $ret;
}