/** * Get the fieldset to display in the administration section */ function getCMSFields() { $group = null; if ($this->GroupID) { $group = DataObject::get_one("Group", "ID = {$this->GroupID}"); } $fields = new FieldSet(new TextField("Title", _t('NewsletterType.NEWSLETTERTYPE', 'Newsletter Type')), new TextField("FromEmail", _t('NewsletterType.SENDFROM', 'Send newsletters from')), new TabSet("Root", new Tab(_t('NewsletterType.DRAFTS', 'Drafts'), $draftList = new NewsletterList("Draft", $this, _t('NewsletterType.DRAFT', 'Draft'))), new TabSet('Sent', new Tab(_t('NewsletterType.SENT', 'Sent'), $sendList = new NewsletterList("Send", $this, _t('NewsletterType.SEND', 'Send'))), new Tab(_t('NewsletterType.UNSUBSCRIBED', 'Unsubscribed'), $unsubscribedList = new UnsubscribedList("Unsubscribed", $this)), new Tab(_t('NewsletterType.BOUNCED', 'Bounced'), $bouncedList = new BouncedList("Bounced", $this))))); if ($this->GroupID) { $fields->addFieldToTab('Root', new TabSet("Recipients", new Tab(_t('NewsletterType.RECIPIENTS', 'Recipients'), $recipients = new MemberTableField($this, "Recipients", $group)), new Tab(_t('NewsletterType.IMPORT', 'Import'), $importField = new RecipientImportField("ImportFile", _t('NewsletterType.IMPORTFROM', 'Import from file'), $group)))); $recipients->setController($this); $importField->setController($this); $importField->setTypeID($this->ID); } $fields->addFieldToTab('Root', new Tab(_t('NewsletterType.TEMPLATE', 'Template'), $templates = new TemplateList("Template", "Template", $this->Template, NewsletterAdmin::template_path()))); $draftList->setController($this); $sendList->setController($this); $templates->setController($this); $unsubscribedList->setController($this); $bouncedList->setController($this); $fields->push($idField = new HiddenField("ID")); $fields->push(new HiddenField("executeForm", "", "TypeEditForm")); $idField->setValue($this->ID); return $fields; }
public function getMailingListEditForm($id) { if (!is_numeric($id)) { $id = Session::get('currentPage'); } if (is_a($id, 'NewsletterType')) { $mailType = $id; $id = $mailType->ID; } else { if ($id && is_numeric($id)) { $mailType = DataObject::get_by_id('NewsletterType', $id); } } $group = null; if (isset($mailType) && is_object($mailType) && $mailType->GroupID) { $group = DataObject::get_one("Group", "ID = {$mailType->GroupID}"); } if (isset($mailType) && is_object($mailType)) { $fields = new FieldSet(new TabSet("Root", new Tab(_t('NewsletterAdmin.RECIPIENTS', 'Recipients'), $recipients = new MemberTableField($this, "Recipients", $group)), new Tab(_t('NewsletterAdmin.IMPORT', 'Import'), $importField = new RecipientImportField("ImportFile", _t('NewsletterAdmin.IMPORTFROM', 'Import from file'), $group)), new Tab(_t('NewsletterAdmin.UNSUBSCRIBERS', 'Unsubscribers'), $unsubscribedList = new UnsubscribedList("Unsubscribed", $mailType)), new Tab(_t('NewsletterAdmin.BOUNCED', 'Bounced'), $bouncedList = new BouncedList("Bounced", $mailType)))); $recipients->setController($this); $importField->setController($this); $unsubscribedList->setController($this); $bouncedList->setController($this); $importField->setTypeID($id); $fields->push($idField = new HiddenField("ID")); $fields->push(new HiddenField("executeForm", "", "MailingListEditForm")); $idField->setValue($id); // Save button is not used in Mailing List section $actions = new FieldSet(new HiddenField("save")); $form = new Form($this, "MailingListEditForm", $fields, $actions); $form->loadDataFrom(array('Title' => $mailType->Title, 'FromEmail' => $mailType->FromEmail)); // This saves us from having to change all the JS in response to renaming this form to MailingListEditForm $form->setHTMLID('Form_EditForm'); } else { $form = false; } return $form; }