You are here

function themekey_rule_chain_form_submit in ThemeKey 7.2

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

Form submission handler for themekey_rule_chain_form().

See also

themekey_rule_chain_form()

File

./themekey_admin.inc, line 427

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(check_plain(t('The configuration options have been saved. Trying to clear page cache ...')));

  // fast deletion of page cache (truncate)
  cache_clear_all('*', 'cache_page', TRUE);
}