From d9c4aa8583670e9fbe22cdeb96510f1373727e2e Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 13 Apr 2012 18:38:57 +0200 Subject: [PATCH] MINOR Using new DataObject::fieldLabels() caching in SiteTree --- code/model/SiteTree.php | 70 ++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index 2cd9603f..f9b0d4a0 100644 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -1984,40 +1984,44 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * */ function fieldLabels($includerelations = true) { - $labels = parent::fieldLabels($includerelations); - - $labels['Title'] = _t('SiteTree.PAGETITLE', "Page name"); - $labels['MenuTitle'] = _t('SiteTree.MENUTITLE', "Navigation label"); - $labels['MetaTitle'] = _t('SiteTree.METATITLE', "Meta Title"); - $labels['MetaDescription'] = _t('SiteTree.METADESC', "Meta Description"); - $labels['MetaKeywords'] = _t('SiteTree.METAKEYWORDS', "Meta Keywords"); - $labels['ExtraMeta'] = _t('SiteTree.METAEXTRA', "Custom Meta Tags"); - $labels['ClassName'] = _t('SiteTree.PAGETYPE', "Page type", PR_MEDIUM, 'Classname of a page object'); - $labels['ParentType'] = _t('SiteTree.PARENTTYPE', "Page location", PR_MEDIUM); - $labels['ParentID'] = _t('SiteTree.PARENTID', "Parent page", PR_MEDIUM); - $labels['ShowInMenus'] =_t('SiteTree.SHOWINMENUS', "Show in menus?"); - $labels['ShowInSearch'] = _t('SiteTree.SHOWINSEARCH', "Show in search?"); - $labels['ProvideComments'] = _t('SiteTree.ALLOWCOMMENTS', "Allow comments on this page?"); - $labels['ViewerGroups'] = _t('SiteTree.VIEWERGROUPS', "Viewer Groups"); - $labels['EditorGroups'] = _t('SiteTree.EDITORGROUPS', "Editor Groups"); - $labels['URLSegment'] = _t('SiteTree.URLSegment', 'URL Segment', PR_MEDIUM, 'URL for this page'); - $labels['Content'] = _t('SiteTree.Content', 'Content', PR_MEDIUM, 'Main HTML Content for a page'); - $labels['CanViewType'] = _t('SiteTree.Viewers', 'Viewers Groups'); - $labels['CanEditType'] = _t('SiteTree.Editors', 'Editors Groups'); - $labels['Comments'] = _t('SiteTree.Comments', 'Comments'); - $labels['Visibility'] = _t('SiteTree.Visibility', 'Visibility'); - $labels['LinkChangeNote'] = _t ( - 'SiteTree.LINKCHANGENOTE', 'Changing this page\'s link will also affect the links of all child pages.' - ); - - if($includerelations){ - $labels['Parent'] = _t('SiteTree.has_one_Parent', 'Parent Page', PR_MEDIUM, 'The parent page in the site hierarchy'); - $labels['LinkTracking'] = _t('SiteTree.many_many_LinkTracking', 'Link Tracking'); - $labels['ImageTracking'] = _t('SiteTree.many_many_ImageTracking', 'Image Tracking'); - $labels['BackLinkTracking'] = _t('SiteTree.many_many_BackLinkTracking', 'Backlink Tracking'); + $cacheKey = $this->class . '_' . $includerelations; + if(!isset(self::$_cache_field_labels[$cacheKey])) { + $labels = parent::fieldLabels($includerelations); + $labels['Title'] = _t('SiteTree.PAGETITLE', "Page name"); + $labels['MenuTitle'] = _t('SiteTree.MENUTITLE', "Navigation label"); + $labels['MetaTitle'] = _t('SiteTree.METATITLE', "Meta Title"); + $labels['MetaDescription'] = _t('SiteTree.METADESC', "Meta Description"); + $labels['MetaKeywords'] = _t('SiteTree.METAKEYWORDS', "Meta Keywords"); + $labels['ExtraMeta'] = _t('SiteTree.METAEXTRA', "Custom Meta Tags"); + $labels['ClassName'] = _t('SiteTree.PAGETYPE', "Page type", PR_MEDIUM, 'Classname of a page object'); + $labels['ParentType'] = _t('SiteTree.PARENTTYPE', "Page location", PR_MEDIUM); + $labels['ParentID'] = _t('SiteTree.PARENTID', "Parent page", PR_MEDIUM); + $labels['ShowInMenus'] =_t('SiteTree.SHOWINMENUS', "Show in menus?"); + $labels['ShowInSearch'] = _t('SiteTree.SHOWINSEARCH', "Show in search?"); + $labels['ProvideComments'] = _t('SiteTree.ALLOWCOMMENTS', "Allow comments on this page?"); + $labels['ViewerGroups'] = _t('SiteTree.VIEWERGROUPS', "Viewer Groups"); + $labels['EditorGroups'] = _t('SiteTree.EDITORGROUPS', "Editor Groups"); + $labels['URLSegment'] = _t('SiteTree.URLSegment', 'URL Segment', PR_MEDIUM, 'URL for this page'); + $labels['Content'] = _t('SiteTree.Content', 'Content', PR_MEDIUM, 'Main HTML Content for a page'); + $labels['CanViewType'] = _t('SiteTree.Viewers', 'Viewers Groups'); + $labels['CanEditType'] = _t('SiteTree.Editors', 'Editors Groups'); + $labels['Comments'] = _t('SiteTree.Comments', 'Comments'); + $labels['Visibility'] = _t('SiteTree.Visibility', 'Visibility'); + $labels['LinkChangeNote'] = _t ( + 'SiteTree.LINKCHANGENOTE', 'Changing this page\'s link will also affect the links of all child pages.' + ); + + if($includerelations){ + $labels['Parent'] = _t('SiteTree.has_one_Parent', 'Parent Page', PR_MEDIUM, 'The parent page in the site hierarchy'); + $labels['LinkTracking'] = _t('SiteTree.many_many_LinkTracking', 'Link Tracking'); + $labels['ImageTracking'] = _t('SiteTree.many_many_ImageTracking', 'Image Tracking'); + $labels['BackLinkTracking'] = _t('SiteTree.many_many_BackLinkTracking', 'Backlink Tracking'); + } + + self::$_cache_field_labels[$cacheKey] = $labels; } - - return $labels; + + return self::$_cache_field_labels[$cacheKey]; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////