function boost_get_all_filenames in Boost 6
Returns all possible filenames given the input and current settings
Parameters
$filename: Name of file
$base_dir: Value from base_dir column in database
Return value
returns a 2 dimensional array 1st dimension key is either gzip or normal 2nd dimension contains all the filenames
3 calls to boost_get_all_filenames()
- boost_cache_kill in ./
boost.module - Deletes cached page from file system.
- boost_cache_write in ./
boost.module - Writes data to filename in an atomic operation thats compatible with older versions of php (php < 5.2.4 file_put_contents() doesn't lock correctly).
- _boost_change_extension in ./
boost.module - Change a file extension in the database.
File
- ./
boost.module, line 3702 - Provides static file caching for Drupal text output. Pages, Feeds, ect...
Code
function boost_get_all_filenames($filename, $base_dir = NULL) {
$namesA = array();
$namesB = array();
$filenames = array();
$base_dir = is_null($base_dir) ? BOOST_FILE_PATH : $base_dir;
if (stristr($filename, '[')) {
$paths = explode('/', $filename);
$end = array_pop($paths);
$end = preg_replace("([[0-9]])", ']', $end);
$paths[] = $end;
$namesA[] = implode('/', $paths);
}
$namesA[] = $filename;
foreach ($namesA as $filename) {
$namesB[] = $filename;
// Generate urlencoded filename, if name contains decoded characters
$paths = explode('/', $filename);
$end = array_pop($paths);
$end = str_replace('[', '%5B', $end);
$end = str_replace(']', '%5D', $end);
$end = str_replace(',', '%2C', $end);
$end = str_replace(' ', '%20', $end);
$paths[] = $end;
$namesB[] = implode('/', $paths);
}
$namesB = array_unique($namesB);
// Generate gzip filenames
foreach ($namesB as $name) {
if (BOOST_SET_FILE_ENCODING != '') {
$name = iconv("UTF-8", BOOST_SET_FILE_ENCODING, $name);
}
$filenames['normal'][] = $name;
if (BOOST_GZIP) {
// Replace the correct dir with the gzip version for the given base dir.
$gzip_base_path = implode('/', array_filter(explode('/', str_replace(BOOST_ROOT_CACHE_DIR . '/' . BOOST_NORMAL_DIR, BOOST_ROOT_CACHE_DIR . '/' . BOOST_GZIP_DIR . '/', $base_dir))));
$filenames['gzip'][] = str_replace($base_dir, $gzip_base_path, $name) . BOOST_GZIP_EXTENSION;
}
}
return $filenames;
}