@todo Please document this function.

Voir aussi

http://drupal.org/node/1354

2 calls to advagg_get_bundle_from_filename()
advagg_bundle_built dans ./advagg.module
See if this bundle has been built.
advagg_missing_regenerate dans includes/missing.inc
regenerates a missing css file.

Fichier

./advagg.module, line 1501

Code

function advagg_get_bundle_from_filename($filename) {
    // Verify requested filename has the correct pattern.
    if (!preg_match('/^(j|cs)s_[0-9a-f]{32}_\\d+\\.(j|cs)s$/', $filename)) {
        return t('Wrong Pattern.');
    }
    // Get type
    $type = substr($filename, 0, strpos($filename, '_'));
    // Get extension
    $ext = substr($filename, strpos($filename, '.', 37) + 1);
    // Make sure extension is the same as the type.
    if ($ext != $type) {
        return t('Type does not match extension.');
    }
    // Extract info from wanted filename.
    if ($type == 'css') {
        $md5 = substr($filename, 4, 32);
        $counter = substr($filename, 37, strpos($filename, '.', 38) - 37);
    }
    elseif ($type == 'js') {
        $md5 = substr($filename, 3, 32);
        $counter = substr($filename, 36, strpos($filename, '.', 37) - 36);
    }
    else {
        return t('Wrong file type.');
    }
    return array(
        $type,
        $md5,
        $counter,
    );
}