BUG Prevent folders deleted on the filesystem from breaking asset interface

This commit is contained in:
Damian Mooyman 2016-02-09 13:03:40 +13:00
parent 0cc49cb27a
commit 2ad490c3e2

View File

@ -156,7 +156,7 @@ JS
$form = parent::getEditForm($id, $fields); $form = parent::getEditForm($id, $fields);
$folder = ($id && is_numeric($id)) ? DataObject::get_by_id('Folder', $id, false) : $this->currentPage(); $folder = ($id && is_numeric($id)) ? DataObject::get_by_id('Folder', $id, false) : $this->currentPage();
$fields = $form->Fields(); $fields = $form->Fields();
$title = ($folder && $folder->exists()) ? $folder->Title : _t('AssetAdmin.FILES', 'Files'); $title = ($folder && $folder->isInDB()) ? $folder->Title : _t('AssetAdmin.FILES', 'Files');
$fields->push(new HiddenField('ID', false, $folder ? $folder->ID : null)); $fields->push(new HiddenField('ID', false, $folder ? $folder->ID : null));
// File listing // File listing
@ -244,7 +244,7 @@ JS
); );
$tabList->addExtraClass("content-listview cms-tabset-icon list"); $tabList->addExtraClass("content-listview cms-tabset-icon list");
$tabTree->addExtraClass("content-treeview cms-tabset-icon tree"); $tabTree->addExtraClass("content-treeview cms-tabset-icon tree");
if($fields->Count() && $folder->exists()) { if($fields->Count() && $folder && $folder->isInDB()) {
$tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details'))); $tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
$tabDetails->addExtraClass("content-galleryview cms-tabset-icon edit"); $tabDetails->addExtraClass("content-galleryview cms-tabset-icon edit");
foreach($fields as $field) { foreach($fields as $field) {
@ -520,7 +520,7 @@ JS
$id = $this->currentPageID(); $id = $this->currentPageID();
if($id && is_numeric($id) && $id > 0) { if($id && is_numeric($id) && $id > 0) {
$folder = DataObject::get_by_id('Folder', $id); $folder = DataObject::get_by_id('Folder', $id);
if($folder && $folder->exists()) { if($folder && $folder->isInDB()) {
return $folder; return $folder;
} }
} }