diff --git a/code/CMSBatchAction.php b/code/CMSBatchAction.php index 4c8ca127..9c0540fe 100644 --- a/code/CMSBatchAction.php +++ b/code/CMSBatchAction.php @@ -38,10 +38,11 @@ abstract class CMSBatchAction extends Object { * @param $helperMethod The method to call on each of those objects. * @para */ - public function batchaction(DataObjectSet $pages, $helperMethod, $successMessage) { + public function batchaction(DataObjectSet $pages, $helperMethod, $successMessage, $arguments = array()) { foreach($pages as $page) { + // Perform the action - $page->$helperMethod(); + call_user_func_array(array($page, $helperMethod), $arguments); // Now make sure the tree title is appropriately updated $publishedRecord = DataObject::get_by_id('SiteTree', $page->ID); @@ -59,6 +60,10 @@ abstract class CMSBatchAction extends Object { return FormResponse::respond(); } + // if your batchaction has parameters, return a fieldset here + function getParameterFields() { + return false; + } } /** diff --git a/code/CMSMain.php b/code/CMSMain.php index 190f8c35..66b6f959 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -1022,18 +1022,18 @@ JS; $batchActions = CMSBatchActionHandler::$batch_actions; $forms = array(); - foreach($batchActions as $batchAction) { + foreach($batchActions as $urlSegment => $batchAction) { if ($fieldset = singleton($batchAction)->getParameterFields()) { $formHtml = ''; foreach($fieldset as $field) { $formHtml .= $field->Field(); } - $forms[$batchAction] = $formHtml; + $forms[$urlSegment] = $formHtml; } } $pageHtml = ''; - foreach($forms as $class => $html) { - $pageHtml .= "
\n\n"; + foreach($forms as $urlSegment => $html) { + $pageHtml .= "<% _t('SELECTPAGESACTIONS','Select the pages that you want to change & then click an action:') %>
- +