mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 12:05:56 +00:00
ENHANCEMENT: Adding documents to a page works! (poorly)
This commit is contained in:
parent
2819a5fd60
commit
adf25185f1
@ -58,20 +58,13 @@ class DMSDocumentAddController extends LeftAndMain {
|
|||||||
|
|
||||||
$page = $this->currentPage();
|
$page = $this->currentPage();
|
||||||
|
|
||||||
$uploadField = UploadField::create('AssetUploadField', '');
|
$uploadField = DMSUploadField::create('AssetUploadField', '');
|
||||||
$uploadField->setConfig('previewMaxWidth', 40);
|
$uploadField->setConfig('previewMaxWidth', 40);
|
||||||
$uploadField->setConfig('previewMaxHeight', 30);
|
$uploadField->setConfig('previewMaxHeight', 30);
|
||||||
$uploadField->addExtraClass('ss-assetuploadfield');
|
$uploadField->addExtraClass('ss-assetuploadfield');
|
||||||
$uploadField->removeExtraClass('ss-uploadfield');
|
$uploadField->removeExtraClass('ss-uploadfield');
|
||||||
$uploadField->setTemplate('AssetUploadField');
|
$uploadField->setTemplate('AssetUploadField');
|
||||||
|
$uploadField->setRecord($page);
|
||||||
/*if ($folder->exists() && $folder->getFilename()) {
|
|
||||||
// The Upload class expects a folder relative *within* assets/
|
|
||||||
$path = preg_replace('/^' . ASSETS_DIR . '\//', '', $folder->getFilename());
|
|
||||||
$uploadField->setFolderName($path);
|
|
||||||
} else {
|
|
||||||
$uploadField->setFolderName(ASSETS_DIR);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$exts = $uploadField->getValidator()->getAllowedExtensions();
|
$exts = $uploadField->getValidator()->getAllowedExtensions();
|
||||||
asort($exts);
|
asort($exts);
|
||||||
@ -80,6 +73,7 @@ class DMSDocumentAddController extends LeftAndMain {
|
|||||||
$this,
|
$this,
|
||||||
'getEditForm',
|
'getEditForm',
|
||||||
new FieldList(
|
new FieldList(
|
||||||
|
new HiddenField('ID', false, $page->ID),
|
||||||
$uploadField,
|
$uploadField,
|
||||||
new LiteralField(
|
new LiteralField(
|
||||||
'AllowedExtensions',
|
'AllowedExtensions',
|
||||||
@ -88,8 +82,7 @@ class DMSDocumentAddController extends LeftAndMain {
|
|||||||
_t('AssetAdmin.ALLOWEDEXTS', 'Allowed extensions'),
|
_t('AssetAdmin.ALLOWEDEXTS', 'Allowed extensions'),
|
||||||
implode('<em>, </em>', $exts)
|
implode('<em>, </em>', $exts)
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
new HiddenField('ID')
|
|
||||||
),
|
),
|
||||||
new FieldList()
|
new FieldList()
|
||||||
);
|
);
|
||||||
|
@ -21,8 +21,12 @@ class DMSUploadField extends UploadField {
|
|||||||
* @param File
|
* @param File
|
||||||
*/
|
*/
|
||||||
protected function attachFile($file) {
|
protected function attachFile($file) {
|
||||||
$dmsDocument = $this->getRecord();
|
$page = $this->getRecord();
|
||||||
$dmsDocument->ingestFile($file);
|
|
||||||
|
$dms = DMS::getDMSInstance();
|
||||||
|
$document = $dms->storeDocument($file);
|
||||||
|
$file->delete();
|
||||||
|
$document->addPage($page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user