From 4e11307eaec819229bd98a07e2700e813a2aad80 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 8 Jan 2009 01:39:59 +0000 Subject: [PATCH] BUGFIX Fixed $add_action behaviour for SiteTree classes (through i18n_singular_name() method). Deprecated in favour of ".TITLE" entity to enable localized page titles. Limited add_action behaviour to SiteTree (was implemented on DataObject before) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@69878 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/DataObject.php | 3 +-- core/model/SiteTree.php | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 4dc8cff82..ab4704a8a 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -293,8 +293,7 @@ class DataObject extends ViewableData implements DataObjectInterface,i18nEntityP * @return string User friendly translated singular name of this DataObject */ function i18n_singular_name() { - $name = (!empty($this->add_action)) ? $this->add_action : $this->singular_name(); - return _t($this->class.'.SINGULARNAME', $name); + return _t($this->class.'.SINGULARNAME', $this->singular_name()); } /** diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index fd6367ecc..e3bd9e5b2 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -138,6 +138,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid /** * The text shown in the create page dropdown. If * this is not set, default to "Create a ClassName". + * + * @deprecated 2.3 Use ".TITLE" in the i18n language tables instead * @var string */ static $add_action = null; @@ -1763,6 +1765,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid ); } + function i18n_singular_name() { + $addAction = $this->stat('add_action'); + $name = (!empty($addAction)) ? $addAction : $this->singular_name(); + return _t($this->class.'.SINGULARNAME', $name); + } + /** * Overloaded to also provide entities for 'Page' class which is usually * located in custom code, hence textcollector picks it up for the wrong folder.