You are here

function advagg_mod_admin_settings_form_validate in Advanced CSS/JS Aggregation 7.2

Validate callback, check that the unified multisite directory was created.

Related topics

1 string reference to 'advagg_mod_admin_settings_form_validate'
advagg_mod_admin_settings_form in advagg_mod/advagg_mod.admin.inc
Form builder; Configure advagg settings.

File

advagg_mod/advagg_mod.admin.inc, line 646
Admin page callbacks for the advagg bundler module.

Code

function advagg_mod_admin_settings_form_validate($form, &$form_state) {

  // Unified Mmultisite.
  $multisite_dir = rtrim($form_state['values']['advagg_mod_unified_multisite_dir'], '/');
  if (!empty($multisite_dir)) {

    // Prepare directory.
    $css_dir = $multisite_dir . '/advagg_css';
    $js_dir = $multisite_dir . '/advagg_js';
    if (!file_prepare_directory($css_dir, FILE_CREATE_DIRECTORY) || !file_prepare_directory($js_dir, FILE_CREATE_DIRECTORY)) {
      if (!is_dir($multisite_dir) || !is_writable($multisite_dir)) {
        form_set_error('advagg_mod_unified_multisite_dir', t('%dir is not a directory or can not be written to. The shared directory needs to have the same permissions as the "Public file system path" found on the <a href="@file_system_link">File System configuration page</a>.', array(
          '%dir' => $multisite_dir,
          '@file_system_link' => url('admin/config/media/file-system'),
        )));
        return;
      }
    }
  }

  // Use JS to load CSS.
  if ($form_state['values']['advagg_mod_css_defer']) {
    if ($form_state['values']['advagg_mod_css_defer_visibility'] == ADVAGG_MOD_VISIBILITY_LISTED && empty($form_state['values']['advagg_mod_css_defer_pages'])) {
      form_set_error('advagg_mod_css_defer_pages', t('The Deferred CSS Execution setting will run only on specific pages. On other pages it will act as being Disabled. Please input what pages you wish to have the CSS be deferred. Currently none are selected.'));
    }
    if ($form_state['values']['advagg_mod_css_defer_visibility'] == ADVAGG_MOD_VISIBILITY_NOTLISTED && $form_state['values']['advagg_mod_css_defer_pages'] === '*') {
      form_set_error('advagg_mod_css_defer_pages', t('The Deferred CSS Execution setting will run only on specific pages. On other pages it will act as being Disabled. Please input what pages you wish to have the CSS not be deferred. Currently all pages are disabled (*).'));
    }
  }
}