Hi UncleCheeze!
Sites that enable translation won't work with Data Object Manager.
The main problem is that the locale parameter is not propagated in most requests.
Anyway, I found a work around, and I think you might be interrested to include those changes in your trunk!
First, I need to enable translations for all the classes (SiteTree, all classes using DataObject), and also for the DataObjectManager and DataObjectManager_Item classes. For those two last, I know it's bad, but it's the work around I found.
so, in my _config.php, I have :
Translatable::set_default_locale('fr_FR');
Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('Performer', 'Translatable');
Object::add_extension('DataObjectManager', 'Translatable');
Object::add_extension('DataObjectManager_Item', 'Translatable');
After /dev/build, you'll see there's a Locale DB field add for DataObject classes (Performer, in my case)
Then, in the Performer Class, i need to add an hidden field :
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'FullName', 'Nom' ) );
$fields->push( new TextField( 'Tagline' ) );
$fields->push( new TextField( 'Web' ) );
$fields->push( new HiddenField( $name='Locale', $title='Locale', $value=Translatable::get_current_locale() ) );
return $fields;
}
It would be good if the the field would add up itself... But I didn't have the time to work on it...
After, I needed to edit you DataObjectManager.php :
Modify getQueryString method :
protected function getQueryString($params = array())
{
$per_page = isset($params['per_page'])? $params['per_page'] : $this->per_page;
$show_all = isset($params['show_all'])? $params['show_all'] : $this->showAll;
$sort = isset($params['sort'])? $params['sort'] : $this->sort;
$sort_dir = isset($params['sort_dir'])? $params['sort_dir'] : $this->sort_dir;
$filter = isset($params['filter'])? $params['filter'] : $this->filter;
$search = isset($params['search'])? $params['search'] : $this->search;
$locale = $this->hasExtension('Translatable') ? "&locale=".Translatable::get_current_locale() : '';
return "ctf[{$this->Name()}][per_page]={$per_page}&ctf[{$this->Name()}][showall]={$show_all}&ctf[{$this->Name()}][sort]={$sort}&ctf[{$this->Name()}][sort_dir]={$sort_dir}&ctf[{$this->Name()}][search]={$search}&ctf[{$this->Name()}][filter]={$filter}".$locale;
}
Modify the AddLink method :
public function AddLink() {
$currentLang = ($this->hasExtension('Translatable')) ? '?locale='.Translatable::get_current_locale() : '';
return $this->BaseLink() . '/add'.$currentLang;
}
And add thoses methods for the DataObjectManager_Item class :
public function EditLink() {
$currentLang = ($this->hasExtension('Translatable')) ? '?locale='.Translatable::get_current_locale() : '';
return parent::EditLink().$currentLang;
}
public function DeleteLink() {
$currentLang = ($this->hasExtension('Translatable')) ? '?locale='.Translatable::get_current_locale() : '';
return parent::DeleteLink().$currentLang;
}
So it works for a has_many relationship. I think I gonna have to work a little more for a many_many relationship. Thank god, I don't have to use a FileObjectManager !!!
For now I broke the code, so I can't get (easily) in sync with your trunk!
I know this issue involves a lot of work... And thanks for your good work!
JP