mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #2746 from mooror/enhance-batch-action-parameters
CMSMain - Fixed and enhanced BatchActionParameters
This commit is contained in:
commit
de8d7632c2
@ -4,6 +4,7 @@ Name: cmsextensions
|
|||||||
SilverStripe\Admin\LeftAndMain:
|
SilverStripe\Admin\LeftAndMain:
|
||||||
extensions:
|
extensions:
|
||||||
- SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension
|
- SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension
|
||||||
|
- SilverStripe\CMS\Controllers\LeftAndMainBatchActionsExtension
|
||||||
---
|
---
|
||||||
Name: cmsmodals
|
Name: cmsmodals
|
||||||
---
|
---
|
||||||
|
@ -2112,28 +2112,38 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
return new CMSBatchActionHandler($this, 'batchactions');
|
return new CMSBatchActionHandler($this, 'batchactions');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a LiteralField containing parameter field HTML
|
||||||
|
* for batch actions
|
||||||
|
*
|
||||||
|
* Used by {@link LeftAndMain} to render batch actions in
|
||||||
|
* the BatchActionsForm
|
||||||
|
*
|
||||||
|
* @return LiteralField
|
||||||
|
*/
|
||||||
public function BatchActionParameters()
|
public function BatchActionParameters()
|
||||||
{
|
{
|
||||||
$batchActions = CMSBatchActionHandler::config()->batch_actions;
|
$batchActions = $this->batchactions()->registeredActions();
|
||||||
|
|
||||||
$forms = [];
|
$forms = [];
|
||||||
foreach ($batchActions as $urlSegment => $batchAction) {
|
foreach ($batchActions as $urlSegment => $batchAction) {
|
||||||
$SNG_action = singleton($batchAction);
|
$SNG_action = singleton($batchAction['class']);
|
||||||
if ($SNG_action->canView() && $fieldset = $SNG_action->getParameterFields()) {
|
if ($SNG_action->canView() && $fieldList = $SNG_action->getParameterFields()) {
|
||||||
$formHtml = '';
|
$formHtml = '';
|
||||||
/** @var FormField $field */
|
/** @var FormField $field */
|
||||||
foreach ($fieldset as $field) {
|
foreach ($fieldList as $field) {
|
||||||
$formHtml .= $field->Field();
|
$formHtml .= $field->FieldHolder();
|
||||||
}
|
}
|
||||||
$forms[$urlSegment] = $formHtml;
|
$forms[$urlSegment] = $formHtml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$pageHtml = '';
|
$pageHtml = '';
|
||||||
foreach ($forms as $urlSegment => $html) {
|
foreach ($forms as $urlSegment => $html) {
|
||||||
$pageHtml .= "<div class=\"params\" id=\"BatchActionParameters_$urlSegment\">$html</div>\n\n";
|
$pageHtml .= '<div class="params" id="BatchActionParameters_' . $urlSegment . '" style="display:none">' . $html . '</div>';
|
||||||
}
|
}
|
||||||
return new LiteralField("BatchActionParameters", '<div id="BatchActionParameters" style="display:none">'.$pageHtml.'</div>');
|
return new LiteralField('BatchActionParameters', '<div id="BatchActionParameters" class="action-parameters" style="display:none">' . $pageHtml . '</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of batch actions
|
* Returns a list of batch actions
|
||||||
*/
|
*/
|
||||||
|
16
code/Controllers/LeftAndMainBatchActionsExtension.php
Normal file
16
code/Controllers/LeftAndMainBatchActionsExtension.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Controllers\CMSMain;
|
||||||
|
use SilverStripe\Core\Extension;
|
||||||
|
|
||||||
|
class LeftAndMainBatchActionsExtension extends Extension
|
||||||
|
{
|
||||||
|
public function updateBatchActionsForm(&$form)
|
||||||
|
{
|
||||||
|
$cmsMain = singleton(CMSMain::class);
|
||||||
|
$form->Fields()->insertAfter('Action', $cmsMain->BatchActionParameters());
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user