Skip to content
This repository
Browse code

Merge pull request #78 from halkyon/uploadfile_allowed_extensions

ENHANCEMENT Indicate which file extensions are allowed to be uploaded
  • Loading branch information...
commit 1c2ccaecb1ced3305a927ea33f01aed6577555e2 2 parents 8166c26 + 7c9a130
Ingo Schommer authored March 27, 2012

Showing 1 changed file with 18 additions and 4 deletions. Show diff stats Hide diff stats

  1. 22  code/controllers/CMSFileAddController.php
22  code/controllers/CMSFileAddController.php
@@ -72,10 +72,24 @@ public function getEditForm($id = null, $fields = null) {
72 72
 			$uploadField->setFolderName(ASSETS_DIR);
73 73
 		}
74 74
 
  75
+		$exts = $uploadField->getValidator()->getAllowedExtensions();
  76
+		asort($exts);
  77
+
75 78
 		$form = new Form(
76  
-			$this, 
77  
-			'getEditForm', 
78  
-			new FieldList($uploadField, new HiddenField('ID')), 
  79
+			$this,
  80
+			'getEditForm',
  81
+			new FieldList(
  82
+				$uploadField,
  83
+				new LiteralField(
  84
+					'AllowedExtensions',
  85
+					sprintf(
  86
+						'<p>%s: %s</p>',
  87
+						_t('AssetAdmin.ALLOWEDEXTS', 'Allowed extensions'),
  88
+						implode('<em>, </em>', $exts)
  89
+					)
  90
+				),
  91
+				new HiddenField('ID')
  92
+			),
79 93
 			new FieldList()
80 94
 		);
81 95
 		$form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
@@ -121,4 +135,4 @@ public function Breadcrumbs($unlinked = false) {
121 135
 		return $items;
122 136
 	}
123 137
 
124  
-}
  138
+}

0 notes on commit 1c2ccae

Please sign in to comment.
Something went wrong with that request. Please try again.