Same name in other branches
  1. 7.x-1.x includes/admin.inc \advagg_admin_settings_form_submit()

Clear out the advagg cache bin when the save configuration button is pressed.

Sujets associés

1 string reference to 'advagg_admin_settings_form_submit'
advagg_admin_settings_form dans ./advagg.admin.inc
Form builder; Configure advagg settings.

Fichier

./advagg.admin.inc, line 1297

Code

function advagg_admin_settings_form_submit($form, &$form_state) {
    // Remove non variables.
    if (isset($form_state['values']['advagg_resource_hints_preload_reset'])) {
        unset($form_state['values']['advagg_resource_hints_preload_reset']);
    }
    // Reset this form to defaults or recommended values; also show what changed.
    advagg_set_admin_form_defaults_recommended($form_state, 'advagg_admin_mode');
    // Sort and fix values before saving to the db.
    foreach ($form_state['values']['advagg_resource_hints_preload_settings'] as &$entry) {
        if (isset($entry['weight'])) {
            $entry['#weight'] = $entry['weight'];
            unset($entry['weight']);
        }
        ksort($entry);
    }
    uasort($form_state['values']['advagg_resource_hints_preload_settings'], 'element_sort');
    // Make sure .htaccess file exists in the advagg dir.
    if (isset($form_state['values']['advagg_resource_hints_use_immutable']) && variable_get('advagg_resource_hints_use_immutable', ADVAGG_RESOURCE_HINTS_USE_IMMUTABLE) != $form_state['values']['advagg_resource_hints_use_immutable'] && variable_get('advagg_htaccess_check_generate', ADVAGG_HTACCESS_CHECK_GENERATE)) {
        // Set variable.
        variable_set('advagg_resource_hints_use_immutable', $form_state['values']['advagg_resource_hints_use_immutable']);
        unset($form_state['values']['advagg_resource_hints_use_immutable']);
        // Get paths to .htaccess file.
        list($css_path, $js_path) = advagg_get_root_files_dir();
        $files['css'] = $css_path[0] . '/.htaccess';
        $files['js'] = $js_path[0] . '/.htaccess';
        // Make the advagg_htaccess_check_generate() function available.
        module_load_include('inc', 'advagg', 'advagg.missing');
        // Generate new .htaccess files in advagg dirs.
        foreach ($files as $type => $uri) {
            advagg_htaccess_check_generate(array(
                $uri => $type,
            ), $type, TRUE);
        }
    }
    // Alter htaccess if needed.
    if (isset($form_state['values']['advagg_htaccess_rewritebase']) && variable_get('advagg_htaccess_rewritebase', ADVAGG_HTACCESS_REWRITEBASE) != $form_state['values']['advagg_htaccess_rewritebase'] && variable_get('advagg_htaccess_check_generate', ADVAGG_HTACCESS_CHECK_GENERATE)) {
        // Set variable.
        variable_set('advagg_htaccess_rewritebase', trim($form_state['values']['advagg_htaccess_rewritebase']));
        unset($form_state['values']['advagg_htaccess_rewritebase']);
        // Get paths to .htaccess file.
        list($css_path, $js_path) = advagg_get_root_files_dir();
        $files['css'] = $css_path[0] . '/.htaccess';
        $files['js'] = $js_path[0] . '/.htaccess';
        // Make the advagg_htaccess_check_generate() function available.
        module_load_include('inc', 'advagg', 'advagg.missing');
        // Generate new .htaccess files in advagg dirs.
        foreach ($files as $type => $uri) {
            advagg_htaccess_check_generate(array(
                $uri => $type,
            ), $type, TRUE);
        }
    }
    if (variable_get('advagg_htaccess_symlinksifownermatch', ADVAGG_HTACCESS_SYMLINKSIFOWNERMATCH) != $form_state['values']['advagg_htaccess_symlinksifownermatch'] && variable_get('advagg_htaccess_check_generate', ADVAGG_HTACCESS_CHECK_GENERATE)) {
        list($css_path, $js_path) = advagg_get_root_files_dir();
        $files['css'] = $css_path[0] . '/.htaccess';
        $files['js'] = $js_path[0] . '/.htaccess';
        // Make the advagg_htaccess_check_generate() function available.
        module_load_include('inc', 'advagg', 'advagg.missing');
        // Push out new setting.
        variable_set('advagg_htaccess_symlinksifownermatch', $form_state['values']['advagg_htaccess_symlinksifownermatch']);
        unset($form_state['values']['advagg_htaccess_symlinksifownermatch']);
        foreach ($files as $type => $uri) {
            advagg_htaccess_check_generate(array(
                $uri => $type,
            ), $type, TRUE);
        }
    }
    // Clear caches.
    advagg_cache_clear_admin_submit();
}