fixed editing translated siteconfigs

fixed editings translated configs, and added a link for the 'add
translation' not working for siteconfigs
This commit is contained in:
Ruud Arentsen 2012-07-26 15:06:42 +02:00
parent 2fb20aa7e5
commit 91afab6ed1
2 changed files with 21 additions and 1 deletions

View File

@ -241,6 +241,9 @@ class Translatable extends DataExtension implements PermissionProvider {
if((isset($_GET['locale']) && !$langsAvailable) || (isset($_GET['locale']) && in_array($_GET['locale'], $langsAvailable))) {
// get from GET parameter
self::set_current_locale($_GET['locale']);
} else if((isset($_POST['Locale']) && !$langsAvailable) || (isset($_POST['Locale']) && in_array($_POST['Locale'], $langsAvailable))) {
// get from POST parameter
self::set_current_locale($_POST['Locale']);
} else {
self::set_current_locale(self::default_locale());
}
@ -933,7 +936,13 @@ class Translatable extends DataExtension implements PermissionProvider {
$existingTransHTML = '<ul>';
foreach($alreadyTranslatedLocales as $langCode) {
$existingTranslation = $this->owner->getTranslation($langCode);
if($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) {
if ($existingTranslation && $this->owner->ClassName == "SiteConfig") {
$existingTransHTML .= sprintf('<li><a href="%s">%s</a></li>',
sprintf('%s/?locale=%s', Director::baseURL()."admin/settings", $langCode),
i18n::get_locale_name($langCode)
);
}
else if($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) {
$existingTransHTML .= sprintf('<li><a href="%s">%s</a></li>',
sprintf('%s/?locale=%s', $existingTranslation->CMSEditLink(), $langCode),
i18n::get_locale_name($langCode)

View File

@ -60,5 +60,16 @@
return false;
}
});
/* for adding siteconfig translations */
$('.CMSSettingsController :input[name=action_createtranslation]').entwine({
onclick: function(e) {
var newurl = document.location.href.split("?");
newurl = newurl[0];
document.location = newurl+"?locale="+$('select.languagedropdown').val()
e.preventDefault();
return false;
}
});
});
}(jQuery));