protected function compile()
	{
		// Overwrite default template
		if ($this->nl_template)
		{
			$this->Template = new FrontendTemplate($this->nl_template);
			$this->Template->setData($this->arrData);
		}

		$this->Template->email = '';
		$this->Template->captcha = '';

		// Activate e-mail address
		if (strncmp(Input::get('token'), 'nl-', 3) === 0)
		{
			$this->activateRecipient();

			return;
		}

		$objWidget = null;

		// Set up the captcha widget
		if (!$this->disableCaptcha)
		{
			$arrField = array
			(
				'name' => 'subscribe_'.$this->id,
				'label' => $GLOBALS['TL_LANG']['MSC']['securityQuestion'],
				'inputType' => 'captcha',
				'eval' => array('mandatory'=>true)
			);

			/** @var Widget $objWidget */
			$objWidget = new FormCaptcha(FormCaptcha::getAttributesFromDca($arrField, $arrField['name']));
		}

		$strFormId = 'tl_subscribe_' . $this->id;

		// Validate the form
		if (Input::post('FORM_SUBMIT') == $strFormId)
		{
			$varSubmitted = $this->validateForm($objWidget);

			if ($varSubmitted !== false)
			{
				$this->addRecipient(...$varSubmitted);
			}
		}

		// Add the captcha widget to the template
		if ($objWidget !== null)
		{
			$this->Template->captcha = $objWidget->parse();
		}

		$session = System::getContainer()->get('session');
		$flashBag = $session->getFlashBag();

		// Confirmation message
		if ($session->isStarted() && $flashBag->has('nl_confirm'))
		{
			$arrMessages = $flashBag->get('nl_confirm');

			$this->Template->mclass = 'confirm';
			$this->Template->message = $arrMessages[0];
		}

		$arrChannels = array();
		$objChannel = NewsletterChannelModel::findByIds($this->nl_channels);

		// Get the titles
		if ($objChannel !== null)
		{
			while ($objChannel->next())
			{
				$arrChannels[$objChannel->id] = $objChannel->title;
			}
		}

		// Default template variables
		$this->Template->channels = $arrChannels;
		$this->Template->showChannels = !$this->nl_hideChannels;
		$this->Template->submit = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['subscribe']);
		$this->Template->channelsLabel = $GLOBALS['TL_LANG']['MSC']['nl_channels'];
		$this->Template->emailLabel = $GLOBALS['TL_LANG']['MSC']['emailAddress'];
		$this->Template->action = Environment::get('indexFreeRequest');
		$this->Template->formId = $strFormId;
		$this->Template->id = $this->id;
		$this->Template->text = $this->nl_text;
	}
protected function compile()
	{
		
		if ($this->nl_template)
		{
			$this->Template = new FrontendTemplate($this->nl_template);
			$this->Template->setData($this->arrData);
		}

		$this->Template->email = '';
		$this->Template->captcha = '';

		
		if (strncmp(Input::get('token'), 'nl-', 3) === 0)
		{
			$this->activateRecipient();

			return;
		}

		$objWidget = null;

		
		if (!$this->disableCaptcha)
		{
			$arrField = array
			(
				'name' => 'subscribe_'.$this->id,
				'label' => $GLOBALS['TL_LANG']['MSC']['securityQuestion'],
				'inputType' => 'captcha',
				'eval' => array('mandatory'=>true)
			);

			
			$objWidget = new FormCaptcha(FormCaptcha::getAttributesFromDca($arrField, $arrField['name']));
		}

		$strFormId = 'tl_subscribe_' . $this->id;

		
		if (Input::post('FORM_SUBMIT') == $strFormId)
		{
			$varSubmitted = $this->validateForm($objWidget);

			if ($varSubmitted !== false)
			{
				$this->addRecipient(...$varSubmitted);
			}
		}

		
		if ($objWidget !== null)
		{
			$this->Template->captcha = $objWidget->parse();
		}

		$session = System::getContainer()->get('session');
		$flashBag = $session->getFlashBag();

		
		if ($session->isStarted() && $flashBag->has('nl_confirm'))
		{
			$arrMessages = $flashBag->get('nl_confirm');

			$this->Template->mclass = 'confirm';
			$this->Template->message = $arrMessages[0];
		}

		$arrChannels = array();
		$objChannel = NewsletterChannelModel::findByIds($this->nl_channels);

		
		if ($objChannel !== null)
		{
			while ($objChannel->next())
			{
				$arrChannels[$objChannel->id] = $objChannel->title;
			}
		}

		
		$this->Template->channels = $arrChannels;
		$this->Template->showChannels = !$this->nl_hideChannels;
		$this->Template->submit = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['subscribe']);
		$this->Template->channelsLabel = $GLOBALS['TL_LANG']['MSC']['nl_channels'];
		$this->Template->emailLabel = $GLOBALS['TL_LANG']['MSC']['emailAddress'];
		$this->Template->action = Environment::get('indexFreeRequest');
		$this->Template->formId = $strFormId;
		$this->Template->id = $this->id;
		$this->Template->text = $this->nl_text;
	}
protected function compile ( ) { // Overwrite default template if ( $ this -> nl_template ) { $ this -> Template = new FrontendTemplate ( $ this -> nl_template ) ; $ this -> Template -> setData ( $ this -> arrData ) ; } $ this -> Template -> email = '' ; $ this -> Template -> captcha = '' ; // Activate e-mail address if ( strncmp ( Input :: get ( 'token' ) , 'nl-' , 3 ) === 0 ) { $ this -> activateRecipient ( ) ; return ; } $ objWidget = null ; // Set up the captcha widget if ( ! $ this -> disableCaptcha ) { $ arrField = array ( 'name' => 'subscribe_' . $ this -> id , 'label' => $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'securityQuestion' ] , 'inputType' => 'captcha' , 'eval' => array ( 'mandatory' => true ) ) ; /** @var Widget $objWidget */ $ objWidget = new FormCaptcha ( FormCaptcha :: getAttributesFromDca ( $ arrField , $ arrField [ 'name' ] ) ) ; } $ strFormId = 'tl_subscribe_' . $ this -> id ; // Validate the form if ( Input :: post ( 'FORM_SUBMIT' ) == $ strFormId ) { $ varSubmitted = $ this -> validateForm ( $ objWidget ) ; if ( $ varSubmitted !== false ) { $ this -> addRecipient ( ... $ varSubmitted ) ; } } // Add the captcha widget to the template if ( $ objWidget !== null ) { $ this -> Template -> captcha = $ objWidget -> parse ( ) ; } $ session = System :: getContainer ( ) -> get ( 'session' ) ; $ flashBag = $ session -> getFlashBag ( ) ; // Confirmation message if ( $ session -> isStarted ( ) && $ flashBag -> has ( 'nl_confirm' ) ) { $ arrMessages = $ flashBag -> get ( 'nl_confirm' ) ; $ this -> Template -> mclass = 'confirm' ; $ this -> Template -> message = $ arrMessages [ 0 ] ; } $ arrChannels = array ( ) ; $ objChannel = NewsletterChannelModel :: findByIds ( $ this -> nl_channels ) ; // Get the titles if ( $ objChannel !== null ) { while ( $ objChannel -> next ( ) ) { $ arrChannels [ $ objChannel -> id ] = $ objChannel -> title ; } } // Default template variables $ this -> Template -> channels = $ arrChannels ; $ this -> Template -> showChannels = ! $ this -> nl_hideChannels ; $ this -> Template -> submit = StringUtil :: specialchars ( $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'subscribe' ] ) ; $ this -> Template -> channelsLabel = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'nl_channels' ] ; $ this -> Template -> emailLabel = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'emailAddress' ] ; $ this -> Template -> action = Environment :: get ( 'indexFreeRequest' ) ; $ this -> Template -> formId = $ strFormId ; $ this -> Template -> id = $ this -> id ; $ this -> Template -> text = $ this -> nl_text ; }
Generate the module
Generate the module