File upload field.
Наследование: extends Widget
Пример #1
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     // Overwrite default template
     if ($this->nl_template) {
         /** @var FrontendTemplate|object $objTemplate */
         $objTemplate = new \FrontendTemplate($this->nl_template);
         $this->Template = $objTemplate;
         $this->Template->setData($this->arrData);
     }
     $this->Template->email = '';
     $this->Template->captcha = '';
     // Activate e-mail address
     if (\Input::get('token')) {
         $this->activateRecipient();
         return;
     }
     $objWidget = null;
     // Set up the captcha widget
     if (!$this->disableCaptcha) {
         $arrField = array('name' => 'subscribe', '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) {
             call_user_func_array(array($this, 'addRecipient'), $varSubmitted);
         }
     }
     // Add the captcha widget to the template
     if ($objWidget !== null) {
         $this->Template->captcha = $objWidget->parse();
     }
     $flashBag = \System::getContainer()->get('session')->getFlashBag();
     // Confirmation message
     if ($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;
 }