From 00f95679ceadc46809e40ad7d9f3c47fafdd9598 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 9 Apr 2008 11:08:58 +0000 Subject: [PATCH] Merged revisions 47621 via svnmerge from svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq ........ r47621 | ischommer | 2008-01-04 21:44:07 +1300 (Fri, 04 Jan 2008) | 1 line added get_file_extension() ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@52398 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- filesystem/File.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/filesystem/File.php b/filesystem/File.php index efbf3aa00..b9606ebd0 100755 --- a/filesystem/File.php +++ b/filesystem/File.php @@ -401,7 +401,18 @@ class File extends DataObject { * legacy code. */ function getExtension() { - return strtolower(substr($this->getField('Filename'),strrpos($this->getField('Filename'),'.')+1)); + return self::get_file_extension($this->getField('Filename')); + } + + /** + * Gets the extension of a filepath or filename, + * by stripping away everything before the last "dot". + * + * @param string $filename + * @return string + */ + public static function get_file_extension($filename) { + return strtolower(substr($filename,strrpos($filename,'.')+1)); } function getFileType() {