From 5a6ed1a6036eb6e7f0c95b50f87c2f5e7851066e Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 21 Feb 2012 21:17:56 +0100 Subject: [PATCH] MINOR Backlink for "Add files" UI --- code/controllers/CMSFileAddController.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/code/controllers/CMSFileAddController.php b/code/controllers/CMSFileAddController.php index 44b4d2ff..74e7309b 100644 --- a/code/controllers/CMSFileAddController.php +++ b/code/controllers/CMSFileAddController.php @@ -24,13 +24,15 @@ class CMSFileAddController extends AssetAdmin { Requirements::javascript(SAPPHIRE_DIR . '/javascript/AssetUploadField.js'); Requirements::css(SAPPHIRE_DIR . '/css/AssetUploadField.css'); + $folder = $this->currentPage(); + $uploadField = Object::create('UploadField', 'AssetUploadField', ''); $uploadField->setConfig('previewMaxWidth', 40); $uploadField->setConfig('previewMaxHeight', 30); $uploadField->addExtraClass('ss-assetuploadfield'); $uploadField->removeExtraClass('ss-uploadfield'); $uploadField->setTemplate('AssetUploadField'); - if ($this->currentPage()->exists() && $this->currentPage()->getFilename()) { + if ($folder->exists() && $folder->getFilename()) { $uploadField->setFolderName($this->currentPage()->getFilename()); } @@ -38,6 +40,17 @@ class CMSFileAddController extends AssetAdmin { $form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses()); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); + $form->Fields()->push( + new LiteralField( + 'BackLink', + sprintf( + '%s', + Controller::join_links(singleton('AssetAdmin')->Link('show'), $folder ? $folder->ID : 0), + _t('AssetAdmin.BackToFolder', 'Back to folder') + ) + ) + ); + return $form; }