mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
ENHANCEMENT Allowing custom 'root forms' when id values '0' or 'root' are passed from the tree selection. (rewritten from r98710)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@98735 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
6103522ad2
commit
c38a898de3
@ -509,7 +509,7 @@ class LeftAndMain extends Controller {
|
|||||||
// Wrap the root if needs be.
|
// Wrap the root if needs be.
|
||||||
|
|
||||||
if(!$rootID) {
|
if(!$rootID) {
|
||||||
$rootLink = $this->Link() . '0';
|
$rootLink = $this->Link('show') . '/root';
|
||||||
|
|
||||||
// This lets us override the tree title with an extension
|
// This lets us override the tree title with an extension
|
||||||
if($this->hasMethod('getCMSTreeTitle') && $customTreeTitle = $this->getCMSTreeTitle()) {
|
if($this->hasMethod('getCMSTreeTitle') && $customTreeTitle = $this->getCMSTreeTitle()) {
|
||||||
@ -939,10 +939,42 @@ JS;
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FormResponse::add($script);
|
FormResponse::add($script);
|
||||||
|
|
||||||
return FormResponse::respond();
|
return FormResponse::respond();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a placeholder form, used by {@link getEditForm()} if no record is selected.
|
||||||
|
* Our javascript logic always requires a form to be present in the CMS interface.
|
||||||
|
*
|
||||||
|
* @return Form
|
||||||
|
*/
|
||||||
|
function EmptyForm() {
|
||||||
|
$form = new Form(
|
||||||
|
$this,
|
||||||
|
"EditForm",
|
||||||
|
new FieldSet(
|
||||||
|
new HeaderField(
|
||||||
|
'WelcomeHeader',
|
||||||
|
$this->getApplicationName()
|
||||||
|
),
|
||||||
|
new LiteralField(
|
||||||
|
'WelcomeText',
|
||||||
|
sprintf('<p id="WelcomeMessage">%s %s. %s</p>',
|
||||||
|
_t('LeftAndMain_right.ss.WELCOMETO','Welcome to'),
|
||||||
|
$this->getApplicationName(),
|
||||||
|
_t('CHOOSEPAGE','Please choose an item from the left.')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
new FieldSet()
|
||||||
|
);
|
||||||
|
$form->unsetValidator();
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
public function EditForm() {
|
public function EditForm() {
|
||||||
// Include JavaScript to ensure HtmlEditorField works.
|
// Include JavaScript to ensure HtmlEditorField works.
|
||||||
|
@ -59,7 +59,12 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
public function getEditForm($id) {
|
public function getEditForm($id) {
|
||||||
$record = null;
|
$record = null;
|
||||||
|
|
||||||
if (($id == 'root' || $id == 0) && $this->hasMethod('getRootForm')) return $this->getRootForm($this, 'EditForm');
|
if (($id == 'root' || $id == 0)) {
|
||||||
|
$form = $this->RootForm();
|
||||||
|
$this->extend('augmentRootForm', $form);
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
if($id && $id != 'root') {
|
if($id && $id != 'root') {
|
||||||
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
|
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
|
||||||
@ -77,20 +82,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
$form = new Form($this, "EditForm", $fields, $actions);
|
$form = new Form($this, "EditForm", $fields, $actions);
|
||||||
$form->loadDataFrom($record);
|
$form->loadDataFrom($record);
|
||||||
|
|
||||||
$fields = $form->Fields();
|
|
||||||
|
|
||||||
if($fields->hasTabSet()) {
|
|
||||||
$fields->findOrMakeTab('Root.Import',_t('Group.IMPORTTABTITLE', 'Import'));
|
|
||||||
$fields->addFieldToTab('Root.Import',
|
|
||||||
new LiteralField(
|
|
||||||
'MemberImportFormIframe',
|
|
||||||
sprintf(
|
|
||||||
'<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="400px" border="0"></iframe>',
|
|
||||||
$this->Link('memberimport')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$record->canEdit()) {
|
if(!$record->canEdit()) {
|
||||||
$readonlyFields = $form->Fields()->makeReadonly();
|
$readonlyFields = $form->Fields()->makeReadonly();
|
||||||
|
Loading…
Reference in New Issue
Block a user