diff --git a/code/cms/DMSDocumentAddController.php b/code/cms/DMSDocumentAddController.php index f308080..aed0100 100644 --- a/code/cms/DMSDocumentAddController.php +++ b/code/cms/DMSDocumentAddController.php @@ -73,18 +73,28 @@ class DMSDocumentAddController extends LeftAndMain { Done! "; + + $addExistingField = new DMSDocumentAddExistingField('AddExisting', 'Add Existing'); + $addExistingField->setRecord($page); $form = new Form( $this, 'getEditForm', new FieldList( - new HiddenField('ID', false, $page->ID), - $uploadField, - new LiteralField( - 'AllowedExtensions', - sprintf( - '

%s: %s

', - _t('AssetAdmin.ALLOWEDEXTS', 'Allowed extensions'), - implode(', ', $exts) + new TabSet('Main', + new Tab('From your computer', + new HiddenField('ID', false, $page->ID), + $uploadField, + new LiteralField( + 'AllowedExtensions', + sprintf( + '

%s: %s

', + _t('AssetAdmin.ALLOWEDEXTS', 'Allowed extensions'), + implode(', ', $exts) + ) + ) + ), + new Tab('From the CMS', + $addExistingField ) ) ), diff --git a/code/cms/DMSDocumentAddExistingField.php b/code/cms/DMSDocumentAddExistingField.php new file mode 100644 index 0000000..df5f595 --- /dev/null +++ b/code/cms/DMSDocumentAddExistingField.php @@ -0,0 +1,37 @@ +record = $record; + return $this; + } + /** + * Get the record to use as "Parent" for uploaded Files (eg a Page with a has_one to File) If none is set, it will use Form->getRecord() or Form->Controller()->data() + * @return DataObject + */ + public function getRecord() { + if (!$this->record && $this->form) { + if ($this->form->getRecord() && is_a($this->form->getRecord(), 'DataObject')) { + $this->record = $this->form->getRecord(); + } elseif ($this->form->Controller() && $this->form->Controller()->hasMethod('data') + && $this->form->Controller()->data() && is_a($this->form->Controller()->data(), 'DataObject')) { + $this->record = $this->form->Controller()->data(); + } + } + return $this->record; + } + + public function FieldHolder($properties = array()) { + return $this->Field($properties); + } + + public function Field($properties = array()) { + return $this->renderWith('DMSDocumentAddExistingField'); + } +} + +?> \ No newline at end of file diff --git a/templates/DMSDocumentAddExistingField.ss b/templates/DMSDocumentAddExistingField.ss new file mode 100644 index 0000000..cd9bd13 --- /dev/null +++ b/templates/DMSDocumentAddExistingField.ss @@ -0,0 +1,20 @@ +
+ +

+ + 1 + Link a Document + +

+
+ +
+

+ + 2 + Edit details + +

+
+ +
\ No newline at end of file