From e6cf037369f85aacbd72ccb416f8b843589fbed0 Mon Sep 17 00:00:00 2001 From: Franco Springveldt Date: Thu, 14 Sep 2017 10:27:40 +1200 Subject: [PATCH] FIX namespaced _t() calls --- src/Forms/GridField/GridFieldAddByDBField.php | 6 ++--- .../GridField/GridFieldBlogPostState.php | 8 +++---- src/Model/Blog.php | 20 ++++++++-------- src/Model/BlogCategory.php | 2 +- src/Model/BlogController.php | 10 ++++---- src/Model/BlogMemberExtension.php | 4 ++-- src/Model/BlogObject.php | 3 +-- src/Model/BlogPost.php | 24 +++++++++---------- src/Model/BlogTag.php | 2 +- src/Widgets/BlogArchiveWidget.php | 8 +++---- src/Widgets/BlogCategoriesWidget.php | 15 ++++++------ src/Widgets/BlogRecentPostsWidget.php | 4 ++-- src/Widgets/BlogTagsCloudWidget.php | 2 +- src/Widgets/BlogTagsWidget.php | 14 +++++------ 14 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/Forms/GridField/GridFieldAddByDBField.php b/src/Forms/GridField/GridFieldAddByDBField.php index cdaa823..5c8528c 100644 --- a/src/Forms/GridField/GridFieldAddByDBField.php +++ b/src/Forms/GridField/GridFieldAddByDBField.php @@ -90,7 +90,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP if (!$id) { $gridField->setCustomValidationMessage( _t( - 'GridFieldAddByDBField.AddFail', + __CLASS__ . '.AddFail', 'Unable to save {class} to the database.', 'Unable to add the DataObject.', array( @@ -103,7 +103,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP return Security::permissionFailure( Controller::curr(), _t( - 'GridFieldAddByDBField.PermissionFail', + __CLASS__ . '.PermissionFail', 'You don\'t have permission to create a {class}.', 'Unable to add the DataObject.', array( @@ -186,7 +186,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP $gridField, 'add', _t( - 'GridFieldAddByDBField.Add', + __CLASS__ . '.Add', 'Add {name}', 'Add button text', ['name' => $obj->i18n_singular_name()] diff --git a/src/Forms/GridField/GridFieldBlogPostState.php b/src/Forms/GridField/GridFieldBlogPostState.php index cc90300..ce49e0b 100644 --- a/src/Forms/GridField/GridFieldBlogPostState.php +++ b/src/Forms/GridField/GridFieldBlogPostState.php @@ -24,7 +24,7 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState $modifiedLabel = ''; if ($record->isModifiedOnStage) { - $modifiedLabel = '' . _t('GridFieldBlogPostState.Modified') . ''; + $modifiedLabel = '' . _t(__CLASS__ . '.Modified') . ''; } if (!$record->isPublished()) { @@ -34,7 +34,7 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState $lastEdited = $record->dbObject('LastEdited'); return _t( - 'GridFieldBlogPostState.Draft', + __CLASS__ . '.Draft', ' Saved as Draft on {date}', 'State for when a post is saved.', array( @@ -50,7 +50,7 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState if (strtotime($record->PublishDate) > time()) { return _t( - 'GridFieldBlogPostState.Timer', + __CLASS__ . '.Timer', ' Publish at {date}', 'State for when a post is published.', array( @@ -60,7 +60,7 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState } return _t( - 'GridFieldBlogPostState.Published', + __CLASS__ . '.Published', ' Published on {date}', 'State for when a post is published.', array( diff --git a/src/Model/Blog.php b/src/Model/Blog.php index baf6501..104ec1f 100644 --- a/src/Model/Blog.php +++ b/src/Model/Blog.php @@ -151,7 +151,7 @@ class Blog extends Page implements PermissionProvider $categories = GridField::create( 'Categories', - _t('Blog.Categories', 'Categories'), + _t(__CLASS__ . '.Categories', 'Categories'), $this->Categories(), GridFieldCategorisationConfig::create( 15, @@ -164,7 +164,7 @@ class Blog extends Page implements PermissionProvider $tags = GridField::create( 'Tags', - _t('Blog.Tags', 'Tags'), + _t(__CLASS__ . '.Tags', 'Tags'), $this->Tags(), GridFieldCategorisationConfig::create( 15, @@ -282,15 +282,15 @@ class Blog extends Page implements PermissionProvider } if ($this->isEditor($member)) { - return _t('Blog.EDITOR', 'Editor'); + return _t(__CLASS__ . '.EDITOR', 'Editor'); } if ($this->isWriter($member)) { - return _t('Blog.WRITER', 'Writer'); + return _t(__CLASS__ . '.WRITER', 'Writer'); } if ($this->isContributor($member)) { - return _t('Blog.CONTRIBUTOR', 'Contributor'); + return _t(__CLASS__ . '.CONTRIBUTOR', 'Contributor'); } return null; @@ -349,7 +349,7 @@ class Blog extends Page implements PermissionProvider $fields->addFieldToTab( 'Root.Settings', - NumericField::create('PostsPerPage', _t('Blog.PostsPerPage', 'Posts Per Page')) + NumericField::create('PostsPerPage', _t(__CLASS__ . '.PostsPerPage', 'Posts Per Page')) ); $members = $this->getCandidateUsers()->map()->toArray(); @@ -586,7 +586,7 @@ class Blog extends Page implements PermissionProvider */ public function getLumberjackTitle() { - return _t('Blog.LumberjackTitle', 'Blog Posts'); + return _t(__CLASS__ . '.LumberjackTitle', 'Blog Posts'); } /** @@ -607,14 +607,14 @@ class Blog extends Page implements PermissionProvider return array( Blog::MANAGE_USERS => array( 'name' => _t( - 'Blog.PERMISSION_MANAGE_USERS_DESCRIPTION', + __CLASS__ . '.PERMISSION_MANAGE_USERS_DESCRIPTION', 'Manage users for individual blogs' ), 'help' => _t( - 'Blog.PERMISSION_MANAGE_USERS_HELP', + __CLASS__ . '.PERMISSION_MANAGE_USERS_HELP', 'Allow assignment of Editors, Writers, or Contributors to blogs' ), - 'category' => _t('Blog.PERMISSIONS_CATEGORY', 'Blog permissions'), + 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'Blog permissions'), 'sort' => 100 ) ); diff --git a/src/Model/BlogCategory.php b/src/Model/BlogCategory.php index 3b4959b..50e6abc 100644 --- a/src/Model/BlogCategory.php +++ b/src/Model/BlogCategory.php @@ -72,6 +72,6 @@ class BlogCategory extends DataObject implements CategorisationObject */ protected function getDuplicateError() { - return _t('BlogCategory.Duplicate', 'A blog category already exists with that name.'); + return _t(__CLASS__ . '.Duplicate', 'A blog category already exists with that name.'); } } diff --git a/src/Model/BlogController.php b/src/Model/BlogController.php index 36b2dc0..c0ad6f1 100644 --- a/src/Model/BlogController.php +++ b/src/Model/BlogController.php @@ -326,7 +326,7 @@ class BlogController extends PageController if ($currentPage > 1) { $items[] = _t( - 'Blog.FILTERDESCRIPTION_PAGE', + 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_PAGE', 'Page {page}', null, array( @@ -337,7 +337,7 @@ class BlogController extends PageController if ($author = $this->getCurrentProfile()) { $items[] = _t( - 'Blog.FILTERDESCRIPTION_AUTHOR', + 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_AUTHOR', 'By {author}', null, array( @@ -348,7 +348,7 @@ class BlogController extends PageController if ($tag = $this->getCurrentTag()) { $items[] = _t( - 'Blog.FILTERDESCRIPTION_TAG', + 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_TAG', 'Tagged with {tag}', null, array( @@ -359,7 +359,7 @@ class BlogController extends PageController if ($category = $this->getCurrentCategory()) { $items[] = _t( - 'Blog.FILTERDESCRIPTION_CATEGORY', + 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_CATEGORY', 'In category {category}', null, array( @@ -378,7 +378,7 @@ class BlogController extends PageController } $items[] = _t( - 'Blog.FILTERDESCRIPTION_DATE', + 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_DATE', 'In {date}', null, array( diff --git a/src/Model/BlogMemberExtension.php b/src/Model/BlogMemberExtension.php index 5fac4db..8f64148 100644 --- a/src/Model/BlogMemberExtension.php +++ b/src/Model/BlogMemberExtension.php @@ -111,11 +111,11 @@ class BlogMemberExtension extends DataExtension Requirements::css(BLOGGER_DIR . '/css/cms.css'); Requirements::javascript(BLOGGER_DIR . '/js/cms.js'); - $tab = Tab::create('BlogPosts', _t('BlogMemberExtension.TABBLOGPOSTS', 'Blog Posts')); + $tab = Tab::create('BlogPosts', _t(__CLASS__ . '.TABBLOGPOSTS', 'Blog Posts')); $gridField = GridField::create( 'BlogPosts', - _t('BlogMemberExtension.BLOGPOSTS', 'Blog Posts'), + _t(__CLASS__ . '.BLOGPOSTS', 'Blog Posts'), $this->owner->BlogPosts(), GridFieldConfig_BlogPost::create() ); diff --git a/src/Model/BlogObject.php b/src/Model/BlogObject.php index a36f01c..54e4294 100644 --- a/src/Model/BlogObject.php +++ b/src/Model/BlogObject.php @@ -35,12 +35,11 @@ trait BlogObject */ public function getCMSFields() { - $shortClass = ClassInfo::shortName(self::class); $fields = TabSet::create( 'Root', Tab::create( 'Main', - TextField::create('Title', _t($shortClass . '.Title', 'Title')) + TextField::create('Title', _t(__CLASS__ . '.Title', 'Title')) ) ); diff --git a/src/Model/BlogPost.php b/src/Model/BlogPost.php index 0d3eede..925808a 100644 --- a/src/Model/BlogPost.php +++ b/src/Model/BlogPost.php @@ -169,7 +169,7 @@ class BlogPost extends Page } if ($this->isAuthor($member)) { - return _t('BlogPost.AUTHOR', 'Author'); + return _t(__CLASS__ . '.AUTHOR', 'Author'); } $parent = $this->Parent(); @@ -212,7 +212,7 @@ class BlogPost extends Page Requirements::javascript(BLOGGER_DIR . '/js/cms.js'); $this->beforeUpdateCMSFields(function ($fields) { - $uploadField = UploadField::create('FeaturedImage', _t('BlogPost.FeaturedImage', 'Featured Image')); + $uploadField = UploadField::create('FeaturedImage', _t(__CLASS__ . '.FeaturedImage', 'Featured Image')); $uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); /** @@ -223,13 +223,13 @@ class BlogPost extends Page $summary = HtmlEditorField::create('Summary', false); $summary->setRows(5); $summary->setDescription(_t( - 'BlogPost.SUMMARY_DESCRIPTION', + __CLASS__ . '.SUMMARY_DESCRIPTION', 'If no summary is specified the first 30 words will be used.' )); $summaryHolder = ToggleCompositeField::create( 'CustomSummary', - _t('BlogPost.CUSTOMSUMMARY', 'Add A Custom Summary'), + _t(__CLASS__ . '.CUSTOMSUMMARY', 'Add A Custom Summary'), array( $summary, ) @@ -249,18 +249,18 @@ class BlogPost extends Page $authorField = ListboxField::create( 'Authors', - _t('BlogPost.Authors', 'Authors'), + _t(__CLASS__ . '.Authors', 'Authors'), $this->getCandidateAuthors()->map()->toArray() ); $authorNames = TextField::create( 'AuthorNames', - _t('BlogPost.AdditionalCredits', 'Additional Credits'), + _t(__CLASS__ . '.AdditionalCredits', 'Additional Credits'), null, 1024 )->setDescription( _t( - 'BlogPost.AdditionalCredits_Description', + __CLASS__ . '.AdditionalCredits_Description', 'If some authors of this post don\'t have CMS access, enter their name(s) here. You can separate multiple names with a comma.' ) ); @@ -270,12 +270,12 @@ class BlogPost extends Page $authorNames = $authorNames->performDisabledTransformation(); } - $publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date')); + $publishDate = DatetimeField::create('PublishDate', _t(__CLASS__ . '.PublishDate', 'Publish Date')); if (!$this->PublishDate) { $publishDate->setDescription( _t( - 'BlogPost.PublishDate_Description', + __CLASS__ . '.PublishDate_Description', 'Will be set to "now" if published without a value.' ) ); @@ -299,7 +299,7 @@ class BlogPost extends Page $urlSegment, TagField::create( 'Categories', - _t('BlogPost.Categories', 'Categories'), + _t(__CLASS__ . '.Categories', 'Categories'), $categories, $this->Categories() ) @@ -307,7 +307,7 @@ class BlogPost extends Page ->setShouldLazyLoad(true), TagField::create( 'Tags', - _t('BlogPost.Tags', 'Tags'), + _t(__CLASS__ . '.Tags', 'Tags'), $tags, $this->Tags() ) @@ -721,7 +721,7 @@ class BlogPost extends Page { $labels = parent::fieldLabels($includeRelations); - $labels['Title'] = _t('BlogPost.PageTitleLabel', 'Post Title'); + $labels['Title'] = _t(__CLASS__ . '.PageTitleLabel', 'Post Title'); return $labels; } diff --git a/src/Model/BlogTag.php b/src/Model/BlogTag.php index 983a946..2163c97 100644 --- a/src/Model/BlogTag.php +++ b/src/Model/BlogTag.php @@ -72,6 +72,6 @@ class BlogTag extends DataObject implements CategorisationObject */ protected function getDuplicateError() { - return _t('BlogTag.Duplicate', 'A blog tag already exists with that name.'); + return _t(__CLASS__ . '.Duplicate', 'A blog tag already exists with that name.'); } } diff --git a/src/Widgets/BlogArchiveWidget.php b/src/Widgets/BlogArchiveWidget.php index 5ea67f7..ee53d07 100644 --- a/src/Widgets/BlogArchiveWidget.php +++ b/src/Widgets/BlogArchiveWidget.php @@ -71,7 +71,7 @@ class BlogArchiveWidget extends Widget $type = $archiveType->enumValues(); foreach ($type as $k => $v) { - $type[$k] = _t('BlogArchiveWidget.' . ucfirst(strtolower($v)), $v); + $type[$k] = _t(__CLASS__ .'.' . ucfirst(strtolower($v)), $v); } /** @@ -80,11 +80,11 @@ class BlogArchiveWidget extends Widget $fields->merge(array( DropdownField::create( 'BlogID', - _t('BlogArchiveWidget.Blog', 'Blog'), + _t(__CLASS__ . '.Blog', 'Blog'), Blog::get()->map() ), - DropdownField::create('ArchiveType', _t('BlogArchiveWidget.ArchiveType', 'ArchiveType'), $type), - NumericField::create('NumberToDisplay', _t('BlogArchiveWidget.NumberToDisplay', 'No. to Display')) + DropdownField::create('ArchiveType', _t(__CLASS__ . '.ArchiveType', 'ArchiveType'), $type), + NumericField::create('NumberToDisplay', _t(__CLASS__ . '.NumberToDisplay', 'No. to Display')) )); }); diff --git a/src/Widgets/BlogCategoriesWidget.php b/src/Widgets/BlogCategoriesWidget.php index 63de4fc..14a9d86 100644 --- a/src/Widgets/BlogCategoriesWidget.php +++ b/src/Widgets/BlogCategoriesWidget.php @@ -11,6 +11,7 @@ use SilverStripe\Core\Convert; use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\NumericField; +use SilverStripe\ORM\DataList; use SilverStripe\Widgets\Model\Widget; /** @@ -57,18 +58,18 @@ class BlogCategoriesWidget extends Widget $this->beforeUpdateCMSFields(function (FieldList $fields) { $fields[] = DropdownField::create( 'BlogID', - _t('BlogCategoriesWidget.Blog', 'Blog'), + _t(__CLASS__ . '.Blog', 'Blog'), Blog::get()->map() ); $fields[] = NumericField::create( 'Limit', - _t('BlogCategoriesWidget.Limit', 'Limit'), + _t(__CLASS__ . '.Limit', 'Limit'), 0 ) ->setDescription( _t( - 'BlogCategoriesWidget.Limit_Description', + __CLASS__ . '.Limit_Description', 'Limit the number of categories shown by this widget (set to 0 to show all categories).' ) ) @@ -76,21 +77,21 @@ class BlogCategoriesWidget extends Widget $fields[] = DropdownField::create( 'Order', - _t('BlogCategoriesWidget.Sort', 'Sort'), + _t(__CLASS__ . '.Sort', 'Sort'), array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated') ) ->setDescription( - _t('BlogCategoriesWidget.Sort_Description', 'Change the order of categories shown by this widget.') + _t(__CLASS__ . '.Sort_Description', 'Change the order of categories shown by this widget.') ); $fields[] = DropdownField::create( 'Direction', - _t('BlogCategoriesWidget.Direction', 'Direction'), + _t(__CLASS__ . '.Direction', 'Direction'), array('ASC' => 'Ascending', 'DESC' => 'Descending') ) ->setDescription( _t( - 'BlogCategoriesWidget.Direction_Description', + __CLASS__ . '.Direction_Description', 'Change the direction of ordering of categories shown by this widget.' ) ); diff --git a/src/Widgets/BlogRecentPostsWidget.php b/src/Widgets/BlogRecentPostsWidget.php index f85d9e0..cf2a3e2 100644 --- a/src/Widgets/BlogRecentPostsWidget.php +++ b/src/Widgets/BlogRecentPostsWidget.php @@ -57,8 +57,8 @@ class BlogRecentPostsWidget extends Widget * @var FieldList $fields */ $fields->merge(array( - DropdownField::create('BlogID', _t('BlogRecentPostsWidget.Blog', 'Blog'), Blog::get()->map()), - NumericField::create('NumberOfPosts', _t('BlogRecentPostsWidget.NumberOfPosts', 'Number of Posts')) + DropdownField::create('BlogID', _t(__CLASS__ . '.Blog', 'Blog'), Blog::get()->map()), + NumericField::create('NumberOfPosts', _t(__CLASS__ . '.NumberOfPosts', 'Number of Posts')) )); }); diff --git a/src/Widgets/BlogTagsCloudWidget.php b/src/Widgets/BlogTagsCloudWidget.php index fb8ca6b..907ce2a 100644 --- a/src/Widgets/BlogTagsCloudWidget.php +++ b/src/Widgets/BlogTagsCloudWidget.php @@ -58,7 +58,7 @@ class BlogTagsCloudWidget extends Widget $fields->push( DropdownField::create( 'BlogID', - _t('BlogTagsCloudWidget.Blog', 'Blog'), + _t(__CLASS__ . '.Blog', 'Blog'), Blog::get()->map() ) ); diff --git a/src/Widgets/BlogTagsWidget.php b/src/Widgets/BlogTagsWidget.php index fe9f092..e7fc743 100644 --- a/src/Widgets/BlogTagsWidget.php +++ b/src/Widgets/BlogTagsWidget.php @@ -57,18 +57,18 @@ class BlogTagsWidget extends Widget $this->beforeUpdateCMSFields(function (Fieldlist $fields) { $fields[] = DropdownField::create( 'BlogID', - _t('BlogTagsWidget.Blog', 'Blog'), + _t(__CLASS__ . '.Blog', 'Blog'), Blog::get()->map() ); $fields[] = NumericField::create( 'Limit', - _t('BlogTagsWidget.Limit', 'Limit'), + _t(__CLASS__ . '.Limit', 'Limit'), 0 ) ->setDescription( _t( - 'BlogTagsWidget.Limit_Description', + __CLASS__ . '.Limit_Description', 'Limit the number of tags shown by this widget (set to 0 to show all tags).' ) ) @@ -76,21 +76,21 @@ class BlogTagsWidget extends Widget $fields[] = DropdownField::create( 'Order', - _t('BlogTagsWidget.Sort', 'Sort'), + _t(__CLASS__ . '.Sort', 'Sort'), array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated') ) ->setDescription( - _t('BlogTagsWidget.Sort_Description', 'Change the order of tags shown by this widget.') + _t(__CLASS__ . '.Sort_Description', 'Change the order of tags shown by this widget.') ); $fields[] = DropdownField::create( 'Direction', - _t('BlogTagsWidget.Direction', 'Direction'), + _t(__CLASS__ . '.Direction', 'Direction'), array('ASC' => 'Ascending', 'DESC' => 'Descending') ) ->setDescription( _t( - 'BlogTagsWidget.Direction_Description', + __CLASS__ . '.Direction_Description', 'Change the direction of ordering of tags shown by this widget.' ) );