function advagg_get_bundle_from_filename in Advanced CSS/JS Aggregation 7
Same name and namespace in other branches
- 6 advagg.module \advagg_get_bundle_from_filename()
@todo Please document this function.
See also
2 calls to advagg_get_bundle_from_filename()
- advagg_bundle_built in ./
advagg.module - See if this bundle has been built.
- advagg_missing_regenerate in includes/
missing.inc - regenerates a missing css file.
File
- ./
advagg.module, line 1501 - Advanced CSS/JS aggregation module
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,
);
}