4 * Plugin for Nucleus CMS (http://plugins.nucleuscms.org/)
5 * Copyright (C) 2003 The Nucleus Plugins Project
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * see license.txt for the full license
21 * - upgrade to TinyMCE 2RC3
22 * - lots of path fixes
23 * - experimental GZip option. Should load quicker if it works
25 * - upgrade to TinyMCE 2RC2
26 * - addition of File Manager
27 * - bugfixes and cleaner uninstall
29 * - initial implementation, mostly copied over from NP_EditControls by karma - http://demuynck.org
32 class NP_TinyMCE2j extends NucleusPlugin {
34 function NP_TinyMCE2j() {
35 // $this->baseUrl = $this->getAdminURL();
36 // hardcoded relative path to avoid domain security issues (IE6 'Access is denied' error)
38 $this->baseUrl = str_replace ($CONF['AdminURL'],'',$this->getAdminURL());
42 function getName() { return 'TinyMCE 2RC3'; }
43 function getAuthor() { return 'karma | roel | eph'; }
44 function getURL() { return 'http://demuynck.org/'; }
45 function getVersion() { return '0.9c'; }
46 function getMinNucleusVersion() { return 300; }
47 function getDescription()
49 return 'WYSIWYG XHTML 1.0 editor. Mozilla, MSIE and FireFox (Safari experimental).';
55 * Make sure plugin still works when a database table prefix is activated for
56 * the Nucleus installation. (Nucleus refuses to install plugins which do not
57 * support SqlTablePrefix when a database prefix is active)
60 function supportsFeature($what) {
65 case 'SqlTablePrefix':
74 // create plugin options (per-blog options)
75 $this->createBlogOption('use_tinymce', 'Use TinyMCE editor', 'yesno', 'yes');
77 // create plugin options (admin)
78 $this->createOption('use_tgzip', 'Use TinyMCE GZip compression (experimental)', 'yesno', 'no');
80 // disable the default javascript editbar that comes with nucleus
81 mysql_query("UPDATE ".sql_table('config')." SET value='1' WHERE name='DisableJSTools'");
83 // disable auto-linebreak conversions
84 $this->setLinebreakConversion(0);
88 function setLinebreakConversion($mode) {
89 // modify auto-linebreak on the fly. Thx to alfmiti :)
90 mysql_query("UPDATE ".sql_table('blog')." SET bconvertbreaks=".$mode);
94 function unInstall() {
95 // restore to standard settings
96 $this->setLinebreakConversion(1);
97 mysql_query("UPDATE ".sql_table('config')." SET value='2' WHERE name='DisableJSTools'");
101 * List of events we want to subscribe to
103 function getEventList() {
105 'AdminPrePageHead', // include javascript on admin add/edit pages
106 'BookmarkletExtraHead', // include javascript on bookmarklet pages
107 'PreSendContentType' // we need to force text/html instead of application/xhtml+xml
112 * Hook into the <head> section of bookmarkler area pages.
113 * Insert extra script/css includes there.
115 function event_BookmarkletExtraHead(&$data)
117 $this->_getExtraHead($data['extrahead']);
121 * Hook into the <head> section of admin area pages. When the requested page is an "add item" or
122 * "edit item" form, include the extra code.
124 function event_AdminPrePageHead(&$data)
126 $action = $data['action'];
127 if (($action != 'createitem') && ($action != 'itemedit'))
130 $this->_getExtraHead($data['extrahead']);
135 * Returns the extra code that needs to be inserted in the <head>...</head> section of pages that
138 function _getExtraHead(&$extrahead)
140 global $CONF, $manager;
142 // Found no function to detect blogid in this time -> do the long way
143 if (is_array($manager->blogs)) {
144 $tmp_keys = array_keys($manager->blogs);
145 $blogid = $tmp_keys[0];
148 // get the options for the current blog
149 $bUseEditor = ($this->getBlogOption($blogid, 'use_tinymce') == 'yes');
151 // add code for html editor
154 // To avoid conflicts if a other user use only textmode we must set this on all calls
155 $CONF['DisableJsTools'] = 1; // overrule simple global settings
156 $this->setLinebreakConversion(0);
159 if ($this->getOption('use_tgzip') == 'yes')
160 $editorCode = '<script type="text/javascript" src="'.$this->baseUrl.'tiny_mce_gzip.php"></script>';
162 $editorCode = '<script type="text/javascript" src="'.$this->baseUrl.'tiny_mce.js"></script>';
164 if(_CHARSET == 'UTF-8'){
165 $lang_jp = 'ja_utf8';
166 }elseif(_CHARSET == 'EUC-JP'){
171 $editorCode .= <<<EOD
172 <script type="text/javascript">
174 language : "{$lang_jp}",
177 document_base_url : "{$CONF['IndexURL']}",
178 plugins : "paste,ibrowser,filemanager,emotions,searchreplace,table",
179 theme_advanced_buttons1 : "bold,italic,underline,strikethrough,forecolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,link,unlink",
180 theme_advanced_buttons1_add : "ibrowser,filemanager,emotions,separator,code",
181 theme_advanced_buttons2 : "undo,redo,separator,tablecontrols,separator,pastetext,pasteword,search,replace",
182 theme_advanced_buttons3 : "",
183 theme_advanced_toolbar_location : "top",
184 theme_advanced_toolbar_align : "left",
185 theme_advanced_path_location : "bottom",
186 extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],span[class|align|style]",
187 paste_create_paragraphs : true,
188 paste_use_dialog : true,
189 paste_auto_cleanup_on_paste : true,
190 theme_advanced_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",
197 $extrahead .= $editorCode;
199 $CONF['DisableJsTools'] = 2;
200 $linebreak_conversion = $this->getOption('enable_br') == 'yes' ? 1 : 0;
201 $this->setLinebreakConversion($linebreak_conversion);
207 * Nucleus sends its admin area pages as application/xhtml+xml to browsers that can handle this.
209 * Unfortunately, this causes javascripts that alter page contents through non-DOM methods
210 * to stop working correctly. As the jscalendar and htmlarea both need this, we're forcing
211 * the content-type to text/html for add/edit item forms.
213 function event_PreSendContentType(&$data)
215 $pageType = $data['pageType'];
216 if ($pageType == 'skin')
218 if ( ($pageType != 'bookmarklet-add')
219 && ($pageType != 'bookmarklet-edit')
220 && ($pageType != 'admin-createitem')
221 && ($pageType != 'admin-itemedit')
225 if ($data['contentType'] == 'application/xhtml+xml')
226 $data['contentType'] = 'text/html';