system_themes_form_submit

Versions
6 – 7
system_themes_form_submit($form, &$form_state)

Process system_themes_form form submissions.

Code

modules/system/system.admin.inc, line 304

<?php
function system_themes_form_submit($form, &$form_state) {
  drupal_clear_css_cache();

  // Store list of previously enabled themes and disable all themes
  $old_theme_list = $new_theme_list = array();
  foreach (list_themes() as $theme) {
    if ($theme->status) {
      $old_theme_list[] = $theme->name;
    }
  }
  db_update('system')
    ->fields(array('status' => 0))
    ->condition('type', 'theme')
    ->execute();

  if ($form_state['values']['op'] == t('Save configuration')) {
    if (is_array($form_state['values']['status'])) {
      foreach ($form_state['values']['status'] as $key => $choice) {
        // Always enable the default theme, despite its status checkbox being checked:
        if ($choice || $form_state['values']['theme_default'] == $key) {
          $new_theme_list[] = $key;
          db_update('system')
            ->fields(array('status' => 1))
            ->condition('type', 'theme')
            ->condition('name', $key)
            ->execute();
        }
      }
    }
    if ($form_state['values']['admin_theme'] && $form_state['values']['admin_theme'] != $form_state['values']['theme_default']) {
      drupal_set_message(t('Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array(
        '%admin_theme' => $form_state['values']['admin_theme'],
        '%selected_theme' => $form_state['values']['theme_default'],
      )));
    }

    // Save the variables.
    variable_set('theme_default', $form_state['values']['theme_default']);
    variable_set('admin_theme', $form_state['values']['admin_theme']);
    variable_set('node_admin_theme', $form_state['values']['node_admin_theme']);
  }
  else {
    // Revert to defaults: only Garland is enabled.
    variable_del('theme_default');
    variable_del('admin_theme');
    variable_del('node_admin_theme');
    db_update('system')
      ->fields(array('status' => 1))
      ->condition('type', 'theme')
      ->condition('name', 'garland')
      ->execute();
    $new_theme_list = array('garland');
  }

  list_themes(TRUE);
  menu_rebuild();
  drupal_theme_rebuild();
  drupal_set_message(t('The configuration options have been saved.'));
  $form_state['redirect'] = 'admin/appearance';

  // Notify locale module about new themes being enabled, so translations can
  // be imported. This might start a batch, and only return to the redirect
  // path after that.
  module_invoke('locale', 'system_update', array_diff($new_theme_list, $old_theme_list));

  return;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.