APICHANGE: add DMSDocument->getFileExt(), remove DMSDocument_Controller::get_file_extension(), use the instance function where ever applicable.

This commit is contained in:
Normann Lou 2012-08-01 14:13:07 +12:00
parent 40631b12b1
commit 5e448c8d7b
2 changed files with 15 additions and 6 deletions

View File

@ -478,13 +478,20 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
return FRAMEWORK_DIR . "/images/app_icons/{$ext}_32.gif";
}
/**
* Return the extension of the file associated with the document
*/
function getFileExt() {
return pathinfo($this->Filename, PATHINFO_EXTENSION);
}
/**
* @return FieldList
*/
protected function getFieldsForFile() {
$extension = DMSDocument_Controller::get_file_extension($this->Filename);
$extension = $this->getFileExt();
$previewField = new LiteralField("ImageFull",
"<img id='thumbnailImage' class='thumbnail-preview' src='{$this->Icon($extension)}?r=" . rand(1,100000) . "' alt='{$this->Title}' />\n"
@ -539,10 +546,6 @@ class DMSDocument_Controller extends Controller {
'index'
);
static function get_file_extension($filename) {
return pathinfo($filename, PATHINFO_EXTENSION);
}
/**
* Access the file download without redirecting user, so we can block direct access to documents.
*/
@ -585,7 +588,7 @@ class DMSDocument_Controller extends Controller {
}
else {
// make do with what we have
$ext = self::get_file_extension($path);
$ext = $doc->getFileExt();
if ( $ext =='pdf') {
$mime = 'application/pdf';
}elseif ($ext == 'html' || $ext =='htm') {

View File

@ -131,6 +131,12 @@ interface DMSDocumentInterface {
* @return String
*/
function getDownloadLink();
/**
* Return the extension of the file associated with the document
*/
function getFileExt();
/**
* Takes a File object or a String (path to a file) and copies it into the DMS, replacing the original document file