/**
     * Inject Javascript to preselect newsletters
     * @return string
     */
    public function generate()
    {
        $parentResult = parent::generate();
        if (TL_MODE == 'BE') {
            return $parentResult;
        }
        if (\Input::post('FORM_SUBMIT') == 'tl_registration') {
            return $parentResult;
        }
        $script = <<<SCRIPT
<script language="JavaScript">
jQuery('#tl_registration input[name="newsletter[]"]').prop('checked', true);
</script>
SCRIPT;
        return $parentResult . $script;
    }
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['registration_plus'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     $strFormId = FormHelper::getFormId($this->formHybridDataContainer, $this->id);
     // get id from FormSession
     if ($_POST) {
         $intId = FormSession::getSubmissionId($strFormId);
     }
     $this->objForm = new MemberRegistrationPlusForm($this->objModel, $intId ?: 0);
     $this->editable = $this->objForm->getEditableFields();
     // Return if there are no editable fields
     if (!is_array($this->editable) || empty($this->editable)) {
         return '';
     }
     return parent::generate();
 }
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['loginregistration'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     // required by ModuleRegistration::generate();
     $this->editable = array('username', 'password');
     $this->allowedMailDomains = deserialize($this->allowedMailDomains, true);
     $this->domainCheck = false;
     $this->domainList = $this->getDomainList();
     if (is_array($this->domainList) && !empty($this->domainList)) {
         $this->domainCheck = true;
     }
     // Set the last page visited
     if ($this->redirectBack) {
         $_SESSION['LAST_PAGE_VISITED'] = $this->getReferer();
     }
     // Redirect to the jumpTo page if user is logged in and permanentRedirect is enables
     if (FE_USER_LOGGED_IN && $this->redirectPermanent) {
         $this->redirect($this->getJumpTo());
     }
     // Login
     if (\Input::post('FORM_SUBMIT') == 'tl_login') {
         // Check whether username and password are set
         if (empty($_POST['username']) || empty($_POST['password'])) {
             $_SESSION['LOGIN_ERROR'] = $GLOBALS['TL_LANG']['MSC']['emptyField'];
             $this->reload();
         }
         $strRedirect = $this->getJumpTo();
         $this->import('FrontendUser', 'User');
         // Auto login is not allowed
         if (isset($_POST['autologin']) && !$this->autologin) {
             unset($_POST['autologin']);
             \Input::setPost('autologin', null);
         }
         // Login existing user, or try to get username-domain-combination or register
         if ($this->User->login()) {
             $this->redirect($strRedirect);
         } else {
             $username = $_POST['username'];
             if ($this->domainCheck || \Validator::isEmail($username)) {
                 if (($username = $this->getValidDomainUsername()) === null) {
                     $this->reload();
                 }
                 // overwrite the username
                 $username = strtolower($username);
                 $_POST['username'] = $username;
                 \Input::setPost('username', $username);
                 if ($this->User->login()) {
                     $this->redirect($strRedirect);
                 }
                 $this->registerUser($username);
             }
         }
         $this->reload();
     }
     // Logout and redirect to the website root if the current page is protected
     if (\Input::post('FORM_SUBMIT') == 'tl_logout') {
         global $objPage;
         $this->import('FrontendUser', 'User');
         $strRedirect = \Environment::get('request');
         // Redirect to last page visited
         if ($this->redirectBack && strlen($_SESSION['LAST_PAGE_VISITED'])) {
             $strRedirect = $_SESSION['LAST_PAGE_VISITED'];
         } elseif ($objPage->protected) {
             $strRedirect = \Environment::get('base');
         }
         // Logout and redirect
         if ($this->User->logout()) {
             $this->redirect($strRedirect);
         }
         $this->reload();
     }
     return parent::generate();
 }