/**
  * Parse the template file and return it as string
  * @param array
  * @return string
  */
 public function parse($arrAttributes = null)
 {
     if ($this->formcontrol_template) {
         $this->strTemplate = $this->formcontrol_template;
     }
     return parent::parse($arrAttributes);
 }
Ejemplo n.º 2
0
 /**
  * Validate input and set value
  * We call the parent (FormFileUpload) if user has JavaScript disabled
  */
 public function validate()
 {
     if ($this->mandatory) {
         if (!$_SESSION['FILES'] || !count($_SESSION['FILES'])) {
             $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mandatory'], $this->strLabel));
         }
         $this->mandatory = false;
     }
     // Call parent validate() to upload files without javascript.
     return parent::validate();
 }
Ejemplo n.º 3
0
 /**
  * input_field callback
  * @return string
  */
 public function generateFileUploadField()
 {
     // generate the attached files listing
     $objDb = $this->Database->prepare('SELECT attachment FROM tl_be_email WHERE id=?')->execute(\Input::get('id'));
     $strAttachments = '';
     if ($objDb->attachment != '' && count(unserialize($objDb->attachment)) > 0) {
         $arrFiles = unserialize($objDb->attachment);
         $arrOptions = array();
         foreach ($arrFiles as $fileKey => $fileName) {
             $file = new File(BE_EMAIL_UPLOAD_DIR . '/' . $fileKey);
             $arrOptions[] = array('value' => $fileKey, 'label' => specialchars($fileName . ' [' . $this->getReadableSize($file->size) . ']'));
         }
         if (count($arrFiles)) {
             $widget = new FormCheckBox();
             $widget->name = 'attachment';
             $widget->class = 'attachmentList';
             $widget->options = serialize($arrOptions);
             $widget->addSubmit = true;
             $widget->slabel = $GLOBALS['TL_LANG']['tl_be_email']['removeAttachments'][0];
             $strAttachments .= '<h3><label>' . $GLOBALS['TL_LANG']['tl_be_email']['emailAttachments'][0] . '</label></h3>';
             $strAttachments .= $widget->generate();
         }
     }
     // generate the fileupload form field
     $widget = new FormFileUpload();
     $widget->id = 'fileupload';
     $widget->name = 'file';
     $widget->class = 'tl_upload_file';
     $widget->label = $GLOBALS['TL_LANG']['tl_be_email']['fileupload'][0];
     $widget->slabel = 'upload';
     $widget->addSubmit = true;
     $widget->maxlength = $GLOBALS['TL_CONFIG']['maxFileSize'];
     $strFileuploader = $widget->generateLabel() . $widget->generate();
     // return the html
     $html = '<div id="attachmentBox">%s%s</div>';
     return sprintf($html, $strAttachments, $strFileuploader);
 }