You are here

function themekey_rule_chain_form_submit in ThemeKey 6.2

Same name and namespace in other branches
  1. 6.4 themekey_admin.inc \themekey_rule_chain_form_submit()
  2. 6.3 themekey_admin.inc \themekey_rule_chain_form_submit()
  3. 7.3 themekey_admin.inc \themekey_rule_chain_form_submit()
  4. 7 themekey_admin.inc \themekey_rule_chain_form_submit()
  5. 7.2 themekey_admin.inc \themekey_rule_chain_form_submit()

Form submission handler for themekey_rule_chain_form().

See also

hemekey_rule_chain_form()

File

./themekey_admin.inc, line 377

Code

function themekey_rule_chain_form_submit($form, &$form_state) {
  $max_weight = 0;
  if (!empty($form_state['values']['old_items'])) {
    foreach ($form_state['values']['old_items'] as $id => $item) {
      if ($item['weight'] > $max_weight) {
        $max_weight = $item['weight'];
      }
      $item['id'] = $id;
      if ('drupal:path:wildcard' == $item['property']) {
        $item['property'] = $item['wildcard'];
      }
      unset($item['wildcard']);
      themekey_rule_set($item);
    }
  }
  if (!empty($form_state['values']['new_item']['value']) || '0' === $form_state['values']['new_item']['value']) {
    $item = $form_state['values']['new_item'];
    $item['parent'] = 0;
    $item['weight'] = $max_weight + 1;
    if ('drupal:path:wildcard' == $item['property']) {
      $item['property'] = $item['wildcard'];
    }
    unset($item['wildcard']);
    themekey_rule_set($item);
  }
  drupal_set_message(t('The configuration options have been saved.'));
}