39 $this->rootpath = $this->config[
"rootpath"] .
"/tinymce/jscripts/tiny_mce";
41 self::$LastOfElementsTinymce=$this->config[
"elements"];
42 self::$ListOfElementsTinymce[]= self::$LastOfElementsTinymce;
54 if (!isset($instance)) {
64 foreach (
$config as $key => $val) {
65 $this->config[$key] = $val;
72 $configured = array();
75 if ( ! ($this->setting = @include(
$GLOBALS[
'xoops']->path(
"var/configs/tinymce.php" ) ) ) ) {
76 $this->setting = include dirname(__FILE__) .
"/settings.php";
80 if (is_readable(XOOPS_ROOT_PATH . $this->rootpath .
'/langs/' . $this->config[
"language"] .
'.js')) {
81 $this->setting[
"language"] = $this->config[
"language"];
82 $configured[] =
"language";
85 $this->setting[
"content_css"] = implode(
",", $this->
loadCss() );
86 $configured[] =
"content_css";
88 if ( !empty($this->config[
"theme"]) && is_dir(XOOPS_ROOT_PATH . $this->rootpath .
"/themes/" . $this->config[
"theme"]) ) {
89 $this->setting[
"theme"] = $this->config[
"theme"];
90 $configured[] =
"theme";
93 if (!empty($this->config[
"mode"])) {
94 $this->setting[
"mode"] = $this->config[
"mode"];
95 $configured[] =
"mode";
99 $this->setting[
"plugins"] = implode(
",", $this->
loadPlugins());
100 $configured[] =
"plugins";
102 if ( $this->setting[
"theme"] !=
"simple" ) {
103 if (empty($this->config[
"buttons"])) {
104 $this->config[
"buttons"][] = array(
108 $this->config[
"buttons"][] = array(
112 $this->config[
"buttons"][] = array(
118 foreach ($this->config[
"buttons"] as $button) {
120 if (isset($button[
"before"])) {
121 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}_add_before"] = $button[
"before"];
123 if (isset($button[
"add"])) {
124 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}_add"] = $button[
"add"];
126 if (isset($button[
""])) {
127 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}"] = $button[
""];
130 $configured[] =
"buttons";
132 if (isset($this->config[
"toolbar_location"])) {
133 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_toolbar_location"] = $this->config[
"toolbar_location"];
134 $configured[] =
"toolbar_location";
136 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_toolbar_location"] =
"top";
139 if (isset($this->config[
"toolbar_align"])) {
140 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_toolbar_align"] = $this->config[
"toolbar_align"];
141 $configured[] =
"toolbar_align";
143 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_toolbar_align"] =
"left";
146 if (isset($this->config[
"statusbar_location"])) {
147 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_statusbar_location"] = $this->config[
"statusbar_location"];
148 $configured[] =
"statusbar_location";
151 if (isset($this->config[
"path_location"])) {
152 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_path_location"] = $this->config[
"path_location"];
153 $configured[] =
"path_location";
156 if (isset($this->config[
"resize_horizontal"])) {
157 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_resize_horizontal"] = $this->config[
"resize_horizontal"];
158 $configured[] =
"resize_horizontal";
161 if (isset($this->config[
"resizing"])) {
162 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_resizing"] = $this->config[
"resizing"];
163 $configured[] =
"resizing";
166 if (!empty($this->config[
"fonts"])) {
167 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_fonts"] = $this->config[
"fonts"];
168 $configured[] =
"fonts";
171 for (
$i=1 ;
$i <= 4 ;
$i++ ) {
173 if ( isset($this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}"]) ) {
174 $checklist = explode(
",", $this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}"] );
175 foreach ( $checklist as $plugin ) {
176 if ( strpos( strtolower($plugin),
"xoops") !=
false ) {
177 if ( in_array( $plugin, $this->xoopsPlugins ) ) {
178 $buttons[] = $plugin;
181 $buttons[] = $plugin;
184 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}"] = implode(
",", $buttons);
189 $configured = array_unique($configured);
190 foreach ($this->config as $key => $val) {
191 if (isset($this->setting[$key]) || in_array($key, $configured)) {
194 $this->setting[$key] = $val;
197 if (!is_dir(XOOPS_ROOT_PATH . $this->rootpath .
"/themes/" . $this->setting[
"theme"] .
'/docs/' . $this->setting[
"language"] .
'/')) {
198 $this->setting[
"docs_language"] =
"en";
201 unset($this->config, $configured);
210 $plugins_list = XoopsLists::getDirListAsArray( XOOPS_ROOT_PATH . $this->rootpath .
"/plugins" );
211 if (empty($this->setting[
"plugins"])) {
212 $plugins = $plugins_list;
214 $plugins = array_intersect(explode(
",", $this->setting[
"plugins"]), $plugins_list);
216 if (!empty($this->setting[
"exclude_plugins"])) {
217 $plugins = array_diff($plugins, explode(
",", $this->setting[
"exclude_plugins"]));
219 if (!empty($this->config[
"plugins"])) {
220 $plugins = array_merge($plugins, $this->config[
"plugins"]);
227 $xoopsPlugins = array();
228 $allplugins = XoopsLists::getDirListAsArray( XOOPS_ROOT_PATH . $this->rootpath .
"/plugins" );
229 foreach ( $allplugins as $plugin ) {
230 if ( strpos( strtolower($plugin),
"xoops") !=
false && file_exists(XOOPS_ROOT_PATH . $this->config[
"rootpath"] .
"/include/$plugin.php") ) {
231 if ( $right = @include XOOPS_ROOT_PATH . $this->config[
"rootpath"] .
"/include/$plugin.php" ) {
232 $xoopsPlugins[$plugin] = $plugin;
236 return $xoopsPlugins;
241 static $css_url, $css_path;
243 if (!isset($css_url)) {
249 $css[] = $css_url .
'/' . $css_file;
250 $css_content = file_get_contents( $css_path .
'/' . $css_file );
253 if ( preg_match_all(
"~\@import url\((.*\.css)\);~sUi", $css_content, $matches, PREG_PATTERN_ORDER) ) {
254 foreach( $matches[1] as $key => $css_import ) {
255 $css = array_merge( $css, $this->
loadCss( $css_import) );
263 static $isTinyMceJsLoaded =
false;
266 if (self::$LastOfElementsTinymce!=$this->setting[
"elements"]){
267 $ret =
"\n<!-- 'tiny_mce.js' SCRIPT NOT YET ".$this->setting[
"elements"].
" -->\n";
271 $this->setting[
"elements"]=implode(
",",self::$ListOfElementsTinymce);
273 if ( !empty($this->setting[
"callback"]) ) {
274 $callback = $this->setting[
"callback"];
275 unset($this->setting[
"callback"]);
279 if ( !empty($this->setting[
"file_browser_callback"]) ) {
280 $fbc_name=XOOPS_ROOT_PATH .
"/class/xoopseditor/tinymce/include/".$this->setting[
"file_browser_callback"].
".js";
282 $file_browser_callback =
"MyXoopsUrl ='".XOOPS_URL.
"';\n";
283 $file_browser_callback .= file_get_contents($fbc_name);
284 $file_browser_callback .=
"\n//suis passé la ".$fbc_name;
287 $file_browser_callback =
"//suis absent";
328 $ret .=
"<!-- Start TinyMce Rendering -->\n";
329 if ($isTinyMceJsLoaded) {
330 $ret .=
"<!-- 'tiny_mce.js' SCRIPT IS ALREADY LOADED -->\n";
332 $ret .=
"<script language='javascript' type='text/javascript' src='" . XOOPS_URL . $this->rootpath .
"/tiny_mce.js'></script>\n";
333 $isTinyMceJsLoaded =
true;
335 $ret .=
"<script language='javascript' type='text/javascript'>\n";
336 $ret .=
"tinyMCE.init({\n";
338 foreach ($this->setting as $key => $val) {
342 } elseif ($val ===
false) {
350 $ret .=
"tinymceload: true\n";
352 $ret .= $callback .
"\n";
353 $ret .= $file_browser_callback.
"\n";
355 $ret .=
"</script>\n";
356 $ret .=
"<!-- End TinyMce Rendering -->\n";