From 4d633b4cb5f5b399a8b7ec20e581dcd0dc41a3eb Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 16 Jan 2020 14:51:04 +0900 Subject: [PATCH] Addes the item copying action to the item controller. --- .../src/Controller/Admin/ItemController.php | 9 +++++-- application/view/omeka/admin/item/copy.phtml | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 application/view/omeka/admin/item/copy.phtml diff --git a/application/src/Controller/Admin/ItemController.php b/application/src/Controller/Admin/ItemController.php index 4d47869d4d..87ffed7dd7 100644 --- a/application/src/Controller/Admin/ItemController.php +++ b/application/src/Controller/Admin/ItemController.php @@ -200,6 +200,11 @@ public function editAction() return $this->getAddEditView(); } + public function copyAction() + { + return $this->getAddEditView(); + } + /** * Get the add/edit view. * @@ -214,7 +219,7 @@ protected function getAddEditView() $form->setAttribute('enctype', 'multipart/form-data'); $form->setAttribute('id', '$action-item'); - if ('edit' === $action) { + if ('edit' === $action || 'copy' === $action) { $item = $this->api()->read('items', $this->params('id'))->getContent(); } @@ -252,7 +257,7 @@ protected function getAddEditView() $view = new ViewModel; $view->setVariable('form', $form); - if ('edit' === $action) { + if ('edit' === $action || 'copy' === $action) { $view->setVariable('item', $item); $view->setVariable('resource', $item); } diff --git a/application/view/omeka/admin/item/copy.phtml b/application/view/omeka/admin/item/copy.phtml new file mode 100644 index 0000000000..36b1dfe045 --- /dev/null +++ b/application/view/omeka/admin/item/copy.phtml @@ -0,0 +1,25 @@ +plugin('translate'); +$escape = $this->plugin('escapeHtml'); +$this->htmlElement('body')->appendAttribute('class', 'add items'); +?> + + + +pageTitle("Copied from " . $item->displayTitle(), 1, $translate('Items')); ?> +trigger('view.add.before'); ?> +partial('omeka/admin/item/form.phtml', [ + 'form' => $form, + 'item' => $item, + 'resource' => $resource, + 'mediaForms' => $mediaForms, + 'submitLabel' => $translate('Add'), + 'sectionNavEvent' => 'view.add.section_nav', + 'action' => 'add', +]); +?> + +trigger('view.add.after'); ?>