Skip to content

Commit

Permalink
Merge branch '1' into 2
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Sep 9, 2022
2 parents ec1111f + 36fd3f4 commit 4cf683c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions code/CMSProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\Admin;

use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Forms\HiddenField;
use SilverStripe\Forms\FormAction;
Expand All @@ -12,7 +13,6 @@

class CMSProfileController extends LeftAndMain
{

private static $url_segment = 'myprofile';

private static $menu_title = 'My Profile';
Expand All @@ -34,7 +34,7 @@ public function getEditForm($id = null, $fields = null)
$form->Fields()->removeByName('LastVisited');
$form->Fields()->push(new HiddenField('ID', null, Security::getCurrentUser()->ID));
$form->Actions()->push(
FormAction::create('save', _t('SilverStripe\\CMS\\Controllers\\CMSMain.SAVE', 'Save'))
FormAction::create('save', _t(CMSMain::class . '.SAVE', 'Save'))
->addExtraClass('btn-primary font-icon-save')
->setUseButtonTag(true)
);
Expand Down
6 changes: 3 additions & 3 deletions code/GroupImportForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct($controller, $name, $fields = null, $actions = null,
$fileField = new FileField(
'CsvFile',
DBField::create_field('HTMLFragment', _t(
'SilverStripe\\Admin\\MemberImportForm.FileFieldLabel',
MemberImportForm::class . '.FileFieldLabel',
'CSV File <small>(Allowed extensions: *.csv)</small>'
))
)
Expand All @@ -67,7 +67,7 @@ public function __construct($controller, $name, $fields = null, $actions = null,
}

if (!$actions) {
$action = new FormAction('doImport', _t('SilverStripe\\Admin\\MemberImportForm.BtnImport', 'Import from CSV'));
$action = new FormAction('doImport', _t(MemberImportForm::class . '.BtnImport', 'Import from CSV'));
$action->addExtraClass('btn btn-outline-secondary font-icon-upload');
$actions = new FieldList($action);
}
Expand Down Expand Up @@ -112,7 +112,7 @@ public function doImport($data, $form)
['count' => $result->DeletedCount()]
);
}
$msg = ($msgArr) ? implode(',', $msgArr) : _t('SilverStripe\\Admin\\MemberImportForm.ResultNone', 'No changes');
$msg = ($msgArr) ? implode(',', $msgArr) : _t(MemberImportForm::class . '.ResultNone', 'No changes');

$this->sessionMessage($msg, 'good');

Expand Down
11 changes: 6 additions & 5 deletions code/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use InvalidArgumentException;
use LogicException;
use ReflectionClass;
use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\CMS\Controllers\SilverStripeNavigator;
use SilverStripe\Control\ContentNegotiator;
use SilverStripe\Control\Controller;
Expand Down Expand Up @@ -1452,14 +1453,14 @@ public function getEditForm($id = null, $fields = null)
if (!$actions || !$actions->count()) {
if ($record->hasMethod('canEdit') && $record->canEdit()) {
$actions->push(
FormAction::create('save', _t('SilverStripe\\CMS\\Controllers\\CMSMain.SAVE', 'Save'))
FormAction::create('save', _t(CMSMain::class . '.SAVE', 'Save'))
->addExtraClass('btn btn-primary')
->addExtraClass('font-icon-add-circle')
);
}
if ($record->hasMethod('canDelete') && $record->canDelete()) {
$actions->push(
FormAction::create('delete', _t('SilverStripe\\Admin\\ModelAdmin.DELETE', 'Delete'))
FormAction::create('delete', _t(ModelAdmin::class . '.DELETE', 'Delete'))
->addExtraClass('btn btn-secondary')
);
}
Expand Down Expand Up @@ -1968,7 +1969,7 @@ public function providePermissions()
$perms = [
"CMS_ACCESS_LeftAndMain" => [
'name' => _t(__CLASS__ . '.ACCESSALLINTERFACES', 'Access to all CMS sections'),
'category' => _t('SilverStripe\\Security\\Permission.CMS_ACCESS_CATEGORY', 'CMS Access'),
'category' => _t(Permission::class . '.CMS_ACCESS_CATEGORY', 'CMS Access'),
'help' => _t(__CLASS__ . '.ACCESSALLINTERFACESHELP', 'Overrules more specific access settings.'),
'sort' => -100
]
Expand Down Expand Up @@ -1999,12 +2000,12 @@ public function providePermissions()
$title = LeftAndMain::menu_title($class);
$perms[$code] = [
'name' => _t(
'SilverStripe\\CMS\\Controllers\\CMSMain.ACCESS',
CMSMain::class . '.ACCESS',
"Access to '{title}' section",
"Item in permission selection identifying the admin section. Example: Access to 'Files & Images'",
['title' => $title]
),
'category' => _t('SilverStripe\\Security\\Permission.CMS_ACCESS_CATEGORY', 'CMS Access')
'category' => _t(Permission::class . '.CMS_ACCESS_CATEGORY', 'CMS Access')
];
}

Expand Down
4 changes: 2 additions & 2 deletions code/MemberImportForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct($controller, $name, $fields = null, $actions = null,
$fileField = new FileField(
'CsvFile',
DBField::create_field('HTMLFragment', _t(
'SilverStripe\\Admin\\MemberImportForm.FileFieldLabel',
__CLASS__ . '.FileFieldLabel',
'CSV File <small>(Allowed extensions: *.csv)</small>'
))
)
Expand All @@ -67,7 +67,7 @@ public function __construct($controller, $name, $fields = null, $actions = null,
}

if (!$actions) {
$action = new FormAction('doImport', _t('SilverStripe\\Admin\\MemberImportForm.BtnImport', 'Import from CSV'));
$action = new FormAction('doImport', _t(__CLASS__ . '.BtnImport', 'Import from CSV'));
$action->addExtraClass('btn btn-outline-secondary font-icon-upload');
$actions = new FieldList($action);
}
Expand Down
18 changes: 9 additions & 9 deletions code/ModelAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function ($form) {
$config->addComponent(
GridFieldImportButton::create('buttons-before-left')
->setImportForm($this->ImportForm())
->setModalTitle(_t('SilverStripe\\Admin\\ModelAdmin.IMPORT', 'Import from CSV'))
->setModalTitle(_t(__CLASS__ . '.IMPORT', 'Import from CSV'))
);
}

Expand Down Expand Up @@ -569,13 +569,13 @@ public function ImportForm()
$fields->push(
new CheckboxField(
'EmptyBeforeImport',
_t('SilverStripe\\Admin\\ModelAdmin.EMPTYBEFOREIMPORT', 'Replace data'),
_t(__CLASS__ . '.EMPTYBEFOREIMPORT', 'Replace data'),
false
)
);

$actions = new FieldList(
FormAction::create('import', _t('SilverStripe\\Admin\\ModelAdmin.IMPORT', 'Import from CSV'))
FormAction::create('import', _t(__CLASS__ . '.IMPORT', 'Import from CSV'))
->addExtraClass('btn btn-outline-secondary font-icon-upload')
);

Expand Down Expand Up @@ -623,7 +623,7 @@ public function import($data, $form, $request)
file_get_contents($_FILES['_CsvFile']['tmp_name'] ?? '') == ''
) {
$form->sessionMessage(
_t('SilverStripe\\Admin\\ModelAdmin.NOCSVFILE', 'Please browse for a CSV file to import'),
_t(__CLASS__ . '.NOCSVFILE', 'Please browse for a CSV file to import'),
ValidationResult::TYPE_ERROR
);
$this->redirectBack();
Expand All @@ -640,30 +640,30 @@ public function import($data, $form, $request)
if ($results) {
if ($results->CreatedCount()) {
$message .= _t(
'SilverStripe\\Admin\\ModelAdmin.IMPORTEDRECORDS',
__CLASS__ . '.IMPORTEDRECORDS',
"Imported {count} records.",
['count' => $results->CreatedCount()]
);
}
if ($results && $results->UpdatedCount()) {
$message .= _t(
'SilverStripe\\Admin\\ModelAdmin.UPDATEDRECORDS',
__CLASS__ . '.UPDATEDRECORDS',
"Updated {count} records.",
['count' => $results->UpdatedCount()]
);
}
if ($results->DeletedCount()) {
$message .= _t(
'SilverStripe\\Admin\\ModelAdmin.DELETEDRECORDS',
__CLASS__ . '.DELETEDRECORDS',
"Deleted {count} records.",
['count' => $results->DeletedCount()]
);
}
if (!$results->CreatedCount() && !$results->UpdatedCount()) {
$message .= _t('SilverStripe\\Admin\\ModelAdmin.NOIMPORT', "Nothing to import");
$message .= _t(__CLASS__ . '.NOIMPORT', "Nothing to import");
}
} else {
$message .= _t('SilverStripe\\Admin\\ModelAdmin.NOIMPORT', "Nothing to import");
$message .= _t(__CLASS__ . '.NOIMPORT', "Nothing to import");
}

$form->sessionMessage($message, 'good');
Expand Down
9 changes: 5 additions & 4 deletions code/SecurityAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\Admin;

use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\Convert;
Expand Down Expand Up @@ -318,11 +319,11 @@ public function providePermissions()
return [
"CMS_ACCESS_SecurityAdmin" => [
'name' => _t(
'SilverStripe\\CMS\\Controllers\\CMSMain.ACCESS',
CMSMain::class . '.ACCESS',
"Access to '{title}' section",
['title' => $title]
),
'category' => _t('SilverStripe\\Security\\Permission.CMS_ACCESS_CATEGORY', 'CMS Access'),
'category' => _t(Permission::class . '.CMS_ACCESS_CATEGORY', 'CMS Access'),
'help' => _t(
__CLASS__ . '.ACCESS_HELP',
'Allow viewing, adding and editing users, as well as assigning permissions and roles to them.'
Expand All @@ -331,7 +332,7 @@ public function providePermissions()
'EDIT_PERMISSIONS' => [
'name' => _t(__CLASS__ . '.EDITPERMISSIONS', 'Manage permissions for groups'),
'category' => _t(
'SilverStripe\\Security\\Permission.PERMISSIONS_CATEGORY',
Permission::class . '.PERMISSIONS_CATEGORY',
'Roles and access permissions'
),
'help' => _t(
Expand All @@ -344,7 +345,7 @@ public function providePermissions()
'APPLY_ROLES' => [
'name' => _t(__CLASS__ . '.APPLY_ROLES', 'Apply roles to groups'),
'category' => _t(
'SilverStripe\\Security\\Permission.PERMISSIONS_CATEGORY',
Permission::class . '.PERMISSIONS_CATEGORY',
'Roles and access permissions'
),
'help' => _t(
Expand Down

0 comments on commit 4cf683c

Please sign in to comment.