BUGFIX: fixing all the API changes made by Ingo in an earlier commit by searching for usage and updating places where the APIs are used

This commit is contained in:
Julian Seidenberg 2012-08-27 15:07:01 +12:00
parent d023300626
commit 1f0c08db5d
7 changed files with 16 additions and 16 deletions

View File

@ -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

View File

@ -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",
"<img id='thumbnailImage' class='thumbnail-preview' src='{$this->Icon($extension)}?r=" . rand(1,100000) . "' alt='{$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('<a href="%s" target="_blank" class="file-url">%s</a>', $this->getDownloadLink(), $this->getDownloadLink())
sprintf('<a href="%s" target="_blank" class="file-url">%s</a>', $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('<a href="%s">%s</a>', $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";
}
}
}

View File

@ -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'=>'<a target=\'_blank\' class=\'file-url\' href=\'$DownloadLink\'>$FilenameWithoutID</a>'));
->setFieldFormatting(array('FilenameWithoutID'=>'<a target=\'_blank\' class=\'file-url\' href=\'$Link\'>$FilenameWithoutID</a>'));
//override delete functionality with this class
$gridFieldConfig->getComponentByType('GridFieldDetailForm')->setItemRequestClass('DMSGridFieldDetailForm_ItemRequest');

View File

@ -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,

View File

@ -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()),

View File

@ -1,13 +1,13 @@
<div class="document $FileExt">
<div class="document $Extension">
<% if Title %>
<h4><a href="$DownloadLink" title="Download $Title">$Title</a></h4>
<h4><a href="$Link" title="Download $Title">$Title</a></h4>
<% else %>
<h4><a href="$DownloadLink" title="Download $FilenameWithoutID">$FilenameWithoutID</a></h4>
<h4><a href="$Link" title="Download $FilenameWithoutID">$FilenameWithoutID</a></h4>
<% end_if %>
<p class='details'>
<strong>$FilenameWithoutID</strong>
| $FileExt
| $Extension
| $FileSizeFormatted
| Last Changed: $LastChanged.Nice
</p>

View File

@ -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();