コード例 #1
0
 /**
  * Renders the form field, loads requirements. Sets file size based on php.ini
  * Adds the security token
  * 
  * @param array $attributes [description]
  * @return  SSViewer
  */
 public function FieldHolder($attributes = array())
 {
     Requirements::javascript(DROPZONE_DIR . '/javascript/dropzone.js');
     Requirements::javascript(DROPZONE_DIR . '/javascript/file_attachment_field.js');
     if ($this->isCMS()) {
         Requirements::javascript(DROPZONE_DIR . '/javascript/file_attachment_field_backend.js');
     }
     Requirements::css(DROPZONE_DIR . '/css/file_attachment_field.css');
     if (!$this->getSetting('url')) {
         $this->settings['url'] = $this->Link('upload');
     }
     if (!$this->getSetting('maxFilesize')) {
         $this->settings['maxFilesize'] = static::get_filesize_from_ini();
     }
     // The user may not have opted into a multiple upload. If the form field
     // is attached to a record that has a multi relation, set that automatically.
     $this->settings['uploadMultiple'] = $this->IsMultiple();
     // Auto filter images if assigned to an Image relation
     if ($class = $this->getFileClass()) {
         if (Injector::inst()->get($class) instanceof Image) {
             $this->imagesOnly();
         }
     }
     if ($token = $this->getForm()->getSecurityToken()) {
         $this->addParam($token->getName(), $token->getSecurityID());
     }
     return parent::FieldHolder($attributes);
 }