function override_css_selector_value_submit in Override css 7
Submit selector group form
File
- ./
override_css.admin.inc, line 437
Code
function override_css_selector_value_submit($form, &$form_state) {
$values = array();
$selector = override_css_selector_load($form_state['values']['selector']);
$path = $form['redirect'] ? variable_get('override_css_settings_path', OVERRIDE_CSS_SETTINGS_PATH) : 'admin/appearance/override_css/' . $selector['name'];
$form_state['redirect'] = $path;
$available_properties = override_css_properties_list();
$properties = array_filter($selector['properties']);
foreach ($properties as $property) {
switch ($available_properties[$property]['type']) {
case 'border':
$values[$property] = isset($form_state['values'][$property]) ? $form_state['values'][$property] : '';
$values[$property . '_size'] = isset($form_state['values'][$property . '_size']) ? $form_state['values'][$property . '_size'] : 0;
$values[$property . '_type'] = isset($form_state['values'][$property . '_type']) ? $form_state['values'][$property . '_type'] : '';
break;
case 'shadow':
$extra_fields = array(
'_horizontal',
'_vertical',
'_blur',
'_spread',
);
foreach ($extra_fields as $extra_field) {
$values[$property . $extra_field] = isset($form_state['values'][$property . $extra_field]) ? $form_state['values'][$property . $extra_field] : 0;
}
$values[$property . '_direction'] = isset($form_state['values'][$property . '_direction']) ? $form_state['values'][$property . '_direction'] : '';
case 'background-color':
$values[$property . '_opacity'] = isset($form_state['values'][$property . '_opacity']) ? $form_state['values'][$property . '_opacity'] : 0;
case 'color':
$values[$property] = isset($form_state['values'][$property]) ? $form_state['values'][$property] : '';
break;
case 'size':
case 'transparent':
case 'radius':
case 'font':
$values[$property] = isset($form_state['values'][$property]) ? $form_state['values'][$property] : '';
break;
case 'image':
module_load_include('inc', 'system', 'system.admin');
// Save eerst ingegeven pad
if (!empty($form_state['values'][$property])) {
$values[$property] = _system_theme_settings_validate_path($form_state['values'][$property]);
}
// Overschrijf pad indien afbeelding is geüpload
if ($file = $form_state['values'][$property . '_upload']) {
unset($form_state['values'][$property . '_upload']);
$destination = 'public://' . OVERRIDE_CSS_FILE_PATH;
file_prepare_directory($destination, FILE_CREATE_DIRECTORY);
$filename = file_unmanaged_copy($file->uri, $destination . '/' . $file->filename);
$values[$property] = $filename;
}
// Extra properties for backgrounds
$values[$property . '_position_horizontal'] = $form_state['values'][$property . '_position_horizontal'];
$values[$property . '_position_vertical'] = $form_state['values'][$property . '_position_vertical'];
$values[$property . '_attachment'] = $form_state['values'][$property . '_attachment'];
$values[$property . '_repeat'] = $form_state['values'][$property . '_repeat'];
$values[$property . '_stretch'] = $form_state['values'][$property . '_stretch'];
break;
default:
$values[$property] = isset($form_state['values'][$property]) ? $form_state['values'][$property] : '';
break;
}
// Saving disabled setting
$values[$property . '_disabled'] = $form_state['values'][$property . '_disabled'];
}
db_merge('override_css_properties')
->fields(array(
'name' => $selector['name'],
'properties_values' => serialize($values),
))
->condition('name', $selector['name'], '=')
->execute();
override_css_store_css();
drupal_set_message(t('Your values for this css selector group has been saved.'));
}