ENHANCEMENT Moving "save" and "delete" cms actions from CMSMain->EditForm() into SiteTree->getCMSActions() to make them decoratable (e.g. disallow delete action) and easier to cover with unit tests. Leaving fallback "save" and "delete" actions in CMSMain in case no actions are defined (necessary e.g. for Group class in SecurityAdmin)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@67061 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-12-01 04:00:24 +00:00 committed by Sam Minnee
parent 6fca21ecd0
commit 832cd7c1e9

View File

@ -405,26 +405,13 @@ JS;
if($record->hasMethod('getAllCMSActions')) {
$actions = $record->getAllCMSActions();
} else {
$actions = new FieldSet();
if($record->DeletedFromStage) {
if($record->can('CMSEdit')) {
$actions->push(new FormAction('revert',_t('CMSMain.RESTORE','Restore')));
$actions->push(new FormAction('deletefromlive',_t('CMSMain.DELETEFP','Delete from the published site')));
}
} else {
if($record->canEdit()) {
$actions->push($deleteAction = new FormAction('delete',_t('CMSMain.DELETE','Delete from the draft site')));
$deleteAction->addExtraClass('delete');
}
if($record->hasMethod('getCMSActions')) {
$extraActions = $record->getCMSActions();
if($extraActions) foreach($extraActions as $action) $actions->push($action);
}
$actions = $record->getCMSActions();
// add default actions if none are defined
if(!$actions || !$actions->Count()) {
if($record->canEdit()) {
$actions->push(new FormAction('save',_t('CMSMain.SAVE','Save')));
$actions->push($deleteAction = new FormAction('delete',_t('CMSMain.DELETE','Delete from the draft site')));
$deleteAction->addExtraClass('delete');
}
}
}