From 9e541241454e8c19834a0423311d1c3be9b7540c Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 27 Mar 2012 10:18:05 +1300 Subject: [PATCH 1/2] ENHANCEMENT Indicate which file extensions are allowed to be uploaded when choosing a file to upload. --- code/controllers/CMSFileAddController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/controllers/CMSFileAddController.php b/code/controllers/CMSFileAddController.php index aa8239f6..fc056b0a 100644 --- a/code/controllers/CMSFileAddController.php +++ b/code/controllers/CMSFileAddController.php @@ -73,9 +73,13 @@ class CMSFileAddController extends LeftAndMain { } $form = new Form( - $this, - 'getEditForm', - new FieldList($uploadField, new HiddenField('ID')), + $this, + 'getEditForm', + new FieldList( + $uploadField, + new LiteralField('AllowedExtensions', sprintf('

Allowed extensions: %s

', implode(', ', $uploadField->getValidator()->getAllowedExtensions()))), + new HiddenField('ID') + ), new FieldList() ); $form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses()); @@ -121,4 +125,4 @@ class CMSFileAddController extends LeftAndMain { return $items; } -} \ No newline at end of file +} From 7c9a1304a527785eaac58217464070a144ae64e6 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 27 Mar 2012 13:40:23 +1300 Subject: [PATCH 2/2] ENHANCEMENT Sort extension names by alphabetical order in CMSFileAddController::getEditForm() ENHANCEMENT Ensure _t() used for "Allowed extensions" english text. --- code/controllers/CMSFileAddController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/controllers/CMSFileAddController.php b/code/controllers/CMSFileAddController.php index fc056b0a..28f2b735 100644 --- a/code/controllers/CMSFileAddController.php +++ b/code/controllers/CMSFileAddController.php @@ -72,12 +72,22 @@ class CMSFileAddController extends LeftAndMain { $uploadField->setFolderName(ASSETS_DIR); } + $exts = $uploadField->getValidator()->getAllowedExtensions(); + asort($exts); + $form = new Form( $this, 'getEditForm', new FieldList( $uploadField, - new LiteralField('AllowedExtensions', sprintf('

Allowed extensions: %s

', implode('
, ', $uploadField->getValidator()->getAllowedExtensions()))), + new LiteralField( + 'AllowedExtensions', + sprintf( + '

%s: %s

', + _t('AssetAdmin.ALLOWEDEXTS', 'Allowed extensions'), + implode(', ', $exts) + ) + ), new HiddenField('ID') ), new FieldList()