function wysiwyg_profile_form_submit in Wysiwyg 6.2
Same name and namespace in other branches
- 5.2 wysiwyg.admin.inc \wysiwyg_profile_form_submit()
- 5 wysiwyg.admin.inc \wysiwyg_profile_form_submit()
- 6 wysiwyg.admin.inc \wysiwyg_profile_form_submit()
- 7.2 wysiwyg.admin.inc \wysiwyg_profile_form_submit()
Submit callback for Wysiwyg profile form.
See also
File
- ./
wysiwyg.admin.inc, line 389 - Integrate Wysiwyg editors into Drupal.
Code
function wysiwyg_profile_form_submit($form, &$form_state) {
$values = $form_state['values'];
if (isset($values['buttons'])) {
// Store only enabled buttons for each plugin.
foreach ($values['buttons'] as $plugin => $buttons) {
$values['buttons'][$plugin] = array_filter($values['buttons'][$plugin]);
}
// Store only enabled plugins.
$values['buttons'] = array_filter($values['buttons']);
}
// Remove input format name.
$format = $values['format'];
$input_format = $values['input_format'];
$editor_name = $values['editor'];
unset($values['format'], $values['input_format'], $values['editor']);
$preferences = $values['preferences'];
unset($values['preferences']);
$editor = wysiwyg_get_editor($editor_name);
$version = $editor['installed version'];
// If the installed version is newer than what is supported, drop the stored
// number so future upgrades know where to start. Ignore older versions.
if (!$editor['installed version verified'] && !empty($editor['verified version range'])) {
$version_range = $editor['verified version range'];
if (version_compare($version, $version_range[1], '>')) {
$version = $version_range[1];
}
}
$preferences['version'] = $version;
$values['_profile_preferences'] = $preferences;
// Remove FAPI values.
// @see system_settings_form_submit()
unset($values['submit'], $values['cancel'], $values['form_id'], $values['op'], $values['form_token'], $values['form_build_id'], $values['advanced__active_tab']);
// Insert new profile data.
db_query("UPDATE {wysiwyg} SET editor = '%s', settings = '%s' WHERE format = %d", $editor_name, serialize($values), $format);
if (!db_affected_rows()) {
db_query("INSERT INTO {wysiwyg} (format, editor, settings) VALUES (%d, '%s', '%s')", $format, $editor_name, serialize($values));
}
// Clear the editing caches.
if (module_exists('ctools')) {
ctools_include('object-cache');
ctools_object_cache_clear('wysiwyg_profile', 'format' . $format);
}
else {
cache_clear_all('wysiwyg_profile:format' . $format, 'cache');
}
wysiwyg_profile_cache_clear();
$formats = filter_formats();
drupal_set_message(t('Wysiwyg profile for %format has been saved.', array(
'%format' => $formats[$format]->name,
)));
$form_state['redirect'] = 'admin/settings/wysiwyg';
}