Permalink
Browse files

ENHANCEMENT Migrating AssetAdmin fields to File/Folder/Image->getCMSF…

…ields()
  • Loading branch information...
1 parent 0caf199 commit d9538d30853c3c1161420e468a84b0e5cd02edbc @chillu chillu committed Jan 9, 2012
Showing with 56 additions and 27 deletions.
  1. +22 −0 filesystem/File.php
  2. +9 −27 filesystem/Folder.php
  3. +25 −0 model/Image.php
View
@@ -254,6 +254,28 @@ function canDelete($member = null) {
return $this->canEdit($member);
}
+
+ function getCMSFields() {
+ $urlLink = "<div class='field readonly'>";
+ $urlLink .= "<label class='left'>"._t('AssetTableField.URL','URL')."</label>";
+ $urlLink .= "<span class='readonly'><a href='{$this->Link()}'>{$this->RelativeLink()}</a></span>";
+ $urlLink .= "</div>";
+
+ return new FieldList(
+ new TabSet('Root',
+ new Tab('Main',
+ new TextField("Title", _t('AssetTableField.TITLE','Title')),
+ new TextField("Name", _t('AssetTableField.FILENAME','Filename')),
+ new LiteralField("AbsoluteURL", $urlLink),
+ new ReadonlyField("FileType", _t('AssetTableField.TYPE','Type')),
+ new ReadonlyField("Size", _t('AssetTableField.SIZE','Size'), $this->getSize()),
+ new DropdownField("OwnerID", _t('AssetTableField.OWNER','Owner'), Member::mapInCMSGroups()),
+ new DateField_Disabled("Created", _t('AssetTableField.CREATED','First uploaded')),
+ new DateField_Disabled("LastEdited", _t('AssetTableField.LASTEDIT','Last changed'))
+ )
+ )
+ );
+ }
/**
* Returns a category based on the file extension.
View
@@ -404,6 +404,9 @@ function getCMSFields() {
$config->addComponent(new GridFieldSortableHeader());
$config->addComponent(new GridFieldPaginator(2));
$config->addComponent(new GridFieldAction_Delete());
+ $config->addComponent(new GridFieldAction_Edit());
+ $config->addComponent($gridFieldForm = new GridFieldItemEditView());
+ $gridFieldForm->setTemplate('CMSGridFieldItemEditView');
$files = DataList::create('File')->filter('ParentID', $this->ID)->exclude('ClassName', 'Folder');
$gridField = new GridField('File','Files', $files, $config);
$gridField->setDisplayFields(array(
@@ -416,30 +419,19 @@ function getCMSFields() {
$titleField = ($this->ID && $this->ID != "root") ? new TextField("Title", _t('Folder.TITLE')) : new HiddenField("Title");
$fields = new FieldList(
- new HiddenField("Name"),
- new TabSet("Root",
- new Tab("Files", _t('Folder.FILESTAB', "Files"),
+ new TabSet('Root',
+ new Tab('Main',
$titleField,
$gridField,
+ new HiddenField("ID"),
+ new HiddenField("Name"),
new HiddenField("DestFolderID")
- ),
- new Tab("Details", _t('Folder.DETAILSTAB', "Details"),
- new ReadonlyField("URL", _t('Folder.URL', 'URL')),
- new ReadonlyField("ClassName", _t('Folder.TYPE','Type')),
- new ReadonlyField("Created", _t('Folder.CREATED','First Uploaded')),
- new ReadonlyField("LastEdited", _t('Folder.LASTEDITED','Last Updated'))
- ),
- new Tab("Upload", _t('Folder.UPLOADTAB', "Upload"),
- new LiteralField("UploadIframe",
- $this->getUploadIframe()
- )
)
- ),
- new HiddenField("ID")
+ )
);
if(!$this->canEdit()) {
- $fields->removeFieldFromTab("Root", "Upload");
+ $fields->removeByName("Upload");
}
$this->extend('updateCMSFields', $fields);
@@ -448,16 +440,6 @@ function getCMSFields() {
}
/**
- * Display the upload form. Returns an iframe tag that will show admin/assets/uploadiframe.
- */
- function getUploadIframe() {
- return <<<HTML
- <iframe name="AssetAdmin_upload" src="admin/assets/uploadiframe/{$this->ID}" id="AssetAdmin_upload" border="0" style="border-style none !important; width: 97%; min-height: 300px; height: 100%; height: expression(document.body.clientHeight) !important;">
- </iframe>
-HTML;
- }
-
- /**
* Get the children of this folder that are also folders.
*/
function ChildFolders() {
View
@@ -73,6 +73,31 @@ public function defineMethods() {
parent::defineMethods();
}
+ function getCMSFields() {
+ $fields = parent::getCMSFields();
+
+ $urlLink = "<div class='field readonly'>";
+ $urlLink .= "<label class='left'>"._t('AssetTableField.URL','URL')."</label>";
+ $urlLink .= "<span class='readonly'><a href='{$this->Link()}'>{$this->RelativeLink()}</a></span>";
+ $urlLink .= "</div>";
+
+ $big = $this->URL;
+ $formattedImage = $this->getFormattedImage('AssetLibraryPreview');
+ $thumbnail = $formattedImage ? $formattedImage->URL : '';
+
+ // Hmm this required the translated string to be appended to BottomRoot to add this to the Main tab
+ $fields->addFieldToTab('Root.Main',
+ new ReadonlyField("Dimensions", _t('AssetTableField.DIM','Dimensions'))
+ );
+ $fields->addFieldToTab('Root.Main',
+ new LiteralField("ImageFull",
+ "<img id='thumbnailImage' src='{$thumbnail}?r=" . rand(1,100000) . "' alt='{$this->Name}' />"
+ )
+ );
+
+ return $fields;
+ }
+
/**
* An image exists if it has a filename.
* Does not do any filesystem checks.

0 comments on commit d9538d3

Please sign in to comment.