From e71eabc2950f6b3fd6b9527572f56e1a4e0f6e08 Mon Sep 17 00:00:00 2001
From: Mike Shiyan <dev@mike.pp.ua>
Date: Tue, 28 Jul 2015 00:22:53 +0300
Subject: [PATCH] Issue #2540936 by pingwin4eg: Remove style settings from
 custom style form

---
 styleswitcher.admin.inc | 39 +++++++--------------------------------
 1 file changed, 7 insertions(+), 32 deletions(-)

diff --git a/styleswitcher.admin.inc b/styleswitcher.admin.inc
index 7090201..b635145 100644
--- a/styleswitcher.admin.inc
+++ b/styleswitcher.admin.inc
@@ -166,27 +166,6 @@ function styleswitcher_style_form($form, &$form_state, $style = NULL) {
     '#access' => !$style || isset($style['path']),
   );
 
-  $form['status'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Enabled'),
-    '#description' => t('Styles that are not enabled will not be listed in the switcher block.'),
-    '#default_value' => $style ? $style['status'] : TRUE,
-  );
-  // Forbid to disable default style.
-  if ($style && $style['name'] == styleswitcher_default_style_key()) {
-    $form['status']['#default_value'] = TRUE;
-    $form['status']['#disabled'] = TRUE;
-    $form['status']['#description'] .= ' ' . t('Default style must be enabled.');
-  }
-
-  $form['weight'] = array(
-    '#type' => 'weight',
-    '#title' => t('Weight'),
-    '#description' => t('In the switcher block, the heavier styles will sink and the lighter styles will be positioned nearer the top.'),
-    '#delta' => _styleswitcher_weight_delta() + 1,
-    '#default_value' => $style ? $style['weight'] : _styleswitcher_weight_max() + 1,
-  );
-
   $form['actions'] = array('#type' => 'actions');
   $form['actions']['submit'] = array(
     '#type' => 'submit',
@@ -250,24 +229,20 @@ function styleswitcher_style_form_submit($form, &$form_state) {
     'name' => 'custom/' . $form_state['values']['name'],
     'path' => $form_state['values']['path'],
   );
-  $style_settings = array(
-    'status' => $form_state['values']['status'],
-    'weight' => $form_state['values']['weight'],
-  );
 
   if ($old_name !== '') {
-    unset($styles[$old_name], $settings[$old_name]);
+    unset($styles[$old_name]);
 
-    if ($old_name == styleswitcher_default_style_key()) {
-      $style_settings['is_default'] = TRUE;
-      $style_settings['status'] = TRUE;
+    if ($style['name'] != $old_name && isset($settings[$old_name])) {
+      // Update key in settings var.
+      $settings[$style['name']] = $settings[$old_name];
+      unset($settings[$old_name]);
+      variable_set('styleswitcher_styles_settings', $settings);
     }
   }
-  $styles[$style['name']] = $style;
-  $settings[$style['name']] = $style_settings;
 
+  $styles[$style['name']] = $style;
   variable_set('styleswitcher_custom_styles', $styles);
-  variable_set('styleswitcher_styles_settings', $settings);
 
   drupal_set_message(t('The style %title has been saved.', array('%title' => $style['label'])));
 
-- 
1.9.5.msysgit.0

