Skip to content
This repository
Browse code

MINOR Using new DataObject::fieldLabels() caching in SiteTree

  • Loading branch information...
commit d9c4aa8583670e9fbe22cdeb96510f1373727e2e 1 parent 81d7d84
Ingo Schommer authored April 13, 2012

Showing 1 changed file with 37 additions and 33 deletions. Show diff stats Hide diff stats

  1. 70  code/model/SiteTree.php
70  code/model/SiteTree.php
@@ -1984,40 +1984,44 @@ function getSettingsFields() {
1984 1984
 	 * 
1985 1985
 	 */
1986 1986
 	function fieldLabels($includerelations = true) {
1987  
-		$labels = parent::fieldLabels($includerelations);
1988  
-		
1989  
-		$labels['Title'] = _t('SiteTree.PAGETITLE', "Page name");
1990  
-		$labels['MenuTitle'] = _t('SiteTree.MENUTITLE', "Navigation label");
1991  
-		$labels['MetaTitle'] = _t('SiteTree.METATITLE', "Meta Title");
1992  
-		$labels['MetaDescription'] = _t('SiteTree.METADESC', "Meta Description");
1993  
-		$labels['MetaKeywords'] = _t('SiteTree.METAKEYWORDS', "Meta Keywords");
1994  
-		$labels['ExtraMeta'] = _t('SiteTree.METAEXTRA', "Custom Meta Tags");
1995  
-		$labels['ClassName'] = _t('SiteTree.PAGETYPE', "Page type", PR_MEDIUM, 'Classname of a page object');
1996  
-		$labels['ParentType'] = _t('SiteTree.PARENTTYPE', "Page location", PR_MEDIUM);
1997  
-		$labels['ParentID'] = _t('SiteTree.PARENTID', "Parent page", PR_MEDIUM);
1998  
-		$labels['ShowInMenus'] =_t('SiteTree.SHOWINMENUS', "Show in menus?");
1999  
-		$labels['ShowInSearch'] = _t('SiteTree.SHOWINSEARCH', "Show in search?");
2000  
-		$labels['ProvideComments'] = _t('SiteTree.ALLOWCOMMENTS', "Allow comments on this page?");
2001  
-		$labels['ViewerGroups'] = _t('SiteTree.VIEWERGROUPS', "Viewer Groups");
2002  
-		$labels['EditorGroups'] = _t('SiteTree.EDITORGROUPS', "Editor Groups");
2003  
-		$labels['URLSegment'] = _t('SiteTree.URLSegment', 'URL Segment', PR_MEDIUM, 'URL for this page');
2004  
-		$labels['Content'] = _t('SiteTree.Content', 'Content', PR_MEDIUM, 'Main HTML Content for a page');
2005  
-		$labels['CanViewType'] = _t('SiteTree.Viewers', 'Viewers Groups');
2006  
-		$labels['CanEditType'] = _t('SiteTree.Editors', 'Editors Groups');
2007  
-		$labels['Comments'] = _t('SiteTree.Comments', 'Comments');
2008  
-		$labels['Visibility'] = _t('SiteTree.Visibility', 'Visibility');
2009  
-		$labels['LinkChangeNote'] = _t (
2010  
-			'SiteTree.LINKCHANGENOTE', 'Changing this page\'s link will also affect the links of all child pages.'
2011  
-		);
2012  
-		
2013  
-		if($includerelations){
2014  
-			$labels['Parent'] = _t('SiteTree.has_one_Parent', 'Parent Page', PR_MEDIUM, 'The parent page in the site hierarchy');
2015  
-			$labels['LinkTracking'] = _t('SiteTree.many_many_LinkTracking', 'Link Tracking');
2016  
-			$labels['ImageTracking'] = _t('SiteTree.many_many_ImageTracking', 'Image Tracking');
2017  
-			$labels['BackLinkTracking'] = _t('SiteTree.many_many_BackLinkTracking', 'Backlink Tracking');
  1987
+		$cacheKey = $this->class . '_' . $includerelations;
  1988
+		if(!isset(self::$_cache_field_labels[$cacheKey])) {
  1989
+			$labels = parent::fieldLabels($includerelations);
  1990
+			$labels['Title'] = _t('SiteTree.PAGETITLE', "Page name");
  1991
+			$labels['MenuTitle'] = _t('SiteTree.MENUTITLE', "Navigation label");
  1992
+			$labels['MetaTitle'] = _t('SiteTree.METATITLE', "Meta Title");
  1993
+			$labels['MetaDescription'] = _t('SiteTree.METADESC', "Meta Description");
  1994
+			$labels['MetaKeywords'] = _t('SiteTree.METAKEYWORDS', "Meta Keywords");
  1995
+			$labels['ExtraMeta'] = _t('SiteTree.METAEXTRA', "Custom Meta Tags");
  1996
+			$labels['ClassName'] = _t('SiteTree.PAGETYPE', "Page type", PR_MEDIUM, 'Classname of a page object');
  1997
+			$labels['ParentType'] = _t('SiteTree.PARENTTYPE', "Page location", PR_MEDIUM);
  1998
+			$labels['ParentID'] = _t('SiteTree.PARENTID', "Parent page", PR_MEDIUM);
  1999
+			$labels['ShowInMenus'] =_t('SiteTree.SHOWINMENUS', "Show in menus?");
  2000
+			$labels['ShowInSearch'] = _t('SiteTree.SHOWINSEARCH', "Show in search?");
  2001
+			$labels['ProvideComments'] = _t('SiteTree.ALLOWCOMMENTS', "Allow comments on this page?");
  2002
+			$labels['ViewerGroups'] = _t('SiteTree.VIEWERGROUPS', "Viewer Groups");
  2003
+			$labels['EditorGroups'] = _t('SiteTree.EDITORGROUPS', "Editor Groups");
  2004
+			$labels['URLSegment'] = _t('SiteTree.URLSegment', 'URL Segment', PR_MEDIUM, 'URL for this page');
  2005
+			$labels['Content'] = _t('SiteTree.Content', 'Content', PR_MEDIUM, 'Main HTML Content for a page');
  2006
+			$labels['CanViewType'] = _t('SiteTree.Viewers', 'Viewers Groups');
  2007
+			$labels['CanEditType'] = _t('SiteTree.Editors', 'Editors Groups');
  2008
+			$labels['Comments'] = _t('SiteTree.Comments', 'Comments');
  2009
+			$labels['Visibility'] = _t('SiteTree.Visibility', 'Visibility');
  2010
+			$labels['LinkChangeNote'] = _t (
  2011
+				'SiteTree.LINKCHANGENOTE', 'Changing this page\'s link will also affect the links of all child pages.'
  2012
+			);
  2013
+			
  2014
+			if($includerelations){
  2015
+				$labels['Parent'] = _t('SiteTree.has_one_Parent', 'Parent Page', PR_MEDIUM, 'The parent page in the site hierarchy');
  2016
+				$labels['LinkTracking'] = _t('SiteTree.many_many_LinkTracking', 'Link Tracking');
  2017
+				$labels['ImageTracking'] = _t('SiteTree.many_many_ImageTracking', 'Image Tracking');
  2018
+				$labels['BackLinkTracking'] = _t('SiteTree.many_many_BackLinkTracking', 'Backlink Tracking');
  2019
+			}
  2020
+
  2021
+			self::$_cache_field_labels[$cacheKey] = $labels;
2018 2022
 		}
2019  
-				
2020  
-		return $labels;
  2023
+
  2024
+		return self::$_cache_field_labels[$cacheKey];
2021 2025
 	}
2022 2026
 
2023 2027
 	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 notes on commit d9c4aa8

Please sign in to comment.
Something went wrong with that request. Please try again.