mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE Moved AssetAdmin-specific fields from Folder->getCMSFields() to AssetAdmin->getEditForm(). For modifying those fields via DataExtension, please use AssetAdmin->updateEditForm() instead
This commit is contained in:
parent
9df1487d8f
commit
27cdc40c7a
@ -407,92 +407,12 @@ class Folder extends File {
|
|||||||
* and implemeting updateCMSFields(FieldList $fields) on that extension.
|
* and implemeting updateCMSFields(FieldList $fields) on that extension.
|
||||||
*/
|
*/
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
$config = GridFieldConfig::create();
|
// Hide field on root level, which can't be renamed
|
||||||
$config->addComponent(new GridFieldSortableHeader());
|
$titleField = (!$this->ID || $this->ID === "root") ? new HiddenField("Name") : new TextField("Name", _t('Folder.NAME'));
|
||||||
$config->addComponent(new GridFieldFilter());
|
|
||||||
$config->addComponent(new GridFieldDefaultColumns());
|
|
||||||
$config->addComponent(new GridFieldPaginator(10));
|
|
||||||
$config->addComponent(new GridFieldAction_Delete());
|
|
||||||
$config->addComponent(new GridFieldAction_Edit());
|
|
||||||
$config->addComponent($gridFieldForm = new GridFieldPopupForms(Controller::curr(), 'EditForm'));
|
|
||||||
$gridFieldForm->setTemplate('CMSGridFieldPopupForms');
|
|
||||||
|
|
||||||
if($this->ID) {
|
|
||||||
// When a specific folder is selected, show only children files,
|
|
||||||
// and include children folders to allow navigating into them.
|
|
||||||
$files = DataList::create('File')
|
|
||||||
->filter('ParentID', $this->ID)
|
|
||||||
->sort('(CASE WHEN "ClassName" = \'Folder\' THEN 0 ELSE 1 END)');
|
|
||||||
} else {
|
|
||||||
// On the root folder, show all files but exclude folders - newest first.
|
|
||||||
$files = DataList::create('File')
|
|
||||||
->exclude('ClassName', 'Folder')
|
|
||||||
->sort('Created', 'Desc');
|
|
||||||
}
|
|
||||||
|
|
||||||
$gridField = new GridField('File','Files', $files, $config);
|
|
||||||
$gridField->setDisplayFields(array(
|
|
||||||
'StripThumbnail' => '',
|
|
||||||
// 'Parent.FileName' => 'Folder',
|
|
||||||
'Title'=>'Title',
|
|
||||||
'Date'=>'Created',
|
|
||||||
'Size'=>'Size',
|
|
||||||
));
|
|
||||||
$gridField->setFieldFormatting(array(
|
|
||||||
'Date' => 'Nice'
|
|
||||||
));
|
|
||||||
$gridField->setAttribute(
|
|
||||||
'data-url-folder-template',
|
|
||||||
Controller::join_links(singleton('AssetAdmin')->Link('show'), '%s')
|
|
||||||
);
|
|
||||||
|
|
||||||
$titleField = ($this->ID && $this->ID != "root") ? new TextField("Title", _t('Folder.TITLE')) : new HiddenField("Title");
|
|
||||||
|
|
||||||
if($this->canCreate()) {
|
|
||||||
$uploadBtn = new LiteralField(
|
|
||||||
'UploadButton',
|
|
||||||
sprintf(
|
|
||||||
'<a class="ss-ui-button ss-ui-action-constructive icon-accept cms-panel-link" data-target-panel=".cms-content" href="%s">%s</a>',
|
|
||||||
Controller::join_links(singleton('CMSFileAddController')->Link(), '?ID=' . $this->ID),
|
|
||||||
_t('Folder.UploadFilesButton', 'Upload')
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$uploadBtn = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$this->hasMethod('canAddChildren') || ($this->hasMethod('canAddChildren') && $this->canAddChildren())) {
|
|
||||||
$addFolderBtn = new LiteralField(
|
|
||||||
'AddFolderButton',
|
|
||||||
sprintf(
|
|
||||||
'<a class="ss-ui-button ss-ui-action-constructive icon-accept cms-page-add-button" href="%s">%s</a>',
|
|
||||||
singleton('CMSFileAddController')->Link(),
|
|
||||||
_t('Folder.AddFolderButton', 'Add folder')
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$addFolderBtn = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
// The tabs of Root are used to generate the top tabs
|
$titleField,
|
||||||
new TabSet('Root',
|
new HiddenField('ParentID')
|
||||||
new Tab('listview', _t('AssetAdmin.ListView', 'List View'),
|
|
||||||
$titleField,
|
|
||||||
$actionsComposite = new CompositeField(
|
|
||||||
$uploadBtn,
|
|
||||||
$addFolderBtn
|
|
||||||
),
|
|
||||||
$gridField,
|
|
||||||
new HiddenField("ID"),
|
|
||||||
new HiddenField("DestFolderID")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$actionsComposite->addExtraClass('cms-actions-row');
|
|
||||||
|
|
||||||
$this->extend('updateCMSFields', $fields);
|
$this->extend('updateCMSFields', $fields);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
Loading…
Reference in New Issue
Block a user