2012-07-31 04:24:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Field for uploading files into a DMSDocument. Replacing the existing file.
|
|
|
|
*
|
|
|
|
* <b>NOTE: this Field will call write() on the supplied record</b>
|
|
|
|
*
|
|
|
|
* <b>Features (some might not be available to old browsers):</b>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Julian Seidenberg
|
|
|
|
* @package dms
|
|
|
|
*/
|
|
|
|
class DMSUploadField extends UploadField {
|
|
|
|
|
2012-07-31 08:16:54 +02:00
|
|
|
protected $folderName = 'DMSTemporaryUploads';
|
|
|
|
|
2012-07-31 04:24:35 +02:00
|
|
|
/**
|
|
|
|
* Override the default behaviour of the UploadField and take the uploaded file (uploaded to assets) and
|
|
|
|
* add it into the DMS storage, deleting the old/uploaded file.
|
|
|
|
* @param File
|
|
|
|
*/
|
|
|
|
protected function attachFile($file) {
|
|
|
|
$dmsDocument = $this->getRecord();
|
|
|
|
$dmsDocument->ingestFile($file);
|
|
|
|
}
|
|
|
|
|
2012-07-31 08:16:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Never directly display items uploaded
|
|
|
|
* @return SS_List
|
|
|
|
*/
|
|
|
|
public function getItems() {
|
|
|
|
return new ArrayList();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function Field($properties = array()) {
|
|
|
|
$fields = parent::Field($properties);
|
|
|
|
|
|
|
|
//replace the download template with a new one
|
|
|
|
Requirements::block(FRAMEWORK_DIR . '/javascript/UploadField_downloadtemplate.js');
|
|
|
|
Requirements::javascript('dms/javascript/DMSUploadField_downloadtemplate.js');
|
|
|
|
|
|
|
|
return $fields;
|
|
|
|
}
|
2012-07-31 04:24:35 +02:00
|
|
|
}
|