function _cdn_cron_get_files_to_sync in CDN 5
Generates the list of files that has to be sync, based on a file name pattern, a list of ignored directories, a list of directories of which any file will be included, and an exclude pattern.
Parameters
$filters: A set of filters, as specified in README.txt.
Return value
An array of which the keys are filepaths and the values are filesizes.
2 calls to _cdn_cron_get_files_to_sync()
- cdn_admin_settings_form in ./
cdn.module - Form definition: CDN admin settings form.
- cdn_cron_run in ./
cdn_cron.inc - Executes a CDN synchronization cron run when called
File
- ./
cdn_cron.inc, line 190 - Basic functions for CDN synchronization cron.
Code
function _cdn_cron_get_files_to_sync($filters) {
$files = array();
$files_unique_settings = array();
$files_update_settings = array();
foreach ($filters as $filter) {
$newfiles = array();
foreach ($filter['paths'] as $path) {
$newfiles = _cdn_cron_scan_directory($path, $filter['pattern'], $filter['ignored_dirs']);
if (count($newfiles)) {
// Get relative filepaths.
$newfiles = array_combine(array_map('cdn_clean_filepath', array_keys($newfiles)), array_values($newfiles));
// For some unique methods, we have to store some extra parameters.
$extra_params = FALSE;
if ($filter['unique_method'] == 'md5 of mtimes') {
$extra_params = array(
'path' => $path,
'files' => array_keys($newfiles),
);
}
// Store the unique settings for each file.
$unique_settings = array_fill(0, count($newfiles), array(
'method' => $filter['unique_method'],
'where' => $filter['unique'],
'params' => $extra_params,
));
$files_unique_settings += array_combine(array_keys($newfiles), $unique_settings);
// If desired, update the URLs that are embedded in the files.
$update_settings = array_fill(0, count($newfiles), isset($filter['update_urls_in_files']) && $filter['update_urls_in_files'] === TRUE ? TRUE : FALSE);
$files_update_settings += array_combine(array_keys($newfiles), $update_settings);
$files += $newfiles;
}
}
}
return array(
$files,
$files_unique_settings,
$files_update_settings,
);
}