40 $this->rootpath = $this->
config[
"rootpath"] .
"/tinymce/js/tinymce";
53 if (!isset($instance)) {
64 foreach (
$config as $key => $val) {
65 $this->
config[$key] = $val;
77 $configured = array();
78 $this->setting[
"selector"] =
"textarea";
79 $this->setting[
"theme"] =
"modern";
82 if (!($this->setting = @
include(
$GLOBALS[
'xoops']->path(
"var/configs/tinymce.php")))) {
83 $this->setting =
include __DIR__ .
"/settings.php";
88 $this->setting[
"language"] = $this->config[
"language"];
89 $configured[] =
"language";
92 $this->setting[
"content_css"] = implode(
",", $this->
loadCss());
93 $configured[] =
"content_css";
95 if (!empty($this->config[
"theme"])
96 && is_dir(\
XoopsBaseConfig::get(
'root-path') . $this->rootpath .
"/themes/" . $this->config[
"theme"])
98 $this->setting[
"theme"] = $this->config[
"theme"];
99 $configured[] =
"theme";
102 if (!empty($this->config[
"mode"])) {
103 $this->setting[
"mode"] = $this->config[
"mode"];
104 $configured[] =
"mode";
108 $this->setting[
"plugins"] = implode(
",", $this->
loadPlugins());
109 $configured[] =
"plugins";
111 if ($this->setting[
"theme"] !=
"simple") {
112 if (empty($this->config[
"buttons"])) {
113 $this->config[
"buttons"][] = array(
117 $this->config[
"buttons"][] = array(
121 $this->config[
"buttons"][] = array(
127 foreach ($this->config[
"buttons"] as
$button) {
129 if (isset($button[
"before"])) {
130 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}_add_before"] = $button[
"before"];
132 if (isset($button[
"add"])) {
133 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}_add"] = $button[
"add"];
135 if (isset($button[
""])) {
136 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}"] = $button[
""];
139 $configured[] =
"buttons";
141 if (isset($this->config[
"toolbar_location"])) {
142 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_toolbar_location"]
143 = $this->config[
"toolbar_location"];
144 $configured[] =
"toolbar_location";
146 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_toolbar_location"] =
"top";
149 if (isset($this->config[
"toolbar_align"])) {
150 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_toolbar_align"] = $this->config[
"toolbar_align"];
151 $configured[] =
"toolbar_align";
153 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_toolbar_align"] =
"left";
156 if (isset($this->config[
"statusbar_location"])) {
157 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_statusbar_location"]
158 = $this->config[
"statusbar_location"];
159 $configured[] =
"statusbar_location";
162 if (isset($this->config[
"path_location"])) {
163 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_path_location"] = $this->config[
"path_location"];
164 $configured[] =
"path_location";
167 if (isset($this->config[
"resize_horizontal"])) {
168 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_resize_horizontal"]
169 = $this->config[
"resize_horizontal"];
170 $configured[] =
"resize_horizontal";
173 if (isset($this->config[
"resizing"])) {
174 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_resizing"] = $this->config[
"resizing"];
175 $configured[] =
"resizing";
178 if (!empty($this->config[
"fonts"])) {
179 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_fonts"] = $this->config[
"fonts"];
180 $configured[] =
"fonts";
183 for (
$i=1;
$i <= 4;
$i++) {
185 if (isset($this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}"])) {
186 $checklist = explode(
",", $this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}"]);
187 foreach ($checklist as $plugin) {
188 if (strpos(strtolower($plugin),
"xoops") !==
false) {
189 if (in_array($plugin, $this->xoopsPlugins)) {
190 $buttons[] = $plugin;
193 $buttons[] = $plugin;
196 $this->setting[
"theme_" . $this->setting[
"theme"] .
"_buttons{$i}"] = implode(
",", $buttons);
201 $configured = array_unique($configured);
202 foreach ($this->config as $key => $val) {
203 if (isset($this->setting[$key]) || in_array($key, $configured)) {
206 $this->setting[$key] = $val;
209 if (!is_dir(\
XoopsBaseConfig::get(
'root-path') . $this->rootpath .
"/themes/" . $this->setting[
"theme"] .
'/docs/' . $this->setting[
"language"] .
'/')) {
210 $this->setting[
"docs_language"] =
"en";
213 unset($this->config, $configured);
226 $plugins_list = XoopsLists::getDirListAsArray(\
XoopsBaseConfig::get(
'root-path') . $this->rootpath .
"/plugins");
227 if (empty($this->setting[
"plugins"])) {
228 $plugins = $plugins_list;
230 $plugins = array_intersect(explode(
",", $this->setting[
"plugins"]), $plugins_list);
232 if (!empty($this->setting[
"exclude_plugins"])) {
233 $plugins = array_diff($plugins, explode(
",", $this->setting[
"exclude_plugins"]));
235 if (!empty($this->
config[
"plugins"])) {
236 $plugins = array_merge($plugins, $this->
config[
"plugins"]);
249 $xoopsPlugins = array();
251 $allplugins = XoopsLists::getDirListAsArray (
$xoops_root_path . $this->rootpath .
"/plugins");
252 foreach ($allplugins as $plugin) {
253 if (strpos(strtolower($plugin),
"xoops") !==
false
256 $xoopsPlugins[$plugin] = $plugin;
261 return $xoopsPlugins;
264 public function loadCss($css_file =
'style.css')
266 static $css_url, $css_path;
268 if (!isset($css_url)) {
274 $css[] = $css_url .
'/' . $css_file;
275 $css_content = file_get_contents($css_path .
'/' . $css_file);
278 if (preg_match_all(
"~\@import url\((.*\.css)\);~sUi", $css_content, $matches, PREG_PATTERN_ORDER)) {
279 foreach ($matches[1] as $key => $css_import) {
280 $css = array_merge($css, $this->
loadCss($css_import));
303 if (!empty($this->setting[
"callback"])) {
304 $callback = $this->setting[
"callback"];
305 unset($this->setting[
"callback"]);
310 $ret =
'<script language="javascript" type="text/javascript" src="' .
\XoopsBaseConfig::get(
'url') . $this->rootpath .
'/tinymce.min.js"></script>';
311 $ret .=
'<script language="javascript" type="text/javascript">
315 foreach ($this->setting as $key => $val) {
319 } elseif ($val ===
false) {
341 $ret .=
'external_plugins: {';
342 $ret .=
'"qrcode": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/qrcode/plugin.min.js",';
343 $ret .=
'"youtube": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/youtube/plugin.min.js",';
344 $ret .=
'"alignbtn": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/alignbtn/plugin.min.js",';
345 $ret .=
'"chartextbtn": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/chartextbtn/plugin.min.js",';
346 $ret .=
'"xoops_code": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/xoops_code/plugin.min.js",';
347 $ret .=
'"xoops_quote": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/xoops_quote/plugin.min.js",';
348 $ret .=
'"xoops_tagextgal": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/xoops_tagextgal/plugin.min.js",';
349 $ret .=
'"codemirror": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/codemirror/plugin.min.js",';
350 $ret .=
'"filemanager": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/filemanager/plugin.min.js",';
351 $ret .=
'"responsivefilemanager": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/responsivefilemanager/plugin.min.js",';
355 $ret .=
'codemirror: {
359 mode: "application/x-httpd-php",
363 "mode/clike/clike.js",
369 $ret .=
'"external_filemanager_path": "'.$chemin_path.
'/class/xoopseditor/tinymce4/external_plugins/filemanager/",';
372 $ret .=
'templates: "'.$chemin_path.
'/uploads/filemanager/templates/liste-templates.js",';
376 $ret .=
'relative_urls : false,
377 remove_script_host : false, tinymceload : "1"});
381 if (tinyMCE.getInstanceById(id) == null) {
382 tinyMCE.execCommand("mceAddControl", false, id);
384 tinyMCE.execCommand("mceRemoveControl", false, id);
if(DIRECTORY_SEPARATOR!="/") $xoops_root_path
loadCss($css_file= 'style.css')