2007-09-16 18:30:26 +02:00
|
|
|
var _TRANSLATING_LANG = null;
|
2007-09-25 23:58:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2008-11-13 05:24:02 +01:00
|
|
|
LangSelectorClass = Class.create();
|
|
|
|
LangSelectorClass.prototype = {
|
2007-09-16 18:30:26 +02:00
|
|
|
|
|
|
|
initialize: function() {
|
2007-09-25 23:58:42 +02:00
|
|
|
if(this.selectedIndex != 0) {
|
|
|
|
_TRANSLATING_LANG = this.value;
|
2007-09-16 18:30:26 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2007-09-25 23:58:42 +02:00
|
|
|
onchange: function(e, val) {
|
|
|
|
if(this.value != _TRANSLATING_LANG) {
|
|
|
|
_TRANSLATING_LANG = this.value;
|
Merged, debugged and enhanced Translatable patches from branches/translatable at r64523, r64523, 64523, thanks wakeless!
API CHANGE Changed Translatable schema from auxilliary tables (SiteTree_lang, SiteTree_lang_Live) to automatically filtered records on the original table (SiteTree, SiteTree_Live), using $Lang and $OriginalID properties. Incompatible update to old schema, migration script is in the works.
API CHANGE Removed Translatable::get_one(), Translatable::write()
ENHANCEMENT Simplified Translatable tree generation by using getSiteTreeFor() in CMSMain->createtranslation()
ENHANCEMENT Added AllChildrenIncludingDeleted(), augmentNumChildrenCountQuery(), augmentAllChildrenIncludingDeleted(), augmentStageChildren() to Translatable class to allow for more stable tree generation.
ENHANCEMENT Moved definition of Translatable schema from augmentDatabase() to Translatable->extraStatics()
ENHANCEMENT Changes to the CMS language selection refresh the whole admin interface instead of the tree only. This way we can add a URL parameter ?lang=<lang> to /admin, which makes the specific language bookmarkable and reloadable. Changes to LangSelector.js
ENHANCEMENT Added fallback to ModelAsController->getNestedController() to fetch page with matching URLSegment but different language in case no page is found in the current language.
ENHANCEMENT Added helper methods to Translatable: getTranslation(), hasTranslation(), isTranslation(), findOriginalIDs()
ENHANCEMENT Getters and setters for Translatable->getOriginalPage() etc.
ENHANCEMENT Hooking Translatable into ModelAsController and ContentController initialization in order to call choose_site_lang()
ENHANCEMENT Simplified Translatable->augmentSQL(), augmentWrite() by not using auxilliary tables
ENHANCEMENT Showing clickable links for Translations in Translatable->updateCMSFields()
BUGFIX Modifying Hierarchy/SiteTree Children getters to accept optional "context" which can be used to set a language explicitly through the $Lang property, rather than implicitly reyling on the static Translatable::current_lang()
BUGFIX Fixed TranslatableTest to work with new datamodel
BUGFIX Temporarily disabled cookie/session selection in Translatable::choose_site_lang() until we have a good test suite for the side effects.
MINOR Added "untranslated" CSS styles to tree nodes and marking them as inactive/grey
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@69959 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-01-10 13:15:30 +01:00
|
|
|
document.location = 'admin/?lang=' + this.value;
|
2007-09-16 18:30:26 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
selectValue: function(lang) {
|
2007-09-25 23:58:42 +02:00
|
|
|
this.value = lang;
|
|
|
|
if(this.value != lang) {
|
2007-09-16 18:30:26 +02:00
|
|
|
var newLang = document.createElement('option');
|
|
|
|
newLang.text = lang;
|
|
|
|
newLang.value = lang;
|
|
|
|
try {
|
2007-09-25 23:58:42 +02:00
|
|
|
this.add(newLang, null); // standards compliant
|
2007-09-16 18:30:26 +02:00
|
|
|
} catch(ex) {
|
2007-09-25 23:58:42 +02:00
|
|
|
this.add(newLang); // IE only
|
2007-09-16 18:30:26 +02:00
|
|
|
}
|
2007-09-25 23:58:42 +02:00
|
|
|
this.value = lang;
|
2007-09-16 18:30:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2008-11-13 05:24:02 +01:00
|
|
|
LangSelectorClass.applyTo('#LangSelector');
|
2007-09-16 18:30:26 +02:00
|
|
|
|
2007-09-25 23:58:42 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2007-09-16 18:30:26 +02:00
|
|
|
TranslatorCreator = Class.create();
|
|
|
|
TranslatorCreator.prototype = {
|
|
|
|
|
|
|
|
onSelectionChanged: function(selectedNode) {
|
2007-09-25 23:58:42 +02:00
|
|
|
if(_TRANSLATING_LANG && Element.hasClassName(selectedNode,'untranslated')) {
|
2007-09-16 18:30:26 +02:00
|
|
|
$start = confirm('Would you like to start a translation for this page?');
|
2007-09-25 23:58:42 +02:00
|
|
|
if($start) Element.removeClassName(selectedNode,'untranslated');
|
2007-09-16 18:30:26 +02:00
|
|
|
return $start;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
$('sitetree').observeMethod('SelectionChanged', this.onSelectionChanged.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
TranslatorCreator.applyTo('#LangSelector_holder');
|