@@ -423,6 +423,7 @@ public function generate()
423423 // Store tiny mce fields
424424 if ($ arrField ['eval ' ]['rte ' ] && strncmp ($ arrField ['eval ' ]['rte ' ], 'tiny ' , 4 ) === 0 )
425425 {
426+ //TODO for CTO 3.2, 3.1, 3.0 id param hasn't row
426427 $ GLOBALS ['TL_RTE ' ]['tinyMCE ' ][$ this ->strField . '_ ' . $ strKey ] = array (
427428 'id ' => $ this ->strField . '_ ' . $ strKey ,
428429 'file ' => 'tinyMCE ' ,
@@ -562,7 +563,7 @@ public function generate()
562563 // Tiny MCE
563564 if ($ arrField ['eval ' ]['rte ' ] && strncmp ($ arrField ['eval ' ]['rte ' ], 'tiny ' , 4 ) === 0 )
564565 {
565- $ tinyMce = $ this ->getMcWTinyMCEString ($ objWidget ->id );
566+ $ tinyMce = $ this ->getMcWTinyMCEString ($ objWidget ->id , $ arrField );
566567 $ arrField ['eval ' ]['tl_class ' ] .= ' tinymce ' ;
567568 }
568569
@@ -749,12 +750,39 @@ protected function getMcWDatePickerString($strId, $strKey, $rgxp)
749750 }
750751 }
751752
752- protected function getMcWTinyMCEString ($ strId )
753+ protected function getMcWTinyMCEString ($ strId, $ arrField )
753754 {
754- return "<script>
755+ if (version_compare (VERSION , '3.3 ' , '< ' ))
756+ {
757+ return "<script>
755758 tinyMCE.execCommand('mceAddControl', false, 'ctrl_ " . $ strId . "');
756759 $('ctrl_ " . $ strId . "').erase('required');
757760 </script> " ;
761+ }
762+
763+ list ($ file , $ type ) = explode ('| ' , $ arrField ['eval ' ]['rte ' ], 2 );
764+
765+ if (!file_exists (TL_ROOT . '/system/config/ ' . $ file . '.php ' ))
766+ {
767+ throw new \Exception (sprintf ('Cannot find editor configuration file "%s.php" ' , $ file ));
768+ }
769+
770+ // Backwards compatibility
771+ $ language = substr ($ GLOBALS ['TL_LANGUAGE ' ], 0 , 2 );
772+
773+ if (!file_exists (TL_ROOT . '/assets/tinymce/langs/ ' . $ language . '.js ' ))
774+ {
775+ $ language = 'en ' ;
776+ }
777+
778+ $ selector = 'ctrl_ ' . $ strId ;
779+
780+ ob_start ();
781+ include TL_ROOT . '/system/config/ ' . $ file . '.php ' ;
782+ $ editor = ob_get_contents ();
783+ ob_end_clean ();
784+
785+ return $ editor ;
758786 }
759787
760788 /**
0 commit comments