Added extension handling for file path

This commit is contained in:
Rudi Grinberg 2012-09-18 12:04:54 -04:00
parent 8657a80459
commit bc873a3ece
1 changed files with 16 additions and 1 deletions

View File

@ -399,6 +399,17 @@ SQL;
$this->_file->save(); $this->_file->save();
} }
public function getRealFileExtension() {
$path = $this->_file->getDbFilepath();
$path_elements = explode('.', $path);
if (count($path_elements) < 2) {
return "";
} else {
return $path_elements[count($path_elements) - 1];
}
}
/** /**
* Return suitable extension. * Return suitable extension.
* *
@ -407,9 +418,13 @@ SQL;
*/ */
public function getFileExtension() public function getFileExtension()
{ {
//return "";
// TODO : what's the point of having this function? Can we not just use // TODO : what's the point of having this function? Can we not just use
// the extension from the file_path column from cc_files? // the extension from the file_path column from cc_files?
$possible_ext = $this->getRealFileExtension();
if ($possible_ext !== "") {
return $possible_ext;
}
$mime = $this->_file->getDbMime(); $mime = $this->_file->getDbMime();
if ($mime == "audio/ogg" || $mime == "application/ogg") { if ($mime == "audio/ogg" || $mime == "application/ogg") {