Alter the CSS or JS array removing empty files from the aggregates.

Paramètres

array $array: CSS or JS array.

2 calls to advagg_remove_empty_files()
advagg_get_css dans ./advagg.module
Returns a themed representation of all stylesheets to attach to the page.
advagg_get_full_js dans ./advagg.module
Get full JS array.

Fichier

./advagg.module, line 6012

Code

function advagg_remove_empty_files(array &$array) {
    if (!variable_get('advagg_js_remove_empty_files', ADVAGG_JS_REMOVE_EMPTY_FILES)) {
        return;
    }
    if (variable_get('advagg_fast_filesystem', ADVAGG_FAST_FILESYSTEM)) {
        foreach ($array as $key => $value) {
            if ($value['type'] !== 'file') {
                continue;
            }
            // Check locally.
            if (!is_readable($value['data']) || filesize($value['data']) == 0) {
                unset($array[$key]);
            }
        }
    }
    else {
        module_load_include('inc', 'advagg', 'advagg');
        $files = array();
        foreach ($array as $key => $value) {
            if ($value['type'] !== 'file') {
                continue;
            }
            $files[$key] = $value['data'];
        }
        // Check cache/db.
        $info = advagg_get_info_on_files($files);
        foreach ($info as $key => $values) {
            if (empty($values['filesize'])) {
                $key = array_search($values['data'], $files);
                if (isset($array[$key])) {
                    unset($array[$key]);
                }
            }
        }
    }
}