You are here

function css_injector_edit_save in CSS Injector 7

Same name and namespace in other branches
  1. 6 css_injector.admin.inc \css_injector_edit_save()
  2. 7.2 css_injector.admin.inc \css_injector_edit_save()

Submit button callback for the CSS rule edit form.

1 call to css_injector_edit_save()
css_injector_edit_save_and_continue in ./css_injector.admin.inc
Save and continue callback for the CSS rule edit form.
1 string reference to 'css_injector_edit_save'
css_injector_edit in ./css_injector.admin.inc
Form builder function for the CSS rule edit form.

File

./css_injector.admin.inc, line 287
css_injector.admin.inc Administrative interface for CSS Injector.

Code

function css_injector_edit_save($form, &$form_state) {

  //$themes = implode('//', $form_state['values']['themes']);
  $rule = $form_state['values'];
  $crid = !empty($form_state['values']['crid']) ? $form_state['values']['crid'] : NULL;

  // Serialize themes list before inserting to databse.
  $rule['rule_themes'] = serialize($rule['rule_themes']);
  drupal_write_record('css_injector_rule', $rule, empty($crid) ? array() : 'crid');

  // Unserialize themes list for form state.
  $rule['rule_themes'] = unserialize($rule['rule_themes']);
  $form_state['values']['rule'] = $rule;
  file_unmanaged_save_data($rule['css_text'], _css_injector_rule_uri($rule['crid']), FILE_EXISTS_REPLACE);
  _css_injector_load_rule(NULL, TRUE);
  drupal_set_message(t('Your CSS injection rule %title was saved.', array(
    '%title' => $rule['title'],
  )));
  $form_state['redirect'] = 'admin/config/development/css-injector';
}