From 6aefb2e09fbdad0f3e74f54e916fc7e08d704d33 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Fri, 29 May 2015 15:52:14 +1200 Subject: [PATCH] BUG Fix compat with userforms/translatable --- code/model/Translatable.php | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/code/model/Translatable.php b/code/model/Translatable.php index 5abdde2..5a6d358 100755 --- a/code/model/Translatable.php +++ b/code/model/Translatable.php @@ -211,6 +211,21 @@ class Translatable extends DataExtension implements PermissionProvider { * or URL path prefixes like "/en/mypage". */ private static $enforce_global_unique_urls = true; + + /** + * Exclude these fields from translation + * + * @var array + * @config + */ + private static $translate_excluded_fields = array( + 'ViewerGroups', + 'EditorGroups', + 'CanViewType', + 'CanEditType', + 'NewTransLang', + 'createtranslation' + ); /** * Reset static configuration variables to their default values @@ -1149,16 +1164,9 @@ protected function addTranslatableFields(&$fields) { if(is_a($this->owner, $excludedPageType)) return; } } - - // TODO Remove hardcoding for SiteTree properties - $excludeFields = array( - 'ViewerGroups', - 'EditorGroups', - 'CanViewType', - 'CanEditType', - 'NewTransLang', - 'createtranslation' - ); + + // Get excluded fields from translation + $excludeFields = $this->owner->config()->translate_excluded_fields; // if a language other than default language is used, we're in "translation mode", // hence have to modify the original fields