diff --git a/filesystem/File.php b/filesystem/File.php
index 608abac50..4de518f68 100644
--- a/filesystem/File.php
+++ b/filesystem/File.php
@@ -447,50 +447,46 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer, Thumb
/**
* Returns the fields to power the edit screen of files in the CMS.
* You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension}
- * and implemeting updateCMSFields(FieldList $fields) on that extension.
+ * and implementing updateCMSFields(FieldList $fields) on that extension.
*
* @return FieldList
*/
public function getCMSFields() {
- // Preview
- $filePreview = CompositeField::create(
- CompositeField::create(new LiteralField("ImageFull", $this->PreviewThumbnail()))
- ->setName("FilePreviewImage")
- ->addExtraClass('cms-file-info-preview'),
- CompositeField::create(
- CompositeField::create(
- new ReadonlyField("FileType", _t('AssetTableField.TYPE','File type') . ':'),
- new ReadonlyField("Size", _t('AssetTableField.SIZE','File size') . ':', $this->getSize()),
- HTMLReadonlyField::create(
- 'ClickableURL',
- _t('AssetTableField.URL','URL'),
- sprintf('%s', $this->Link(), $this->Link())
- ),
- new DateField_Disabled("Created", _t('AssetTableField.CREATED','First uploaded') . ':'),
- new DateField_Disabled("LastEdited", _t('AssetTableField.LASTEDIT','Last changed') . ':')
- )
- )
- ->setName("FilePreviewData")
- ->addExtraClass('cms-file-info-data')
- )
- ->setName("FilePreview")
- ->addExtraClass('cms-file-info');
+ $path = '/' . dirname($this->getFilename());
- //get a tree listing with only folder, no files
- $fields = new FieldList(
- new TabSet('Root',
- new Tab('Main',
- $filePreview,
- new TextField("Title", _t('AssetTableField.TITLE','Title')),
- new TextField("Name", _t('AssetTableField.FILENAME','Filename')),
- DropdownField::create("OwnerID", _t('AssetTableField.OWNER','Owner'), Member::mapInCMSGroups())
- ->setHasEmptyDefault(true),
- new TreeDropdownField("ParentID", _t('AssetTableField.FOLDER','Folder'), 'Folder')
- )
+ $fields = FieldList::create([
+ HeaderField::create('TitleHeader', $this->Title, 1),
+ LiteralField::create("ImageFull", $this->PreviewThumbnail()),
+ TextField::create("Name", $this->fieldLabel('Filename')),
+ ReadonlyField::create(
+ "Path",
+ _t('AssetTableField.PATH', 'Path'),
+ (($path !== '/.') ? $path : '') . '/'
)
- );
+ ]);
+
+ if ($this->getIsImage()) {
+ $fields->push(ReadonlyField::create(
+ "DisplaySize",
+ _t('AssetTableField.SIZE', "File size"),
+ sprintf('%spx, %s', $this->getDimensions(), $this->getSize())
+ ));
+ $fields->push(HTMLReadonlyField::create(
+ 'ClickableURL',
+ _t('AssetTableField.URL','URL'),
+ sprintf('%s', $this->Link(), $this->Link())
+ ));
+ }
+ $fields->push(HiddenField::create('ID', $this->ID));
+
+ $fields->insertBefore(TextField::create("Title", $this->fieldLabel('Title')), 'Name');
+ $fields->push(DatetimeField::create(
+ "LastEdited",
+ _t('AssetTableField.LASTEDIT', 'Last changed')
+ )->setReadonly(true));
$this->extend('updateCMSFields', $fields);
+
return $fields;
}
diff --git a/filesystem/Folder.php b/filesystem/Folder.php
index 90d91e92a..1d5b2a692 100644
--- a/filesystem/Folder.php
+++ b/filesystem/Folder.php
@@ -181,17 +181,16 @@ class Folder extends File {
* @return FieldList
*/
public function getCMSFields() {
- // Hide field on root level, which can't be renamed
- if(!$this->ID || $this->ID === "root") {
- $titleField = new HiddenField("Name");
- } else {
- $titleField = new TextField("Name", $this->fieldLabel('Name'));
- }
+ // Don't show readonly path until we can implement parent folder selection,
+ // it's too confusing when readonly (makes sense for files only).
+
+ $fields = FieldList::create([
+ HeaderField::create('TitleHeader', $this->Title, 1),
+ LiteralField::create("ImageFull", $this->PreviewThumbnail()),
+ TextField::create("Name", $this->fieldLabel('Filename')),
+ HiddenField::create('ID', $this->ID)
+ ]);
- $fields = new FieldList(
- $titleField,
- new HiddenField('ParentID')
- );
$this->extend('updateCMSFields', $fields);
return $fields;