37 $this->rootpath = $this->
config[
"rootpath"] .
"/tiny_mce";
39 $this->element = $config[
'elements'];
51 if (!isset($instance)) {
52 $instance =
new TinyMCE($config);
54 $instance->setConfig($config);
61 foreach ($config as $key => $val) {
62 $this->
config[$key] = $val;
70 $configured = array();
75 if ( ! ($this->setting = @
include(
$xoops->path(
"var/configs/tinymce.php" ) ) ) ) {
76 $this->setting =
include __DIR__ .
"/settings.php";
81 $this->setting[
"language"] = $this->config[
"language"];
82 $configured[] =
"language";
85 $this->setting[
"content_css"] = implode(
",", $this->
loadCss()) .
',' .
$xoops->url(
'xoops.css');
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);
211 $plugins_list = XoopsLists::getDirListAsArray(
$xoops_root_path . $this->rootpath .
"/plugins" );
212 if (empty($this->setting[
"plugins"])) {
213 $plugins = $plugins_list;
215 $plugins = array_intersect(explode(
",", $this->setting[
"plugins"]), $plugins_list);
217 if (!empty($this->setting[
"exclude_plugins"])) {
218 $plugins = array_diff($plugins, explode(
",", $this->setting[
"exclude_plugins"]));
220 if (!empty($this->
config[
"plugins"])) {
221 $plugins = array_merge($plugins, $this->
config[
"plugins"]);
229 $xoopsPlugins = array();
230 $allplugins = XoopsLists::getDirListAsArray(
$xoops_root_path . $this->rootpath .
"/plugins" );
231 foreach ( $allplugins as $plugin ) {
232 if ( strpos( strtolower($plugin),
"xoops") !==
false && file_exists(
$xoops_root_path . $this->
config[
"rootpath"] .
"/include/$plugin.php") ) {
234 $xoopsPlugins[$plugin] = $plugin;
238 return $xoopsPlugins;
243 static $css_url, $css_path;
245 if (!isset($css_url)) {
247 $css_url = dirname(
$xoops->getCss(
$xoops->getConfig(
'theme_set')) );
252 $css[] = $css_url .
'/' . $css_file;
253 $css_content = file_get_contents( $css_path .
'/' . $css_file );
256 if ( preg_match_all(
"~\@import url\((.*\.css)\);~sUi", $css_content, $matches, PREG_PATTERN_ORDER) ) {
257 foreach( $matches[1] as $key => $css_import ) {
258 $css = array_merge( $css, $this->
loadCss( $css_import) );
266 static $isTinyMceJsLoaded =
false;
272 if ( !empty($this->setting[
"callback"]) ) {
273 $callback = $this->setting[
"callback"];
274 unset($this->setting[
"callback"]);
281 $ret .=
"<!-- Start TinyMce Rendering -->\n";
282 if ($isTinyMceJsLoaded) {
283 $ret .=
"<!-- 'tiny_mce.js' SCRIPT IS ALREADY LOADED -->\n";
285 $ret .=
"<script language='javascript' type='text/javascript' src='" .
$xoops_url . $this->rootpath .
"/jquery.tinymce.js'></script>\n";
286 $isTinyMceJsLoaded =
true;
288 $ret .=
"<script language='javascript' type='text/javascript'>\n";
289 $ret .=
" $().ready(function() {\n";
290 $ret .=
"$('textarea." . $this->element .
"').tinymce({\n";
292 $ret .=
"script_url : '" .
$xoops_url . $this->rootpath .
"/tiny_mce.js',\n";
295 foreach ($this->setting as $key => $val) {
299 } elseif ($val ===
false) {
308 $ret .=
"tinymceload: true\n";
311 $ret .= $callback .
"\n";
313 $ret .=
"</script>\n";
314 $ret .=
"<!-- End TinyMce Rendering -->\n";
if(DIRECTORY_SEPARATOR!="/") $xoops_root_path
loadCss($css_file= 'style.css')