From 37a914641bba522d9a3bc0757902c7c9f3033552 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 11 Feb 2010 02:22:45 +0000 Subject: [PATCH] ENHANCEMENT Added help texts for MemberImportForm and GroupImportForm git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@98750 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/GroupImportForm.php | 24 +++++++++++++++- code/MemberImportForm.php | 23 ++++++++++++++++ code/SecurityAdmin.php | 8 ++++-- css/MemberImportForm.css | 25 +++++++++++++++++ javascript/MemberImportForm.js | 19 +++++++++++++ lang/en_US.php | 50 ++++++++++++++++++++++++++++++++++ 6 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 css/MemberImportForm.css create mode 100644 javascript/MemberImportForm.js diff --git a/code/GroupImportForm.php b/code/GroupImportForm.php index b5f55eab..a514247d 100644 --- a/code/GroupImportForm.php +++ b/code/GroupImportForm.php @@ -15,7 +15,28 @@ class GroupImportForm extends Form { function __construct($controller, $name, $fields = null, $actions = null, $validator = null) { if(!$fields) { + $helpHtml = _t( + 'GroupImportForm.Help1', + '

Import one or more groups in CSV format (comma-separated values). Show advanced usage

' + ); + $helpHtml .= _t( + 'GroupImportForm.Help2', +'
+

Advanced usage

+ +
'); + + $importer = new GroupCsvBulkLoader(); + $importSpec = $importer->getImportSpec(); + $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields']))); + $fields = new FieldSet( + new LiteralField('Help', $helpHtml), $fileField = new FileField( 'CsvFile', _t( @@ -33,8 +54,9 @@ class GroupImportForm extends Form { if(!$validator) $validator = new RequiredFields('CsvFile'); - parent::__construct($controller, $name, $fields, $actions, $validator); + + $this->addExtraClass('import-form'); } function doImport($data, $form) { diff --git a/code/MemberImportForm.php b/code/MemberImportForm.php index 85da09a8..d3df83c5 100644 --- a/code/MemberImportForm.php +++ b/code/MemberImportForm.php @@ -15,7 +15,27 @@ class MemberImportForm extends Form { function __construct($controller, $name, $fields = null, $actions = null, $validator = null) { if(!$fields) { + $helpHtml = _t( + 'MemberImportForm.Help1', + '

Import members in CSV format (comma-separated values). Show advanced usage

' + ); + $helpHtml .= _t( + 'MemberImportForm.Help2', +'
+

Advanced usage

+ +
'); + + $importer = new MemberCsvBulkLoader(); + $importSpec = $importer->getImportSpec(); + $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields']))); + $fields = new FieldSet( + new LiteralField('Help', $helpHtml), $fileField = new FileField( 'CsvFile', _t( @@ -35,6 +55,9 @@ class MemberImportForm extends Form { parent::__construct($controller, $name, $fields, $actions, $validator); + + Requirements::javascript(CMS_DIR . '/javascript/MemberImportForm.js'); + $this->addExtraClass('import-form'); } function doImport($data, $form) { diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index 0d8b0968..93a72a22 100644 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -113,7 +113,9 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { Requirements::css(SAPPHIRE_DIR . '/css/Form.css'); Requirements::css(CMS_DIR . '/css/typography.css'); Requirements::css(CMS_DIR . '/css/cms_right.css'); - + Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js'); + Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-concrete/dist/jquery.concrete-dist.js'); + Requirements::css(CMS_DIR . '/css/MemberImportForm.css'); Requirements::javascript(CMS_DIR . '/javascript/MemberImportForm.js'); return $this->renderWith('BlankPage', array( @@ -142,7 +144,9 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { Requirements::css(SAPPHIRE_DIR . '/css/Form.css'); Requirements::css(CMS_DIR . '/css/typography.css'); Requirements::css(CMS_DIR . '/css/cms_right.css'); - + Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js'); + Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-concrete/dist/jquery.concrete-dist.js'); + Requirements::css(CMS_DIR . '/css/MemberImportForm.css'); Requirements::javascript(CMS_DIR . '/javascript/MemberImportForm.js'); return $this->renderWith('BlankPage', array( diff --git a/css/MemberImportForm.css b/css/MemberImportForm.css new file mode 100644 index 00000000..16927ddf --- /dev/null +++ b/css/MemberImportForm.css @@ -0,0 +1,25 @@ +* { + font-size:12px; +} + +body { + margin: 0; + padding: 0; +} + +form.import-form { + margin: 0; +} + + form.import-form #CsvFile .middleColumn { + background: none !important; + } + + form.import-form .advanced h4 { + margin-bottom: .5em; + } + + form.import-form .Actions { + text-align: left; + border: 0; + } \ No newline at end of file diff --git a/javascript/MemberImportForm.js b/javascript/MemberImportForm.js new file mode 100644 index 00000000..e45c03b5 --- /dev/null +++ b/javascript/MemberImportForm.js @@ -0,0 +1,19 @@ +(function($) { + $.concrete('ss', function($){ + $('.import-form .advanced').concrete({ + onmatch: function() { + this._super(); + + this.hide(); + } + }); + + $('.import-form a.toggle-advanced').concrete({ + onclick: function(e) { + this.parents('form:eq(0)').find('.advanced').toggle(); + return false; + } + }); + }); + +}(jQuery)); \ No newline at end of file diff --git a/lang/en_US.php b/lang/en_US.php index fbaaeb3b..12993d39 100755 --- a/lang/en_US.php +++ b/lang/en_US.php @@ -207,6 +207,20 @@ $lang['en_US']['CommentTableField.ss']['SPAM'] = 'spam'; $lang['en_US']['ComplexTableField']['CLOSEPOPUP'] = 'Close Popup'; $lang['en_US']['ComplexTableField']['SUCCESSADD'] = 'Added %s %s %s'; $lang['en_US']['Folder']['DELSELECTED'] = 'Delete selected files'; +$lang['en_US']['Group']['IMPORTTABTITLE'] = 'Import'; +$lang['en_US']['GroupImportForm']['Help1'] = '

Import one or more groups in CSV format (comma-separated values). Show advanced usage

'; +$lang['en_US']['GroupImportForm']['Help2'] = '
+

Advanced usage

+ +
'; +$lang['en_US']['GroupImportForm']['ResultCreated'] = 'Created %d groups'; +$lang['en_US']['GroupImportForm']['ResultDeleted'] = 'Deleted %d groups'; +$lang['en_US']['GroupImportForm']['ResultUpdated'] = 'Updated %d groups'; $lang['en_US']['ImageEditor.ss']['ACTIONS'] = 'actions'; $lang['en_US']['ImageEditor.ss']['ADJUST'] = 'adjust'; $lang['en_US']['ImageEditor.ss']['APPLY'] = 'apply'; @@ -274,6 +288,39 @@ $lang['en_US']['LeftAndMain.ss']['VIEWINDRAFT'] = 'View the Page in the Draft Si $lang['en_US']['LeftAndMain.ss']['VIEWINPUBLISHED'] = 'View the Page in the Published Site'; $lang['en_US']['LeftAndMain.ss']['VIEWPAGEIN'] = 'Page view:'; $lang['en_US']['LeftAndMain_right.ss']['WELCOMETO'] = 'Welcome to'; +$lang['en_US']['MathSpamProtection']['EIGHT'] = 'eight'; +$lang['en_US']['MathSpamProtection']['EIGHTEEN'] = 'eighteen'; +$lang['en_US']['MathSpamProtection']['ELEVEN'] = 'eleven'; +$lang['en_US']['MathSpamProtection']['FIFTEEN'] = 'fifteen'; +$lang['en_US']['MathSpamProtection']['FIVE'] = 'five'; +$lang['en_US']['MathSpamProtection']['FOUR'] = 'four'; +$lang['en_US']['MathSpamProtection']['FOURTEEN'] = 'fourteen'; +$lang['en_US']['MathSpamProtection']['NINE'] = 'nine'; +$lang['en_US']['MathSpamProtection']['ONE'] = 'one'; +$lang['en_US']['MathSpamProtection']['SEVEN'] = 'seven'; +$lang['en_US']['MathSpamProtection']['SEVENTEEN'] = 'seventeen'; +$lang['en_US']['MathSpamProtection']['SIX'] = 'six'; +$lang['en_US']['MathSpamProtection']['SIXTEEN'] = 'sixteen'; +$lang['en_US']['MathSpamProtection']['TEN'] = 'ten'; +$lang['en_US']['MathSpamProtection']['THIRTEEN'] = 'thirteen'; +$lang['en_US']['MathSpamProtection']['THREE'] = 'three'; +$lang['en_US']['MathSpamProtection']['TWELVE'] = 'twelve'; +$lang['en_US']['MathSpamProtection']['TWO'] = 'two'; +$lang['en_US']['MathSpamProtection']['WHATIS'] = 'What is %s plus %s?'; +$lang['en_US']['MathSpamProtection']['ZERO'] = 'zero'; +$lang['en_US']['MemberImportForm']['Help1'] = '

Import members in CSV format (comma-separated values). Show advanced usage

'; +$lang['en_US']['MemberImportForm']['Help2'] = '
+

Advanced usage

+ +
'; +$lang['en_US']['MemberImportForm']['ResultCreated'] = 'Created %d members'; +$lang['en_US']['MemberImportForm']['ResultDeleted'] = 'Deleted %d members'; +$lang['en_US']['MemberImportForm']['ResultNone'] = 'No changes'; +$lang['en_US']['MemberImportForm']['ResultUpdated'] = 'Updated %d members'; $lang['en_US']['MemberList.ss']['FILTER'] = array( 'Filter', 50, @@ -416,6 +463,9 @@ $lang['en_US']['SecurityAdmin']['MENUTITLE'] = array( 'Menu title' ); $lang['en_US']['SecurityAdmin']['SGROUPS'] = 'Security Groups'; +$lang['en_US']['SecurityAdmin']['TABIMPORT'] = 'Import'; +$lang['en_US']['SecurityAdmin_MemberImportForm']['BtnImport'] = 'Import'; +$lang['en_US']['SecurityAdmin_MemberImportForm']['FileFieldLabel'] = 'CSV File (Allowed extensions: *.csv)'; $lang['en_US']['SecurityAdmin_left.ss']['BATCHACTIONS'] = array( 'Batch Actions', PR_HIGH