function _flipping_book_clean_filename in Flipping Book 7
Helper function to sanitize flipping_book filename
1 call to _flipping_book_clean_filename()
- flipping_book_management_form_submit in includes/
flipping_book.pages.inc - Submit callback.
File
- includes/
flipping_book.pages.inc, line 138 - Flipping Book Pages.
Code
function _flipping_book_clean_filename($filename) {
// Replace whitespace.
$filename = str_replace(' ', '_', $filename);
// Remove remaining unsafe characters.
$filename = preg_replace('![^0-9A-Za-z_.-]!', '', $filename);
// Remove multiple consecutive non-alphabetical characters.
$filename = preg_replace('/(_)_+|(\\.)\\.+|(-)-+/', '\\1\\2\\3', $filename);
// Force lowercase to prevent issues on case-insensitive file systems.
$filename = strtolower($filename);
return $filename;
}