diff --git a/README.md b/README.md index 6055bac..fd94245 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ subfolders, in order to avoid exceeding filesystem limits. The file name is a composite based on its database ID and the original file name. The exact location shouldn't be relied on by custom logic, but rather retrieved through -the API (`DMSDocument->getDownloadLink()`). +the API (`DMSDocument->getLink()`). Example: @@ -72,7 +72,7 @@ Note: Both operations copy the existing file. $dms = DMS::getDMSInstance(); $docs = $dms->getByTag('priority', 'important')->First(); - $link = $doc->getDownloadLink(); + $link = $doc->getLink(); #### Manage Page Relations diff --git a/code/DMSDocument.php b/code/DMSDocument.php index e24d935..fc89d8e 100644 --- a/code/DMSDocument.php +++ b/code/DMSDocument.php @@ -641,7 +641,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface { } function getFileSizeFormatted(){ - if($size = $this->getFileSize()){ + if($size = $this->getSize()){ if($size < 1024) return $size . ' bytes'; if($size < 1024*10) return (round($size/1024*10)/10). ' KB'; if($size < 1024*1024) return round($size/1024) . ' KB'; @@ -656,7 +656,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface { * @return FieldList */ protected function getFieldsForFile($relationListCount) { - $extension = $this->getFileExt(); + $extension = $this->getExtension(); $previewField = new LiteralField("ImageFull", "{$this->Title}\n" @@ -681,7 +681,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface { new ReadonlyField("FileType", _t('AssetTableField.TYPE','File type') . ':', self::get_file_type($extension)), new ReadonlyField("Size", _t('AssetTableField.SIZE','File size') . ':', $this->getFileSizeFormatted()), $urlField = new ReadonlyField('ClickableURL', _t('AssetTableField.URL','URL'), - sprintf('%s', $this->getDownloadLink(), $this->getDownloadLink()) + sprintf('%s', $this->getLink(), $this->getLink()) ), new ReadonlyField("FilenameWithoutIDField", "Filename". ':', $this->getFilenameWithoutID()), new DateField_Disabled("Created", _t('AssetTableField.CREATED','First uploaded') . ':', $this->Created), @@ -773,7 +773,7 @@ class DMSDocument_Controller extends Controller { } else { // make do with what we have - $ext = $doc->getFileExt(); + $ext = $doc->getExtension(); if ( $ext =='pdf') { $mime = 'application/pdf'; }elseif ($ext == 'html' || $ext =='htm') { @@ -817,9 +817,9 @@ class DMSDocument_Controller extends Controller { if( $content ) { $linkText = sprintf('%s', $document->Link(), $parser->parse($content)); } else { - $extension = $document->getFileExt(); + $extension = $document->getExtension(); $size = "data:{size:'{$document->getFileSizeFormatted()}'}"; - $linkText = $document->getDownloadLink()."\" class=\"$size documentLink $extension"; + $linkText = $document->getLink()."\" class=\"$size documentLink $extension"; } } } diff --git a/code/DMSSiteTreeExtension.php b/code/DMSSiteTreeExtension.php index 019c327..ddac20a 100644 --- a/code/DMSSiteTreeExtension.php +++ b/code/DMSSiteTreeExtension.php @@ -54,7 +54,7 @@ class DMSSiteTreeExtension extends DataExtension { singleton('DMSDocument'); $gridFieldConfig->getComponentByType('GridFieldDataColumns')->setDisplayFields(Config::inst()->get('DMSDocument', 'display_fields')) ->setFieldCasting(array('LastChanged'=>"Date->Ago")) - ->setFieldFormatting(array('FilenameWithoutID'=>'$FilenameWithoutID')); + ->setFieldFormatting(array('FilenameWithoutID'=>'$FilenameWithoutID')); //override delete functionality with this class $gridFieldConfig->getComponentByType('GridFieldDetailForm')->setItemRequestClass('DMSGridFieldDetailForm_ItemRequest'); diff --git a/code/cms/DMSDocumentAddController.php b/code/cms/DMSDocumentAddController.php index ec577dc..0cf9d12 100644 --- a/code/cms/DMSDocumentAddController.php +++ b/code/cms/DMSDocumentAddController.php @@ -186,7 +186,7 @@ class DMSDocumentAddController extends LeftAndMain { $return = array( 'id' => $document->ID, 'name' => $document->getTitle(), - 'thumbnail_url' => $document->Icon($document->getFileExt()), + 'thumbnail_url' => $document->Icon($document->getExtension()), 'edit_url' => $this->getEditForm()->Fields()->fieldByName('Main.From your computer.AssetUploadField')->getItemHandler($document->ID)->EditLink(), 'size' => $document->getFileSizeFormatted(), 'buttons' => $buttonText, diff --git a/code/cms/DMSUploadField.php b/code/cms/DMSUploadField.php index f8dd507..0f6fdaa 100644 --- a/code/cms/DMSUploadField.php +++ b/code/cms/DMSUploadField.php @@ -139,7 +139,7 @@ class DMSUploadField extends UploadField { $return = array_merge($return, array( 'id' => $document->ID, 'name' => $document->getTitle(), - 'thumbnail_url' => $document->Icon($document->getFileExt()), + 'thumbnail_url' => $document->Icon($document->getExtension()), 'edit_url' => $this->getItemHandler($document->ID)->EditLink(), 'size' => $document->getFileSizeFormatted(), 'buttons' => $document->renderWith($this->getTemplateFileButtons()), diff --git a/templates/Includes/Document.ss b/templates/Includes/Document.ss index 9fd8325..a533ea1 100644 --- a/templates/Includes/Document.ss +++ b/templates/Includes/Document.ss @@ -1,13 +1,13 @@ -
+
<% if Title %> -

$Title

+

$Title

<% else %> -

$FilenameWithoutID

+

$FilenameWithoutID

<% end_if %>

$FilenameWithoutID - | $FileExt + | $Extension | $FileSizeFormatted | Last Changed: $LastChanged.Nice

diff --git a/tests/DMSTest.php b/tests/DMSTest.php index 27dfc58..73f582b 100644 --- a/tests/DMSTest.php +++ b/tests/DMSTest.php @@ -125,7 +125,7 @@ class DMSTest extends FunctionalTest { // // //store the first document // $document = $dms->storeDocument(self::$testFile); -// $link = $document->getDownloadLink(); +// $link = $document->getLink(); // // Debug::Show($link); // $d=new DMSDocument_Controller();