Get all js files and js files that are not compressed.

Paramètres

array $redo_list: JS files that need to be compressed.

int $max_time: Max amount of time to spend on compressing.

bool $drush: Set to TRUE to output drush info when running.

Return value

array Array($list, $redo_list).

3 calls to advagg_js_compress_redo_files()
advagg_js_compress_batch_process dans advagg_js_compress/advagg_js_compress.module
The batch processor.
advagg_js_compress_cron dans advagg_js_compress/advagg_js_compress.module
Implements hook_cron().
drush_advagg_js_compress dans advagg_js_compress/advagg_js_compress.drush.inc
Callback function for drush advagg-js-compress.

Fichier

advagg_js_compress/advagg_js_compress.module, line 594

Code

function advagg_js_compress_redo_files(array $redo_list, $max_time = 30, $drush = FALSE) {
    // Get the compressor list and start the clock.
    module_load_include('inc', 'advagg_js_compress', 'advagg_js_compress.advagg');
    $compressor_list = advagg_js_compress_get_enabled_compressors(array(), -1);
    shuffle($redo_list);
    $time_start = microtime(TRUE);
    if ($drush && (!is_callable('drush_log') || !is_callable('dt'))) {
        $drush = FALSE;
    }
    // Change settings for testing.
    if (isset($GLOBALS['conf']['advagg_js_compress_force_run'])) {
        $advagg_js_compress_force_run = $GLOBALS['conf']['advagg_js_compress_force_run'];
    }
    if (isset($GLOBALS['conf']['advagg_js_compress_add_license'])) {
        $advagg_js_compress_add_license = $GLOBALS['conf']['advagg_js_compress_add_license'];
    }
    if (isset($GLOBALS['conf']['httprl_background_callback'])) {
        $httprl_background_callback = $GLOBALS['conf']['httprl_background_callback'];
    }
    $GLOBALS['conf']['advagg_js_compress_force_run'] = TRUE;
    $GLOBALS['conf']['advagg_js_compress_add_license'] = 0;
    $GLOBALS['conf']['httprl_background_callback'] = FALSE;
    $counter = array();
    foreach ($redo_list as $key => $values) {
        // Test the files for up to 30 seconds.
        $filenames_info = array();
        $filenames_info[$values['data']] = $values;
        $compressors = $compressor_list;
        if (isset($values['compressors'])) {
            $compressors = $values['compressors'];
        }
        if ($drush) {
            drush_log(dt('Compressing @data.', array(
                '@data' => $values['data'],
            )), 'ok');
        }
        // Remove jsqueeze if compression failed.
        if (!empty($values['advagg_js_compress'])) {
            $neg_one_counter = 0;
            foreach ($values['advagg_js_compress'] as $compressor_data) {
                if ($compressor_data['code'] == -1) {
                    $neg_one_counter++;
                }
            }
            if (count($values['advagg_js_compress']) === $neg_one_counter) {
                $compressor_key = array_search('jsqueeze', $compressors);
                if ($compressor_key !== FALSE) {
                    unset($compressors[$compressor_key]);
                }
            }
        }
        // Prime cache.
        advagg_js_compress_run_mutiple_tests($filenames_info, $compressors);
        // Add to cache.
        advagg_get_info_on_file($values['data'], TRUE, TRUE);
        $counter[$key] = $values;
        // Stop after 30 seconds of processing.
        $time_end = microtime(TRUE);
        $time = $time_end - $time_start;
        if (!empty($max_time) && $time > $max_time) {
            break;
        }
    }
    // Put them back to normal.
    if (isset($advagg_js_compress_force_run)) {
        $GLOBALS['conf']['advagg_js_compress_force_run'] = $advagg_js_compress_force_run;
    }
    if (isset($advagg_js_compress_add_license)) {
        $GLOBALS['conf']['advagg_js_compress_add_license'] = $advagg_js_compress_add_license;
    }
    if (isset($httprl_background_callback)) {
        $GLOBALS['conf']['httprl_background_callback'] = $httprl_background_callback;
    }
    return $counter;
}