/**
  * 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;
         // The "required" attribute only makes sense for single checkboxes
         if (count($this->arrOptions) == 1 && $this->mandatory) {
             $this->arrAttributes['required'] = 'required';
         }
         // Generate options
         foreach ($this->arrOptions as $i => $arrOption) {
             $arrOptions[] = array('name' => $this->strName . (count($this->arrOptions) > 1 ? '[]' : ''), 'id' => $this->strId . '_' . $i, 'value' => $arrOption['value'], 'checked' => $this->isChecked($arrOption), 'attributes' => $this->getAttributes(), 'label' => $arrOption['label'], 'label_id' => $this->strId . '_' . $i, 'label_for' => $this->strId . '_' . $i);
         }
         $this->options = $arrOptions;
     }
     return parent::parse($arrAttributes);
 }
Example #2
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);
 }