function magic_export_settings_submit in Magic 7
Same name and namespace in other branches
- 7.2 includes/magic.export.inc \magic_export_settings_submit()
Submit hook for magic_export_settings().
File
- ./
magic.module, line 119 - Keep Frontend DRY; sprinkle it with MAGIC!
Code
function magic_export_settings_submit($form, &$form_state) {
$info = $form_state['values']['info'];
$theme = $form['theme']['#value'];
$destination = drupal_get_path('theme', $theme);
$file = file_unmanaged_save_data($info, $destination . '/' . $theme . '.info', FILE_EXISTS_REPLACE);
// Only mark that the settings have updated if the file saved.
if ($file) {
drupal_set_message(t('@theme has been updated.', array(
'@theme' => $theme . '.info',
)));
// Since we exported the file, we want to delete the settings variable.
// This will get remade whenever we want to edit the settings in the future,
// but can always be re-removed.
variable_del('theme_' . $theme . '_settings');
// Rebuild the system .info file information.
system_rebuild_theme_data();
drupal_goto('admin/appearance/settings/' . $theme);
}
else {
drupal_set_message(t('@theme has not been saved, an error has occured.', array(
'@theme' => $theme . '.info',
)), 'error');
}
return $file;
}