mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
Misc 3.1 compat changes
Removed nested_urls check, its the only supported mode now
This commit is contained in:
parent
a3ff187938
commit
5c7682013c
@ -4,7 +4,7 @@
|
||||
*/
|
||||
class TranslatableCMSMainExtension extends Extension {
|
||||
|
||||
static $allowed_actions = array(
|
||||
private static $allowed_actions = array(
|
||||
'createtranslation',
|
||||
);
|
||||
|
||||
|
@ -27,7 +27,7 @@ class LanguageDropdownField extends GroupedDropdownField {
|
||||
else if('Common-Native' == $list) $allLocalesWithTitle = i18n::get_common_languages(true);
|
||||
else if('Locale-English' == $list) $allLocalesWithTitle = i18n::get_common_locales();
|
||||
else if('Locale-Native' == $list) $allLocalesWithTitle = i18n::get_common_locales(true);
|
||||
else $allLocalesWithTitle = i18n::get_locale_list();
|
||||
else $allLocalesWithTitle = i18n::config()->all_locales;
|
||||
|
||||
if(isset($allLocales[Translatable::default_locale()])) {
|
||||
unset($allLocales[Translatable::default_locale()]);
|
||||
|
@ -12,20 +12,14 @@
|
||||
*
|
||||
* <h2>Configuration</h2>
|
||||
*
|
||||
* <h3>Through Object::add_extension()</h3>
|
||||
* Enabling Translatable through {@link Object::add_extension()} in your _config.php:
|
||||
* <code>
|
||||
* MyClass::add_extension('Translatable');
|
||||
* </code>
|
||||
* This is the recommended approach for enabling Translatable.
|
||||
* The extension is automatically enabled for SiteTree and SiteConfig records,
|
||||
* if they can be found. Add the following to your config.yml in order to
|
||||
* register a custom class:
|
||||
*
|
||||
* <h3>Through $extensions</h3>
|
||||
* <code>
|
||||
* class MyClass extends DataObject {
|
||||
* static $extensions = array(
|
||||
* "Translatable"
|
||||
* );
|
||||
* }
|
||||
* MyClass:
|
||||
* extensions:
|
||||
* Translatable
|
||||
* </code>
|
||||
*
|
||||
* Make sure to rebuild the database through /dev/build after enabling translatable.
|
||||
@ -76,12 +70,8 @@
|
||||
*
|
||||
* <h2>Usage for SiteTree</h2>
|
||||
*
|
||||
* Translatable can be used for subclasses of {@link SiteTree} as well.
|
||||
*
|
||||
* <code>
|
||||
* SiteTree::add_extension('Translatable');
|
||||
* SiteConig::add_extension('Translatable');
|
||||
* </code>
|
||||
* Translatable can be used for subclasses of {@link SiteTree},
|
||||
* it is automatically configured if this class is foun.
|
||||
*
|
||||
* If a child page translation is requested without the parent
|
||||
* page already having a translation in this language, the extension
|
||||
@ -277,7 +267,7 @@ class Translatable extends DataExtension implements PermissionProvider {
|
||||
throw new InvalidArgumentException(sprintf('Invalid locale "%s"', $locale));
|
||||
}
|
||||
|
||||
$localeList = i18n::get_locale_list();
|
||||
$localeList = i18n::config()->all_locales;
|
||||
if(isset($localeList[$locale])) {
|
||||
self::$default_locale = $locale;
|
||||
} else {
|
||||
@ -1524,7 +1514,7 @@ class Translatable extends DataExtension implements PermissionProvider {
|
||||
$originalLocale = self::get_current_locale();
|
||||
|
||||
self::set_current_locale(self::default_locale());
|
||||
$original = SiteTree::get_by_link(RootURLController::get_default_homepage_link());
|
||||
$original = SiteTree::get_by_link(RootURLController::config()->default_homepage_link);
|
||||
self::set_current_locale($originalLocale);
|
||||
|
||||
if($original) {
|
||||
@ -1692,13 +1682,11 @@ class Translatable extends DataExtension implements PermissionProvider {
|
||||
$IDFilter = ($this->owner->ID) ? "AND \"SiteTree\".\"ID\" <> {$this->owner->ID}" : null;
|
||||
$parentFilter = null;
|
||||
|
||||
if(SiteTree::nested_urls()) {
|
||||
if($this->owner->ParentID) {
|
||||
$parentFilter = " AND \"SiteTree\".\"ParentID\" = {$this->owner->ParentID}";
|
||||
} else {
|
||||
$parentFilter = ' AND "SiteTree"."ParentID" = 0';
|
||||
}
|
||||
}
|
||||
|
||||
$existingPage = SiteTree::get()
|
||||
// disable get_one cache, as this otherwise may pick up results from when locale_filter was on
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
class TranslatableSearchFormTest extends FunctionalTest {
|
||||
|
||||
static $fixture_file = 'translatable/tests/unit/TranslatableSearchFormTest.yml';
|
||||
protected static $fixture_file = 'translatable/tests/unit/TranslatableSearchFormTest.yml';
|
||||
|
||||
protected $mockController;
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
class TranslatableSiteConfigTest extends SapphireTest {
|
||||
|
||||
static $fixture_file = 'translatable/tests/unit/TranslatableSiteConfigTest.yml';
|
||||
protected static $fixture_file = 'translatable/tests/unit/TranslatableSiteConfigTest.yml';
|
||||
|
||||
protected $requiredExtensions = array(
|
||||
'SiteTree' => array('Translatable'),
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
class TranslatableTest extends FunctionalTest {
|
||||
|
||||
static $fixture_file = 'translatable/tests/unit/TranslatableTest.yml';
|
||||
protected static $fixture_file = 'translatable/tests/unit/TranslatableTest.yml';
|
||||
|
||||
protected $extraDataObjects = array(
|
||||
'TranslatableTest_DataObject',
|
||||
@ -928,7 +928,6 @@ class TranslatableTest extends FunctionalTest {
|
||||
$grandchildTranslation = $grandchild->createTranslation('en_AU');
|
||||
$grandchildTranslation->write();
|
||||
|
||||
SiteTree::enable_nested_urls();
|
||||
Translatable::set_current_locale('en_AU');
|
||||
|
||||
$this->assertEquals (
|
||||
@ -983,14 +982,14 @@ class TranslatableTest extends FunctionalTest {
|
||||
class TranslatableTest_DataObject extends DataObject implements TestOnly {
|
||||
// add_extension() used to add decorator at end of file
|
||||
|
||||
static $db = array(
|
||||
private static $db = array(
|
||||
'TranslatableProperty' => 'Text'
|
||||
);
|
||||
}
|
||||
|
||||
class TranslatableTest_Extension extends DataExtension implements TestOnly {
|
||||
|
||||
static $db = array(
|
||||
private static $db = array(
|
||||
'TranslatableDecoratedProperty' => 'Text'
|
||||
);
|
||||
|
||||
@ -1000,7 +999,7 @@ class TranslatableTest_Page extends Page implements TestOnly {
|
||||
// static $extensions is inherited from SiteTree,
|
||||
// we don't need to explicitly specify the fields
|
||||
|
||||
static $db = array(
|
||||
private static $db = array(
|
||||
'TranslatableProperty' => 'Text'
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user