You are here

function wysiwyg_profile_form_submit in Wysiwyg 5.2

Same name and namespace in other branches
  1. 5 wysiwyg.admin.inc \wysiwyg_profile_form_submit()
  2. 6.2 wysiwyg.admin.inc \wysiwyg_profile_form_submit()
  3. 6 wysiwyg.admin.inc \wysiwyg_profile_form_submit()
  4. 7.2 wysiwyg.admin.inc \wysiwyg_profile_form_submit()

Submit callback for Wysiwyg profile form.

See also

wysiwyg_profile_form()

File

./wysiwyg.admin.inc, line 297
Integrate Wysiwyg editors into Drupal.

Code

function wysiwyg_profile_form_submit($form_id, &$form_values) {
  $values = $form_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 any white-space from 'block_formats' setting, since editor
  // implementations rely on a comma-separated list to explode().
  $values['block_formats'] = preg_replace('@\\s+@', '', $values['block_formats']);

  // Remove input format name.
  $format = $values['format'];
  $input_format = $values['input_format'];
  $editor = $values['editor'];
  unset($values['format'], $values['input_format'], $values['editor']);

  // Remove FAPI values.
  // @see system_settings_form_submit()
  unset($values['submit'], $values['form_id'], $values['op'], $values['form_token']);

  // Insert new profile data.
  db_query("UPDATE {wysiwyg} SET settings = '%s' WHERE format = %d", serialize($values), $format);
  drupal_set_message(t('Wysiwyg profile for %format has been saved.', array(
    '%format' => $input_format,
  )));
  return 'admin/settings/wysiwyg';
}