You are here

function image_hotspots_style_config_submit in Image Hotspots 7.2

Hotspots-style configuration submit.

File

includes/image_hotspots.admin.inc, line 112
Admin configuration for module.

Code

function image_hotspots_style_config_submit($form, &$form_state) {
  if ($form_state['clicked_button']['#value'] == 'Default') {
    $style_settings = image_hotspots_default();
  }
  else {
    $style_settings = array();
    $old = isset($form_state['input']['old_style']) ? $form_state['input']['old_style'] : array();
    $new = isset($form_state['input']['hotspot_style']) ? $form_state['input']['hotspot_style'] : array();
    $form_state['input']['hotspot_style'] = array_merge($old, $new);
    foreach ($form_state['input']['hotspot_style'] as $row => $value) {
      if ($value['remove'] != TRUE) {
        $row_settings = array();
        if (!empty($value['color'])) {
          $row_settings['background-color'] = str_replace('#', '', $value['color']);
        }
        if (!empty($value['border']['color']) && intval($value['border']['width']) > 0) {
          $value['border']['width'] = intval($value['border']['width']);
          $value['border']['color'] = str_replace('#', '', $value['border']['color']);
          $row_settings['border'] = $value['border'];
        }
        if (count($row_settings) != 0) {
          $row_settings['opacity'] = floatval($value['opacity']);
          $style_settings[] = $row_settings;
        }
      }
    }
  }
  variable_set('image_hotspots_settings', $style_settings);
}