function _backup_migrate_construct_filename in Backup and Migrate 7.3
Same name and namespace in other branches
- 8.2 includes/files.inc \_backup_migrate_construct_filename()
- 8.3 includes/files.inc \_backup_migrate_construct_filename()
- 6.3 includes/files.inc \_backup_migrate_construct_filename()
- 6.2 includes/files.inc \_backup_migrate_construct_filename()
- 7.2 includes/files.inc \_backup_migrate_construct_filename()
Construct a filename using token and some cleaning.
1 call to _backup_migrate_construct_filename()
- backup_migrate_perform_backup in ./
backup_migrate.module - Perform a backup with the given settings.
File
- includes/
files.inc, line 143 - General file handling code for Backup and Migrate.
Code
function _backup_migrate_construct_filename($settings) {
// Get the raw filename from the settings.
$filename = $settings->filename;
// Replace any tokens.
if (module_exists('token') && function_exists('token_replace')) {
$filename = token_replace($filename);
}
// Remove illegal characters.
$filename = _backup_migrate_clean_filename($filename);
// Generate a timestamp if needed.
$timestamp = '';
if ($settings->append_timestamp == 1 && $settings->timestamp_format) {
$timestamp = format_date(time(), 'custom', $settings->timestamp_format);
}
// Trim to length if needed to allow the timestamp to fit into the max filename.
$filename = _backup_migrate_filename_append_prepare($filename, $timestamp);
$filename .= '-' . $timestamp;
$filename = trim($filename, '-');
// If there is no filename, then just call it untitled.
if (drupal_strlen($filename) == 0) {
$filename = 'untitled';
}
return $filename;
}