You are here

function boost_form_alter in Boost 6

Same name and namespace in other branches
  1. 5 boost.module \boost_form_alter()
  2. 7 boost.module \boost_form_alter()

Implementation of hook_form_alter(). Performs alterations before a form is rendered.

File

./boost.module, line 885
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function boost_form_alter(&$form, $form_state, $form_id) {
  if (boost_is_cacheable($GLOBALS['_boost_path'])) {
    $form['#immutable'] = TRUE;
    drupal_add_js(drupal_get_path('module', 'boost') . '/boost.js');
  }
  switch ($form_id) {

    // Alter Drupal's system performance settings form by hiding the default
    // cache enabled/disabled control (which will now always default to
    // CACHE_DISABLED), and inject our own settings in its stead.
    case 'system_performance_settings':
      module_load_include('inc', 'boost', 'boost.admin');
      $form['page_cache'] = boost_admin_performance_page($form['page_cache']);
      $form['#submit'][] = 'boost_admin_performance_page_submit';
      $form['clear_cache']['clear']['#submit'][0] = 'boost_admin_clear_cache_submit';
      break;

    // Alter Drupal's site maintenance settings form in order to ensure that
    // the static page cache gets wiped if the administrator decides to take
    // the site offline.
    case 'system_site_maintenance_settings':
      module_load_include('inc', 'boost', 'boost.admin');
      $form['#submit'][] = 'boost_admin_site_offline_submit';
      break;

    // Alter Drupal's modules build form in order to ensure that
    // the static page cache gets wiped if the administrator decides to
    // change enabled modules
    case 'system_modules':
      module_load_include('inc', 'boost', 'boost.admin');
      $form['#submit'][] = 'boost_admin_modules_submit';
      break;

    // Alter Drupal's theme build form in order to ensure that
    // the static page cache gets wiped if the administrator decides to
    // change theme
    case 'system_themes_form':
      module_load_include('inc', 'boost', 'boost.admin');
      $form['#submit'][] = 'boost_admin_themes_submit';

      // Added below due to this bug: http://drupal.org/node/276615
      if (variable_get('preprocess_css', FALSE) == TRUE && version_compare(VERSION, 6.13, '<=') && boost_cache_clear_all()) {
        drupal_set_message(t('Boost: Static page cache cleared. See <a href="http://drupal.org/node/276615">http://drupal.org/node/276615</a> for reason why (core bug that is fixed in 6.14+).'), 'warning');
      }
      break;
  }
}