You are here

function _themekey_settings_submit in ThemeKey 6

Function _themekey_settings_submit().

File

./themekey_admin.inc, line 366

Code

function _themekey_settings_submit($form, &$form_state) {
  $properties = array();
  if (isset($form_state['values']['table'])) {
    foreach ($form_state['values']['table'] as $property => $details) {
      if ($details['enabled']) {
        $properties[$property] = array(
          'path' => $details['path'],
          'weight' => $details['weight'],
        );
      }
    }
    unset($form_state['values']['table']);
  }

  //
  $properties_old = variable_get('themekey_properties', array());
  $properties_removed = array_diff(array_keys($properties_old), array_keys($properties));
  _themekey_properties_delall($properties_removed);

  //
  uasort($properties, '_themekey_properties_cmp');
  variable_set('themekey_properties', $properties);

  //
  foreach ($form_state['values'] as $key => $value) {
    $pos = strpos($key, 'themekey_');
    if ($pos !== FALSE && $pos == 0) {
      variable_set($key, $value);
    }
  }
  drupal_set_message(t('The configuration options have been saved.'));
  if (count($properties) > 10) {
    drupal_set_message(t('Attention! Do not enable too many properties as this may slow down page loads.'), 'error');
  }
}