Permalink
Browse files

Misc 3.1 compat changes

Removed nested_urls check, its the only supported mode now
  • Loading branch information...
1 parent a3ff187 commit 5c7682013c7869613dcd474420dd71e6416d7c34 @chillu chillu committed Mar 26, 2013
@@ -4,7 +4,7 @@
*/
class TranslatableCMSMainExtension extends Extension {
- static $allowed_actions = array(
+ private static $allowed_actions = array(
'createtranslation',
);
@@ -27,7 +27,7 @@ function __construct($name, $title, $excludeLocales = array(),
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.
- *
- * <h3>Through $extensions</h3>
+ * 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:
+ *
* <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 @@ static function set_default_locale($locale) {
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 @@ public static function get_homepage_link_by_locale($locale) {
$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 @@ public function augmentValidURLSegment() {
$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()
@@ -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 @@ public function testAlternateGetByLink() {
$grandchildTranslation = $grandchild->createTranslation('en_AU');
$grandchildTranslation->write();
- SiteTree::enable_nested_urls();
Translatable::set_current_locale('en_AU');
$this->assertEquals (
@@ -983,14 +982,14 @@ public function testSiteTreeGetByLinkFindsTranslationWithoutLocale() {
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'
);

0 comments on commit 5c76820

Please sign in to comment.