mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Fixed default locale setting in SiteTree_Live through Translatable->requireDefaultRecords()
BUGFIX Added translation groups for existing entries the first time Translatable is switched on through Translatable->requireDefaultRecords() (see #4051) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@76866 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
fdcaba515c
commit
9790c4832a
@ -529,10 +529,18 @@ class Translatable extends DataObjectDecorator {
|
||||
ClassInfo::baseDataClass($this->owner->class)
|
||||
))->column();
|
||||
if($idsWithoutLocale) {
|
||||
foreach(array('Stage', 'Live') as $stage) {
|
||||
foreach($idsWithoutLocale as $id) {
|
||||
$obj = DataObject::get_by_id($this->owner->class, $id);
|
||||
$obj = Versioned::get_one_by_stage(
|
||||
$this->owner->class,
|
||||
$stage,
|
||||
sprintf('"SiteTree"."ID" = %d', $id)
|
||||
);
|
||||
if(!$obj) continue;
|
||||
|
||||
$obj->Locale = Translatable::default_locale();
|
||||
$obj->write();
|
||||
$obj->writeToStage($stage);
|
||||
$obj->addTranslationGroup($obj->ID);
|
||||
$obj->destroy();
|
||||
unset($obj);
|
||||
}
|
||||
@ -543,6 +551,7 @@ class Translatable extends DataObjectDecorator {
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a record to a "translation group",
|
||||
@ -928,11 +937,16 @@ class Translatable extends DataObjectDecorator {
|
||||
$baseDataClass,
|
||||
$baseDataClass
|
||||
);
|
||||
|
||||
$currentStage = Versioned::current_stage();
|
||||
if($this->owner->hasExtension("Versioned")) {
|
||||
if($stage) Versioned::reading_stage($stage);
|
||||
$translations = Versioned::get_by_stage($this->owner->class, Versioned::current_stage(), $filter, null, $join);
|
||||
$translations = Versioned::get_by_stage(
|
||||
$this->owner->class,
|
||||
Versioned::current_stage(),
|
||||
$filter,
|
||||
null,
|
||||
$join
|
||||
);
|
||||
if($stage) Versioned::reading_stage($currentStage);
|
||||
} else {
|
||||
$translations = DataObject::get($this->owner->class, $filter, null, $join);
|
||||
|
Loading…
Reference in New Issue
Block a user