Check all CSS files, see if any contains an @import that is external.
Paramètres
array $files: An array of filenames to check.
Return value
array An array of filenames that contain an @import that is external.
1 call to advagg_relocate_admin_list_files_with_import()
- advagg_relocate_admin_settings_form dans advagg_relocate/
advagg_relocate.admin.inc - Form builder; Configure advagg settings.
Fichier
-
advagg_relocate/
advagg_relocate.admin.inc, line 475
Code
function advagg_relocate_admin_list_files_with_import(array $files = array()) {
if (empty($files)) {
// Get filename.
$results = db_select('advagg_files', 'af')->fields('af', array(
'filename',
))
->condition('filetype', 'css')
->orderBy('filename', 'ASC')
->execute();
while ($row = $results->fetchAssoc()) {
$files[] = $row['filename'];
}
}
$files_with_import_statements = array();
if (empty($files)) {
return $files_with_import_statements;
}
module_load_include('inc', 'advagg', 'advagg');
foreach ($files as $file) {
if (!file_exists($file)) {
continue;
}
// Get the file contents.
$file_contents = advagg_load_css_stylesheet($file, FALSE);
if (strpos($file_contents, '@import') !== FALSE) {
$matches = array();
preg_match_all('%@import\\s*+(?:url\\(\\s*+)?+[\'"]?+((?:http:\\/\\/|https:\\/\\/|\\/\\/)(?:[^\'"()\\s]++))[\'"]?+\\s*+\\)?+\\s*+;%i', $file_contents, $matches);
if (!empty($matches[0])) {
$output = array();
foreach ($matches[1] as $k => $v) {
$v = str_replace(array(
'=',
'&',
' ',
), array(
'_',
'-',
'-',
), $v);
$output[$v] = $matches[0][$k];
}
$files_with_import_statements[$file] = $output;
}
}
}
return $files_with_import_statements;
}