diff --git a/code/SubsiteReportWrapper.php b/code/SubsiteReportWrapper.php index a229e19..2774cfc 100644 --- a/code/SubsiteReportWrapper.php +++ b/code/SubsiteReportWrapper.php @@ -12,7 +12,11 @@ class SubsiteReportWrapper extends SS_ReportWrapper { $subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain', true); $options = $subsites->toDropdownMap('ID', 'Title'); - $subsiteField = new TreeMultiselectField('Subsites', 'Sites', $options); + $subsiteField = new TreeMultiselectField( + 'Subsites', + _t('SubsiteReportWrapper.ReportDropdown', 'Sites'), + $options + ); $subsiteField->setValue(array_keys($options)); // We don't need to make the field editable if only one subsite is available diff --git a/code/SubsitesVirtualPage.php b/code/SubsitesVirtualPage.php index 5d78a3b..5d8831c 100644 --- a/code/SubsitesVirtualPage.php +++ b/code/SubsitesVirtualPage.php @@ -24,7 +24,7 @@ class SubsitesVirtualPage extends VirtualPage { $subsiteSelectionField = new DropdownField( "CopyContentFromID_SubsiteID", - "Subsite", + _t('SubsitesVirtualPage.SubsiteField',"Subsite"), $subsites->map('ID', 'Title'), ($this->CopyContentFromID) ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID') ); @@ -66,13 +66,51 @@ class SubsitesVirtualPage extends VirtualPage { } - $fields->addFieldToTab('Root.Main', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle'); - $fields->addFieldToTab('Root.Main', new TextareaField('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords'); - $fields->addFieldToTab('Root.Main', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription'); - $fields->addFieldToTab('Root.Main', new TextField('CustomExtraMeta', 'Custom Meta Tags (overrides inherited value from the source)'), 'ExtraMeta'); + $fields->addFieldToTab( + 'Root.Main', + TextField::create( + 'CustomMetaTitle', + $this->fieldLabel('CustomMetaTitle') + )->setDescription(_t('SubsitesVirtualPage.OverrideNote', 'Overrides inherited value from the source')), + 'MetaTitle' + ); + $fields->addFieldToTab( + 'Root.Main', + TextareaField::create( + 'CustomMetaKeywords', + $this->fieldLabel('CustomMetaTitle') + )->setDescription(_t('SubsitesVirtualPage.OverrideNote')), + 'MetaKeywords' + ); + $fields->addFieldToTab( + 'Root.Main', + TextareaField::create( + 'CustomMetaDescription', + $this->fieldLabel('CustomMetaTitle') + )->setDescription(_t('SubsitesVirtualPage.OverrideNote')), + 'MetaDescription' + ); + $fields->addFieldToTab( + 'Root.Main', + TextField::create( + 'CustomExtraMeta', + $this->fieldLabel('CustomMetaTitle') + )->setDescription(_t('SubsitesVirtualPage.OverrideNote')), + 'ExtraMeta' + ); return $fields; } + + public function fieldLabels($includerelations = true) { + $labels = parent::fieldLabels($includerelations); + $labels['CustomMetaTitle'] = _t('Subsite.CustomMetaTitle','Title'); + $labels['CustomMetaKeywords'] = _t('Subsite.CustomMetaKeywords','Keywords'); + $labels['CustomMetaDescription'] = _t('Subsite.CustomMetaDescription','Description'); + $labels['CustomExtraMeta'] = _t('Subsite.CustomExtraMeta','Custom Meta Tags'); + + return $labels; + } public function getVirtualFields() { $fields = parent::getVirtualFields(); diff --git a/code/extensions/FileSubsites.php b/code/extensions/FileSubsites.php index 85e0d26..0c5a438 100644 --- a/code/extensions/FileSubsites.php +++ b/code/extensions/FileSubsites.php @@ -30,21 +30,26 @@ class FileSubsites extends DataExtension { if($this->owner instanceof Folder) { $sites = Subsite::accessible_sites('CMS_ACCESS_AssetAdmin'); $values = array(); - $values[0] = 'All sites'; + $values[0] = _t('FileSubsites.AllSitesDropdownOpt','All sites'); foreach ($sites as $site) { $values[$site->ID] = $site->Title; } ksort($values); if($sites){ //Dropdown needed to move folders between subsites - $fields->push($dropdown = new DropdownField('SubsiteID', 'Subsite', $values)); + $dropdown = new DropdownField( + 'SubsiteID', + _t('FileSubsites.SubsiteFieldLabel','Subsite'), + $values + ); + $dropdown->addExtraClass('subsites-move-dropdown'); + $fields->push($dropdown); $fields->push(new LiteralField( 'Message', '

'. _t('ASSETADMIN.SUBSITENOTICE', 'Folders and files created in the main site are accessible by all subsites.') .'

' )); - $dropdown->addExtraClass('subsites-move-dropdown'); } } } diff --git a/code/extensions/GroupSubsites.php b/code/extensions/GroupSubsites.php index fcadc1f..a852742 100644 --- a/code/extensions/GroupSubsites.php +++ b/code/extensions/GroupSubsites.php @@ -93,7 +93,8 @@ class GroupSubsites extends DataExtension implements PermissionProvider { */ function alternateTreeTitle() { if($this->owner->AccessAllSubsites) { - return htmlspecialchars($this->owner->Title, ENT_QUOTES) . ' (global group)'; + $title = _t('GroupSubsites.GlobalGroup', 'global group'); + return htmlspecialchars($this->owner->Title, ENT_QUOTES) . ' (' . $title . ')'; } else { $subsites = Convert::raw2xml(implode(", ", $this->owner->Subsites()->column('Title'))); return htmlspecialchars($this->owner->Title) . " ($subsites)"; diff --git a/code/extensions/LeftAndMainSubsites.php b/code/extensions/LeftAndMainSubsites.php index ee50f76..acf503f 100644 --- a/code/extensions/LeftAndMainSubsites.php +++ b/code/extensions/LeftAndMainSubsites.php @@ -40,6 +40,10 @@ class LeftAndMainSubsites extends Extension { * @return ArrayList of {@link Subsite} instances. */ function sectionSites($includeMainSite = true, $mainSiteTitle = "Main site", $member = null) { + if($mainSiteTitle == 'Main site') { + $mainSiteTitle = _t('Subsites.MainSiteTitle', 'Main site'); + } + // Rationalise member arguments if(!$member) $member = Member::currentUser(); if(!$member) return new ArrayList(); diff --git a/code/extensions/SiteTreeSubsites.php b/code/extensions/SiteTreeSubsites.php index ac3e96e..a1cda6e 100644 --- a/code/extensions/SiteTreeSubsites.php +++ b/code/extensions/SiteTreeSubsites.php @@ -112,8 +112,8 @@ class SiteTreeSubsites extends DataExtension { if(!$sc) { $sc = new SiteConfig(); $sc->SubsiteID = $this->owner->SubsiteID; - $sc->Title = 'Your Site Name'; - $sc->Tagline = 'your tagline here'; + $sc->Title = _t('Subsite.SiteConfigTitle','Your Site Name'); + $sc->Tagline = _t('Subsite.SiteConfigSubtitle','Your tagline here'); $sc->write(); } return $sc; diff --git a/code/model/Subsite.php b/code/model/Subsite.php index 6f3a92d..7eb1e74 100644 --- a/code/model/Subsite.php +++ b/code/model/Subsite.php @@ -63,23 +63,11 @@ class Subsite extends DataObject implements PermissionProvider { ); private static $searchable_fields = array( - 'Title' => array( - 'title' => 'Subsite Name' - ), - 'Domains.Domain' => array( - 'title' => 'Domain name' - ), - 'IsPublic' => array( - 'title' => 'Active subsite', - ), + 'Title', + 'Domains.Domain', + 'IsPublic', ); - private static $summary_fields = array( - 'Title' => 'Subsite Name', - 'PrimaryDomain' => 'Primary Domain', - 'IsPublic' => 'Active subsite', - ); - /** * Memory cache of accessible sites */ @@ -204,12 +192,24 @@ class Subsite extends DataObject implements PermissionProvider { */ function getCMSFields() { if($this->ID!=0) { - $domainTable = new GridField("Domains", "Domains", $this->Domains(), GridFieldConfig_RecordEditor::create(10)); + $domainTable = new GridField( + "Domains", + _t('Subsite.DomainsListTitle',"Domains"), + $this->Domains(), + GridFieldConfig_RecordEditor::create(10) + ); }else { - $domainTable = new LiteralField('Domains', '

'._t('Subsite.DOMAINSAVEFIRST', 'You can only add domains after saving for the first time').'

'); + $domainTable = new LiteralField( + 'Domains', + '

'._t('Subsite.DOMAINSAVEFIRST', 'You can only add domains after saving for the first time').'

' + ); } - $languageSelector = new DropdownField('Language', 'Language', i18n::get_common_locales()); + $languageSelector = new DropdownField( + 'Language', + $this->fieldLabel('Language'), + i18n::get_common_locales() + ); $pageTypeMap = array(); $pageTypes = SiteTree::page_type_classes(); @@ -220,18 +220,22 @@ class Subsite extends DataObject implements PermissionProvider { $fields = new FieldList( $subsiteTabs = new TabSet('Root', - new Tab('Configuration', + new Tab( + 'Configuration', + _t('Subsite.TabTitleConfig', 'Configuration'), new HeaderField($this->getClassName() . ' configuration', 2), - new TextField('Title', 'Name of subsite:', $this->Title), + new TextField('Title', $this->fieldLabel('Title'), $this->Title), - new HeaderField("Domains for this subsite"), + new HeaderField( + _t('Subsite.DomainsHeadline',"Domains for this subsite") + ), $domainTable, $languageSelector, // new TextField('RedirectURL', 'Redirect to URL', $this->RedirectURL), - new CheckboxField('DefaultSite', 'Default site', $this->DefaultSite), - new CheckboxField('IsPublic', 'Enable public access', $this->IsPublic), + new CheckboxField('DefaultSite', $this->fieldLabel('DefaultSite'), $this->DefaultSite), + new CheckboxField('IsPublic', $this->fieldLabel('IsPublic'), $this->IsPublic), - new DropdownField('Theme','Theme', $this->allowedThemes(), $this->Theme), + new DropdownField('Theme',$this->fieldLabel('Theme'), $this->allowedThemes(), $this->Theme), new LiteralField( @@ -258,6 +262,29 @@ class Subsite extends DataObject implements PermissionProvider { return $fields; } + public function fieldLabels($includerelations = true) { + $labels = parent::fieldLabels($includerelations); + $labels['Title'] = _t('Subsites.TitleFieldLabel', 'Subsite Name'); + $labels['RedirectURL'] = _t('Subsites.RedirectURLFieldLabel', 'Redirect URL'); + $labels['DefaultSite'] = _t('Subsites.DefaultSiteFieldLabel', 'Default site'); + $labels['Theme'] = _t('Subsites.ThemeFieldLabel', 'Theme'); + $labels['Language'] = _t('Subsites.LanguageFieldLabel', 'Language'); + $labels['IsPublic'] = _t('Subsites.IsPublicFieldLabel', 'Enable public access'); + $labels['PageTypeBlacklist'] = _t('Subsites.PageTypeBlacklistFieldLabel', 'Page Type Blacklist'); + $labels['Domains.Domain'] = _t('Subsites.DomainFieldLabel', 'Domain'); + $labels['PrimaryDomain'] = _t('Subsites.PrimaryDomainFieldLabel', 'Primary Domain'); + + return $labels; + } + + public function summaryFields() { + return array( + 'Title' => $this->fieldLabel('Title'), + 'PrimaryDomain' => $this->fieldLabel('PrimaryDomain'), + 'IsPublic' => _t('Subsite.IsPublicHeaderField','Active subsite'), + ); + } + /** * @todo getClassName is redundant, already stored as a database field? */ @@ -267,15 +294,25 @@ class Subsite extends DataObject implements PermissionProvider { function getCMSActions() { return new FieldList( - new FormAction('callPageMethod', "Create copy", null, 'adminDuplicate') + new FormAction( + 'callPageMethod', + _t('Subsite.ButtonLabelCopy',"Create copy"), + null, + 'adminDuplicate' + ) ); } function adminDuplicate() { $newItem = $this->duplicate(); - $JS_title = Convert::raw2js($this->Title); + $message = _t( + 'Subsite.CopyMessage', + 'Created a copy of {title}', + array('title' => Convert::raw2js($this->Title)) + ); + return <<ID'); JS; } diff --git a/code/model/SubsiteDomain.php b/code/model/SubsiteDomain.php index 0ba1677..8714c04 100644 --- a/code/model/SubsiteDomain.php +++ b/code/model/SubsiteDomain.php @@ -12,8 +12,8 @@ class SubsiteDomain extends DataObject { ); private static $summary_fields=array( - 'Domain'=>'Domain', - 'IsPrimary'=>'Is Primary Domain' + 'Domain', + 'IsPrimary', ); /** @@ -27,8 +27,16 @@ class SubsiteDomain extends DataObject { public function getCMSFields() { return new FieldList( - new TextField('Domain', _t('SubsiteDomain.DOMAIN', 'Domain'), null, 255), - new CheckboxField('IsPrimary', _t('SubsiteDomain.IS_PRIMARY', 'Is Primary Domain')) + new TextField('Domain', $this->fieldLabel('Domain'), null, 255), + new CheckboxField('IsPrimary', $this->fieldLabel('IsPrimary')) ); } + + public function fieldLabels($includerelations = true) { + $labels = parent::fieldLabels($includerelations); + $labels['Domain'] = _t('SubsiteDomain.DOMAIN', 'Domain'); + $labels['IsPrimary'] = _t('SubsiteDomain.IS_PRIMARY', 'Is Primary Domain'); + + return $labels; + } } diff --git a/lang/en.yml b/lang/en.yml index 477f7d3..e7bbe8c 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -1,39 +1,81 @@ en: - SubsiteAdmin: - MENUTITLE: "Subsites" - GroupSubsites: - ACCESSALL: "All subsites" - ACCESSONLY: "Only these subsites" - ACCESSRADIOTITLE: "Give this group access to" - SECURITYTABTITLE: "Subsites" - ModelAdmin: - LOADEDFOREDITING: "Loaded \'%s\' for editing." - RelatedPageLink: - PLURALNAME: "Related Page Links" - SINGULARNAME: "Related Page Link" - Subsite: - PLURALNAME: "Subsits" - SINGULARNAME: "Subsite" - DOMAINSAVEFIRST: "You can only add domains after saving for the first time" - SubsiteDomain: - PLURALNAME: "Subsite Domains" - SINGULARNAME: "Subsite Domain" - DOMAIN: "Domain" - IS_PRIMARY: "Is Primary Domain" - Subsite_Template: - PLURALNAME: "Subsite Templats" - SINGULARNAME: "Subsite Template" - SubsitesVirtualPage: - PLURALNAME: "Subsites Virtual Pags" - SINGULARNAME: "Subsites Virtual Page" - VirtualPage: - CHOOSE: "Choose a page to link to" - EDITCONTENT: "Click here to edit the content" - GridFieldAddFromTemplateButton: - AddFromTemplate: "Add New from Template" - GridFieldAddFromTemplate: - NewFromTemplate: "New %s from template" - TEMPLATE_NOT_FOUND: "The selected template could not be found" - TEMPLATE: "Template" - LeftAndMainSubsites: - DEFAULT_SITE: "Default Site" + SubsiteAdmin: + MENUTITLE: Subsites + SubsiteXHRController: + MENUTITLE: SubsiteXHRController + ASSETADMIN: + SUBSITENOTICE: 'Folders and files created in the main site are accessible by all subsites.' + FileSubsites: + AllSitesDropdownOpt: 'All sites' + SubsiteFieldLabel: Subsite + GridFieldAddFromTemplateButton: + AddFromTemplate: 'Add New from Template' + GroupSubsites: + ACCESSALL: 'All subsites' + ACCESSONLY: 'Only these subsites' + ACCESSRADIOTITLE: 'Give this group access to' + GlobalGroup: 'global group' + MANAGE_SUBSITES: 'Manage subsites for groups' + MANAGE_SUBSITES_HELP: 'Ability to limit the permissions for a group to one or more subsites.' + SECURITYTABTITLE: Subsites + LeftAndMainSubsites: + Saved: 'Saved, please update related pages.' + LeftAndMain_Menu.ss: + Hello: Hi + LOGOUT: 'Log out' + Permissions: + PERMISSIONS_CATEGORY: 'Roles and access permissions' + SiteTree: + PLURALNAME: Pages + SINGULARNAME: Page + SiteTreeSubsites: + CopyAction: Copy + CopyToSubsite: 'Copy page to subsite' + Subsite: + ButtonLabelCopy: 'Create copy' + COPYSTRUCTURE: 'Copy structure from:' + CopyMessage: 'Created a copy of {title}' + CustomExtraMeta: 'Custom Meta Tags' + CustomMetaDescription: Description + CustomMetaKeywords: Keywords + CustomMetaTitle: Title + DOMAINSAVEFIRST: 'You can only add domains after saving for the first time' + DomainsHeadline: 'Domains for this subsite' + DomainsListTitle: Domains + IsPublicHeaderField: 'Active subsite' + MANAGE_ASSETS: 'Manage assets for subsites' + MANAGE_ASSETS_HELP: 'Ability to select the subsite to which an asset folder belongs. Requires "Access to Files & Images."' + NOTEMPLATE: 'No template' + PLURALNAME: Subsits + PageTypeBlacklistField: 'Disallow page types?' + SINGULARNAME: Subsite + SiteConfigSubtitle: 'Your tagline here' + SiteConfigTitle: 'Your Site Name' + TabTitleConfig: Configuration + ValidateTitle: 'Please add a "Title"' + SubsiteDomain: + DOMAIN: Domain + IS_PRIMARY: 'Is Primary Domain' + PLURALNAME: 'Subsite Domains' + SINGULARNAME: 'Subsite Domain' + SubsiteReportWrapper: + ReportDropdown: Sites + Subsites: + DefaultSiteFieldLabel: 'Default site' + DomainFieldLabel: Domain + IsPublicFieldLabel: 'Enable public access' + LanguageFieldLabel: Language + MainSiteTitle: 'Main site' + PageTypeBlacklistFieldLabel: 'Page Type Blacklist' + PrimaryDomainFieldLabel: 'Primary Domain' + RedirectURLFieldLabel: 'Redirect URL' + ThemeFieldLabel: Theme + TitleFieldLabel: 'Subsite Name' + SubsitesVirtualPage: + DESCRIPTION: 'Displays the content of a page on another subsite' + PLURALNAME: 'Base Pages' + SINGULARNAME: 'Subsites Virtual Page' + SubsiteField: Subsite + VirtualPage: + CHOOSE: 'Choose a page to link to' + EDITCONTENT: 'Click here to edit the content' diff --git a/templates/Includes/GridFieldAddFromTemplateButton.ss b/templates/Includes/GridFieldAddFromTemplateButton.ss index 069eda1..c89dfb3 100644 --- a/templates/Includes/GridFieldAddFromTemplateButton.ss +++ b/templates/Includes/GridFieldAddFromTemplateButton.ss @@ -1 +1 @@ -<% _t('GridFieldAddFromTemplateButton.AddFromTemplate', '_Add New from Template') %> \ No newline at end of file +<% _t('GridFieldAddFromTemplateButton.AddFromTemplate', 'Add New from Template') %> \ No newline at end of file diff --git a/tests/SubsiteAdminFunctionalTest.php b/tests/SubsiteAdminFunctionalTest.php index 57f445a..f5ea663 100644 --- a/tests/SubsiteAdminFunctionalTest.php +++ b/tests/SubsiteAdminFunctionalTest.php @@ -105,7 +105,6 @@ class SubsiteAdminFunctionalTest extends FunctionalTest { // Check forbidden site, on a section that's not allowed on any other subsite $this->getAndFollowAll("admin/assets/?SubsiteID=0"); $this->assertEquals(Subsite::currentSubsiteID(), $subsite1->ID, 'Is redirected to first permitted subsite.'); - var_dump($this->mainSession->lastUrl()); $this->assertNotRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'Is not denied access'); // Check the standalone XHR controller.