diff --git a/code/controller/TranslatableCMSMainExtension.php b/code/controller/TranslatableCMSMainExtension.php index ba04454..d78d46d 100644 --- a/code/controller/TranslatableCMSMainExtension.php +++ b/code/controller/TranslatableCMSMainExtension.php @@ -4,7 +4,7 @@ */ class TranslatableCMSMainExtension extends Extension { - static $allowed_actions = array( + private static $allowed_actions = array( 'createtranslation', ); diff --git a/code/forms/LanguageDropdownField.php b/code/forms/LanguageDropdownField.php index 5bfcbaa..3451f98 100755 --- a/code/forms/LanguageDropdownField.php +++ b/code/forms/LanguageDropdownField.php @@ -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()]); diff --git a/code/model/Translatable.php b/code/model/Translatable.php index 4b0eb70..577706f 100755 --- a/code/model/Translatable.php +++ b/code/model/Translatable.php @@ -12,20 +12,14 @@ * *
- * MyClass::add_extension('Translatable');
- *
- * This is the recommended approach for enabling Translatable.
- *
- *
- * class MyClass extends DataObject {
- * static $extensions = array(
- * "Translatable"
- * );
- * }
+ * MyClass:
+ * extensions:
+ * Translatable
*
*
* Make sure to rebuild the database through /dev/build after enabling translatable.
@@ -76,12 +70,8 @@
*
*
- * SiteTree::add_extension('Translatable');
- * SiteConig::add_extension('Translatable');
- *
+ * 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,12 +1682,10 @@ 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';
- }
+ if($this->owner->ParentID) {
+ $parentFilter = " AND \"SiteTree\".\"ParentID\" = {$this->owner->ParentID}";
+ } else {
+ $parentFilter = ' AND "SiteTree"."ParentID" = 0';
}
$existingPage = SiteTree::get()
diff --git a/tests/unit/TranslatableSearchFormTest.php b/tests/unit/TranslatableSearchFormTest.php
index 58bf359..ed74263 100644
--- a/tests/unit/TranslatableSearchFormTest.php
+++ b/tests/unit/TranslatableSearchFormTest.php
@@ -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;
diff --git a/tests/unit/TranslatableSiteConfigTest.php b/tests/unit/TranslatableSiteConfigTest.php
index 7767eca..3476613 100644
--- a/tests/unit/TranslatableSiteConfigTest.php
+++ b/tests/unit/TranslatableSiteConfigTest.php
@@ -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'),
diff --git a/tests/unit/TranslatableTest.php b/tests/unit/TranslatableTest.php
index 38cdf08..e006bef 100755
--- a/tests/unit/TranslatableTest.php
+++ b/tests/unit/TranslatableTest.php
@@ -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'
);