From 832cd7c1e904e9d51ffbe28cd32728053d356944 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 1 Dec 2008 04:00:24 +0000 Subject: [PATCH] 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 --- code/CMSMain.php | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/code/CMSMain.php b/code/CMSMain.php index 7871ea2b..8dcc4ef3 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -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'); } } }