summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/legal_file.php
diff options
context:
space:
mode:
authorNathan Kinkade <nath@nkinka.de>2012-06-01 15:10:46 +0000
committerNathan Kinkade <nath@nkinka.de>2012-06-01 15:10:46 +0000
commitb52e834bd0bab530e98537d52b31d4b37f199739 (patch)
treeff31dd4f6c2afaeae380f10dc691cde3cb4e6739 /modules/gallery/helpers/legal_file.php
parentf5098f54b8279f468d94747b1156e15ea05d6d25 (diff)
parent4c98b218316df00c8bf3eeb28a8324ec64348bff (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/helpers/legal_file.php')
-rw-r--r--modules/gallery/helpers/legal_file.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php
index af6472ca..bd48d7b7 100644
--- a/modules/gallery/helpers/legal_file.php
+++ b/modules/gallery/helpers/legal_file.php
@@ -89,7 +89,23 @@ class legal_file_Core {
if (strpos($filename, ".") === false) {
return "{$filename}.{$new_ext}";
} else {
- return preg_replace("/\..*?$/", ".{$new_ext}", $filename);
+ return preg_replace("/\.[^\.]*?$/", ".{$new_ext}", $filename);
}
}
+
+ /**
+ * Reduce the given file to having a single extension.
+ */
+ static function smash_extensions($filename) {
+ $parts = pathinfo($filename);
+ $result = "";
+ if ($parts["dirname"] != ".") {
+ $result .= $parts["dirname"] . "/";
+ }
+ $parts["filename"] = str_replace(".", "_", $parts["filename"]);
+ $parts["filename"] = preg_replace("/[_]+/", "_", $parts["filename"]);
+ $parts["filename"] = trim($parts["filename"], "_");
+ $result .= "{$parts['filename']}.{$parts['extension']}";
+ return $result;
+ }
}