function variable_realm_variable_theme_form_submit in Variable 7.2
Same name and namespace in other branches
- 7 variable_realm/variable_realm.form.inc \variable_realm_variable_theme_form_submit()
Process system_theme_settings form submissions.
See also
system_theme_settings_submit()
1 string reference to 'variable_realm_variable_theme_form_submit'
- variable_realm_form_system_theme_settings_alter in variable_realm/
variable_realm.module - Implements hook_form_FORM_ID_alter()
File
- variable_realm/
variable_realm.form.inc, line 295 - Administrative forms for variable realms.
Code
function variable_realm_variable_theme_form_submit($form, &$form_state) {
// Regular theme submission without variable set.
$values = $form_state['values'];
// If the user uploaded a new logo or favicon, save it to a permanent location
// and use it in place of the default theme-provided file.
if ($file = $values['logo_upload']) {
unset($values['logo_upload']);
$filename = file_unmanaged_copy($file->uri);
$values['default_logo'] = 0;
$values['logo_path'] = $filename;
$values['toggle_logo'] = 1;
}
if ($file = $values['favicon_upload']) {
unset($values['favicon_upload']);
$filename = file_unmanaged_copy($file->uri);
$values['default_favicon'] = 0;
$values['favicon_path'] = $filename;
$values['toggle_favicon'] = 1;
}
// If the user entered a path relative to the system files directory for
// a logo or favicon, store a public:// URI so the theme system can handle it.
if (!empty($values['logo_path'])) {
$values['logo_path'] = _system_theme_settings_validate_path($values['logo_path']);
}
if (!empty($values['favicon_path'])) {
$values['favicon_path'] = _system_theme_settings_validate_path($values['favicon_path']);
}
if (empty($values['default_favicon']) && !empty($values['favicon_path'])) {
$values['favicon_mimetype'] = file_get_mimetype($values['favicon_path']);
}
$key = $values['var'];
// Exclude unnecessary elements before saving.
unset($values['var'], $values['submit'], $values['reset'], $values['form_id'], $values['op'], $values['form_build_id'], $values['form_token']);
// Set realm variable.
$variable_name = $key;
$realm_name = $form['#realm_theme'];
$realm_key = $form['#realm_keys'][$realm_name];
variable_realm_set($realm_name, $realm_key, $variable_name, $values);
// If current is default realm key, set global variable too.
$realm_controller = variable_realm_controller($realm_name);
if ($realm_key == $realm_controller
->getDefaultKey()) {
variable_set($variable_name, $values);
}
// Confirmation, clear cache, taken from system_theme_settings_submit()
drupal_set_message(t('The configuration options have been saved.'));
cache_clear_all();
// Redirect later depending on query string parameters.
_variable_realm_form_submit_redirect($form, $form_state);
}