MINOR Moved ul.tree rules from cms/css/cms_left.css to sapphire/javascript/tree/tree.css (particularly around multiselect tickbox styling) (see r98854) (merged from r98855) (from r98865)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@99686 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-02-23 03:32:18 +00:00 committed by Sam Minnee
parent 9624757e14
commit 033d27ac3f
3 changed files with 112 additions and 83 deletions

View File

@ -477,18 +477,8 @@ JS;
$this->extend('updateEditForm', $form); $this->extend('updateEditForm', $form);
return $form; return $form;
} if ($id == 0) { } if ($id == 0 || $id == 'root') {
$siteConfig = SiteConfig::current_site_config(); $form = $this->RootForm();
$fields = $siteConfig->getFormFields();
if(Object::has_extension('SiteConfig',"Translatable")){
$fields->push(new HiddenField('Locale','', $siteConfig->Locale ));
}
$form = new Form($this, "EditForm", $fields, $siteConfig->getFormActions());
$form->loadDataFrom($siteConfig);
$this->extend('updateEditForm', $form);
return $form;
} else if($id) { } else if($id) {
return new Form($this, "EditForm", new FieldSet( return new Form($this, "EditForm", new FieldSet(
new LabelField('PageDoesntExistLabel',_t('CMSMain.PAGENOTEXISTS',"This page doesn't exist"))), new FieldSet()); new LabelField('PageDoesntExistLabel',_t('CMSMain.PAGENOTEXISTS',"This page doesn't exist"))), new FieldSet());
@ -496,7 +486,22 @@ JS;
} }
} }
/**
* @return Form
*/
function RootForm() {
$siteConfig = SiteConfig::current_site_config();
$fields = $siteConfig->getFormFields();
if(Object::has_extension('SiteConfig',"Translatable")){
$fields->push(new HiddenField('Locale','', $siteConfig->Locale ));
}
$form = new Form($this, "EditForm", $fields, $siteConfig->getFormActions());
$form->loadDataFrom($siteConfig);
$this->extend('updateEditForm', $form);
return $form;
}
//------------------------------------------------------------------------------------------// //------------------------------------------------------------------------------------------//
// Data saving handlers // Data saving handlers

View File

@ -29,6 +29,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
'memberimport', 'memberimport',
'GroupImportForm', 'GroupImportForm',
'groupimport', 'groupimport',
'RootForm'
); );
/** /**
@ -58,81 +59,104 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
Requirements::javascript(THIRDPARTY_DIR . "/greybox/greybox.js"); Requirements::javascript(THIRDPARTY_DIR . "/greybox/greybox.js");
} }
public function getEditForm($id) { function getEditForm($id = null) {
$record = null; if(!$id) $id = $this->currentPageID();
// Root form if($id && $id != 'root') {
if (($id == 'root' || $id == 0)) { $record = DataObject::get_by_id($this->stat('tree_class'), $id);
$fields = new FieldSet( if(!$record) return false;
new TabSet( }
'Root',
new Tab('Import', _t('SecurityAdmin.TABIMPORT', 'Import'), if($id && is_numeric($id)) {
new LiteralField( $fields = $record->getCMSFields();
'GroupImportFormIframe',
sprintf( if($fields->hasTabSet()) {
'<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="400px" border="0"></iframe>', $fields->findOrMakeTab('Root.Import',_t('Group.IMPORTTABTITLE', 'Import'));
$this->Link('groupimport') $fields->addFieldToTab('Root.Import',
new LiteralField(
'MemberImportFormIframe',
sprintf(
'<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="400px" border="0"></iframe>',
$this->Link('memberimport')
)
)
);
}
$actions = new FieldSet(
new FormAction('addmember',_t('SecurityAdmin.ADDMEMBER','Add Member')),
new FormAction('save',_t('SecurityAdmin.SAVE','Save'))
);
$form = new Form($this, "EditForm", $fields, $actions);
$form->loadDataFrom($record);
if(!$record->canEdit()) {
$readonlyFields = $form->Fields()->makeReadonly();
$form->setFields($readonlyFields);
}
// Filter permissions
$permissionField = $form->Fields()->dataFieldByName('Permissions');
if($permissionField) $permissionField->setHiddenPermissions(self::$hidden_permissions);
$this->extend('updateEditForm', $form);
} else {
$form = $this->RootForm();
}
return $form;
}
/**
* @return FieldSet
*/
function RootForm() {
$memberList = new MemberTableField(
$this,
"Members"
);
// unset 'inlineadd' permission, we don't want inline addition
$memberList->setPermissions(array('show', 'edit', 'delete', 'add'));
$memberList->setRelationAutoSetting(false);
$fields = new FieldSet(
new TabSet(
'Root',
new Tab('Members', singleton('Member')->i18n_plural_name(),
$memberList,
new LiteralField('MembersCautionText',
sprintf('<p class="caution-remove"><strong>%s</strong></p>',
_t(
'SecurityAdmin.MemberListCaution',
'Caution: Removing members from this list will remove them from all groups and the database'
) )
) )
) )
), ),
// necessary for tree node selection in LeftAndMain.EditForm.js new Tab('Import', _t('SecurityAdmin.TABIMPORT', 'Import'),
new HiddenField('ID', false, 0) new LiteralField(
); 'GroupImportFormIframe',
sprintf(
$actions = new FieldSet(); '<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="400px" border="0"></iframe>',
$this->Link('groupimport')
$form = new Form( )
$this,
'EditForm',
$fields,
$actions
);
$this->extend('updateEditForm', $form);
return $form;
}
if($id && $id != 'root') {
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
}
if(!$record) return false;
$fields = $record->getCMSFields();
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')
) )
) )
); ),
} // necessary for tree node selection in LeftAndMain.EditForm.js
new HiddenField('ID', false, 0)
);
$actions = new FieldSet( $actions = new FieldSet(
new FormAction('addmember',_t('SecurityAdmin.ADDMEMBER','Add Member')), new FormAction('addmember',_t('SecurityAdmin.ADDMEMBER','Add Member'))
new FormAction('save',_t('SecurityAdmin.SAVE','Save'))
); );
$form = new Form($this, "EditForm", $fields, $actions); $form = new Form(
$form->loadDataFrom($record); $this,
'EditForm',
if(!$record->canEdit()) { $fields,
$readonlyFields = $form->Fields()->makeReadonly(); $actions
$form->setFields($readonlyFields); );
}
// Filter permissions
$permissionField = $form->Fields()->dataFieldByName('Permissions');
if($permissionField) $permissionField->setHiddenPermissions(self::$hidden_permissions);
$this->extend('updateEditForm', $form);
return $form; return $form;
} }

View File

@ -10,11 +10,11 @@ class SecurityAdminTest extends FunctionalTest {
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin')); $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
/* First, open the applicable group */ /* First, open the applicable group */
$this->get('admin/security/getitem?ID=' . $this->idFromFixture('Group','admin')); $this->get('admin/security/show/' . $this->idFromFixture('Group','admin'));
$this->assertRegExp('/<input[^>]+id="Form_EditForm_Title"[^>]+value="Administrators"[^>]*>/',$this->content()); $this->assertRegExp('/<input[^>]+id="Form_EditForm_Title"[^>]+value="Administrators"[^>]*>/',$this->content());
/* Then load the export page */ /* Then load the export page */
$this->get('admin/security//EditForm/field/Members/export'); $this->get('admin/security/EditForm/field/Members/export');
$lines = preg_split('/\n/', $this->content()); $lines = preg_split('/\n/', $this->content());
$this->assertEquals(count($lines), 3, "Export with members has one content row"); $this->assertEquals(count($lines), 3, "Export with members has one content row");
@ -25,11 +25,11 @@ class SecurityAdminTest extends FunctionalTest {
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin')); $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
/* First, open the applicable group */ /* First, open the applicable group */
$this->get('admin/security/getitem?ID=' . $this->idFromFixture('Group','empty')); $this->get('admin/security/show/' . $this->idFromFixture('Group','empty'));
$this->assertRegExp('/<input[^>]+id="Form_EditForm_Title"[^>]+value="Empty Group"[^>]*>/',$this->content()); $this->assertRegExp('/<input[^>]+id="Form_EditForm_Title"[^>]+value="Empty Group"[^>]*>/',$this->content());
/* Then load the export page */ /* Then load the export page */
$this->get('admin/security//EditForm/field/Members/export'); $this->get('admin/security/EditForm/field/Members/export');
$lines = preg_split('/\n/', $this->content()); $lines = preg_split('/\n/', $this->content());
$this->assertEquals(count($lines), 2, "Empty export only has header fields and an empty row"); $this->assertEquals(count($lines), 2, "Empty export only has header fields and an empty row");