1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public function init() {
		parent::init();
		
		// Locale" attribute is either explicitly added by LeftAndMain Javascript logic,
		// or implied on a translated record (see {@link Translatable->updateCMSFields()}).
		// $Lang serves as a "context" which can be inspected by Translatable - hence it
		// has the same name as the database property on Translatable.
		
		// EDIT BY DANZZZ
		
			if(Translatable::is_enabled()) {
		   // $Lang serves as a "context" which can be inspected by Translatable - hence it
		   // has the same name as the database property on Translatable.
		   if($this->getRequest()->requestVar("Locale")) {
		      $this->Locale = $this->getRequest()->requestVar("Locale");
		   } elseif($this->getRequest()->requestVar("locale")) {
		      $this->Locale = $this->getRequest()->requestVar("locale");
		    } elseif (Session::get("{$this->class}.Locale")) {
		      $this->Locale = Session::get("{$this->class}.Locale");    
		   } else {
		      $this->Locale = Translatable::default_locale();
		   }
		   Translatable::set_current_locale($this->Locale);
		   Session::set("{$this->class}.Locale", $this->Locale);
		}
		
		/*
		if($this->getRequest()->requestVar("Locale")) {
			$this->Locale = $this->getRequest()->requestVar("Locale");
		} elseif($this->getRequest()->requestVar("locale")) {
			$this->Locale = $this->getRequest()->requestVar("locale");
		} else {
			$this->Locale = Translatable::default_locale();
		}
		Translatable::set_current_locale($this->Locale);
		*/
		
		// collect languages for TinyMCE spellchecker plugin.
		// see http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
		$langName = i18n::get_locale_name($this->Locale);
		HtmlEditorConfig::get('cms')->setOption('spellchecker_languages', "+{$langName}={$this->Locale}");
				
		Requirements::javascript(CMS_DIR . '/javascript/CMSMain.js');
		Requirements::javascript(CMS_DIR . '/javascript/CMSMain_left.js');
		Requirements::javascript(CMS_DIR . '/javascript/CMSMain_right.js');
	}