function wysiwyg_profile_form_submit in Wysiwyg 7.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.2 wysiwyg.admin.inc \wysiwyg_profile_form_submit()
- 6 wysiwyg.admin.inc \wysiwyg_profile_form_submit()
Submit callback for Wysiwyg profile form.
See also
File
- ./
wysiwyg.admin.inc, line 385 - 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']);
}
$editor = $form_state['wysiwyg']['editor'];
$preferences = $values['preferences'];
$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;
// Remove FAPI values.
// @see system_settings_form_submit()
unset($values['preferences'], $values['submit'], $values['cancel'], $values['form_id'], $values['op'], $values['form_token'], $values['form_build_id'], $values['advanced__active_tab']);
$values['_profile_preferences'] = $preferences;
$format = $form_state['wysiwyg_profile']->format;
// Insert new profile data.
db_merge('wysiwyg')
->key(array(
'format' => $format,
))
->fields(array(
'editor' => $form_state['wysiwyg_profile']->editor,
'settings' => serialize($values),
))
->execute();
// Clear the editing caches.
if (module_exists('ctools')) {
ctools_include('object-cache');
ctools_object_cache_clear('wysiwyg_profile', $form_state['wysiwyg_profile']->name);
}
else {
cache_clear_all('wysiwyg_profile:' . $form_state['wysiwyg_profile']->name, '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/config/content/wysiwyg';
}