diff --git a/e107_plugins/tinymce/admin_config.php b/e107_plugins/tinymce/admin_config.php index c011f03de..bad5dcff0 100644 --- a/e107_plugins/tinymce/admin_config.php +++ b/e107_plugins/tinymce/admin_config.php @@ -9,8 +9,8 @@ * Plugin Administration - gsitemap * * $Source: /cvs_backup/e107_0.8/e107_plugins/tinymce/admin_config.php,v $ - * $Revision: 1.7 $ - * $Date: 2009-09-22 18:28:49 $ + * $Revision: 1.8 $ + * $Date: 2009-10-12 06:38:01 $ * $Author: e107coders $ * */ @@ -21,13 +21,525 @@ if(!getperms("P") || !plugInstalled('tinymce')) exit(); } + + + + +require_once(e_HANDLER."form_handler.php"); +require_once (e_HANDLER.'message_handler.php'); + +$frm = new e_form(true); + +$ef = new tinymce; //TODO save prefs to separate config row. // List all forms of access, and allow the user to choose between simple/advanced or 'custom' settings. +if(varset($_POST['update']) || varset($_POST['create'])) +{ + $id = intval($_POST['record_id']); + $ef->submitPage($id); +} + +if(varset($_POST['delete'])) +{ + $id = key($_POST['delete']); + $ef->deleteRecord($id); + $_GET['mode'] = "list"; +} + +if(isset($_POST['edit']) || $id) // define after db changes and before header loads. +{ + $id = (isset($_POST['edit'])) ? key($_POST['edit']) : $id; + define("TINYMCE_CONFIG",$id); +} +else +{ + define("TINYMCE_CONFIG",FALSE); +} + + +require_once(e_ADMIN."auth.php"); + +if(varset($_GET['mode'])=='create') +{ + $id = varset($_POST['edit']) ? key($_POST['edit']) : ""; + if($_POST['record_id']) + { + $id = $_POST['record_id']; + } + $ef->createRecord($id); +} +else +{ + $ef->listRecords(); +} + +if(isset($_POST['submit-e-columns'])) +{ + $user_pref['admin_release_columns'] = $_POST['e-columns']; + save_prefs('user'); +} + + +require_once(e_ADMIN."footer.php"); + + + +class tinymce +{ + var $fields; + var $fieldpref; + var $listQry; + var $table; + var $primary; + + + function __construct() + { + + $this->fields = array( + 'tinymce_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE, 'primary'=>TRUE), + 'tinymce_name' => array('title'=> 'name', 'width'=>'auto','type'=>'text'), + 'tinymce_userclass' => array('title'=> 'class', 'type' => 'array', 'method'=>'tinymce_class', 'width' => 'auto'), + 'tinymce_plugins' => array('title'=> 'plugins', 'type' => 'array', 'method'=>'tinymce_plugins', 'width' => 'auto'), + 'tinymce_buttons1' => array('title'=> 'buttons1', 'type' => 'text', 'method'=>'tinymce_buttons', 'methodparms'=>1, 'width' => 'auto'), + 'tinymce_buttons2' => array('title'=> 'buttons2', 'type' => 'text', 'method'=>'tinymce_buttons', 'methodparms'=>2, 'width' => 'auto'), + 'tinymce_buttons3' => array('title'=> 'buttons3', 'type' => 'text', 'method'=>'tinymce_buttons', 'methodparms'=>3, 'width' => 'auto', 'thclass' => 'left first'), + 'tinymce_buttons4' => array('title'=> 'buttons4', 'type' => 'text', 'method'=>'tinymce_buttons', 'methodparms'=>4, 'width' => 'auto', 'thclass' => 'left first'), + 'tinymce_custom' => array('title'=> 'custom', 'type' => 'text', 'width' => 'auto'), + 'tinymce_prefs' => array('title'=> 'prefs', 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), + 'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last') + ); + + $this->fieldpref = (varset($user_pref['admin_tinymce_columns'])) ? $user_pref['admin_tinymce_columns'] : array_keys($this->fields); + $this->table = "tinymce"; + $this->listQry = "SELECT * FROM #tinymce ORDER BY tinymce_id"; + $this->editQry = "SELECT * FROM #tinymce WHERE tinymce_id = {ID}"; + $this->primary = "tinymce_id"; + $this->pluginTitle = "Tinymce"; + + $this->listCaption = "Tinymce Configs"; + $this->createCaption = LAN_CREATE."/".LAN_EDIT; + + } + + +// -------------------------------------------------------------------------- + /** + * Generic DB Record Listing Function. + * @param object $mode [optional] + * @return + */ + function listRecords($mode=FALSE) + { + $ns = e107::getRender(); + $sql = e107::getDb(); + $frm = e107::getForm(); + + + global $pref; + + $emessage = eMessage::getInstance(); + + $text = "
+ "; + + $ns->tablerender($this->pluginTitle." :: ".$this->listCaption, $emessage->render().$text); + } + + /** + * Render Field value (listing page) + * @param object $key + * @param object $row + * @return + */ + function renderValue($key,$row) + { + $att = $this->fields[$key]; + + if($key == "options") + { + $id = $this->primary; + $text = ""; + $text .= ""; + return $text; + } + + switch($att['type']) + { + case 'url': + return "".$row[$key].""; + break; + + default: + return $row[$key]; + break; + } + return $row[$key] .$att['type']; + } + + /** + * Render Form Element (edit page) + * @param object $key + * @param object $row + * @return + */ + function renderElement($key,$row) + { + global $frm; + $att = $this->fields[$key]; + $value = $row[$key]; + + if($att['method']) + { + $meth = $att['method']; + if(isset($att['methodparms'])) + { + return $this->$meth($value,$att['methodparms']); + } + return $this->$meth($value); + } + + + return $frm->text($key, $row[$key], 50); + + } + + + + function createRecord($id=FALSE) + { + global $frm, $e_userclass, $e_event; + + $tp = e107::getParser(); + $ns = e107::getRender(); + $sql = e107::getDb(); + $mes = eMessage::getInstance(); + + if($id) + { + $query = str_replace("{ID}",$id,$this->editQry); + $sql->db_Select_gen($query); + $row = $sql->db_Fetch(MYSQL_ASSOC); + } + else + { + $row = array(); + } + + $text = " + "; + + $ns->tablerender($this->pluginTitle." :: ".$this->createCaption,$mes->render(). $text); + } + + + function tinymce_buttons($curVal,$id) + { + return "\n"; + } + + + function tinymce_preview() + { + return ""; + + } + + function tinymce_plugins($curVal) + { + $fl = e107::getFile(); + + $curArray = explode(",",$curVal); + + if($plug_array = $fl->get_dirs(e_PLUGIN."tinymce/plugins/")) + { + sort($plug_array); + } + + $text = "]*>/gi,"[quote]");b(/<\/blockquote>/gi,"[/quote]");b(/
/gi,"\n");b(/
/gi,"\n");b(/
/gi,"\n");b(//gi,"");b(/<\/p>/gi,"\n");b(/ /gi," ");b(/"/gi,'"');b(/</gi,"<");b(/>/gi,">");b(/&/gi,"&");return a},_punbb_bbcode2html:function(a){a=tinymce.trim(a);function b(c,d){a=a.replace(c,d)}b(/\n/gi,"
");b(/\[b\]/gi,"");b(/\[\/b\]/gi,"");b(/\[i\]/gi,"");b(/\[\/i\]/gi,"");b(/\[u\]/gi,"");b(/\[\/u\]/gi,"");b(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'$2');b(/\[url\](.*?)\[\/url\]/gi,'$1');b(/\[img\](.*?)\[\/img\]/gi,'');b(/\[color=(.*?)\](.*?)\[\/color\]/gi,'$2');b(/\[code\](.*?)\[\/code\]/gi,'$1 ');b(/\[quote.*?\](.*?)\[\/quote\]/gi,'$1 ');return a}});tinymce.PluginManager.add("bbcode",tinymce.plugins.BBCodePlugin)})(); \ No newline at end of file diff --git a/e107_plugins/tinymce/plugins/bbcode/editor_plugin_src.js b/e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js similarity index 84% rename from e107_plugins/tinymce/plugins/bbcode/editor_plugin_src.js rename to e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js index afcd1de5d..0787a1d8a 100644 --- a/e107_plugins/tinymce/plugins/bbcode/editor_plugin_src.js +++ b/e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js @@ -1,12 +1,12 @@ /** - * $Id: editor_plugin_src.js,v 1.2 2009-10-02 18:18:24 e107coders Exp $ + * $Id: editor_plugin.js,v 1.1 2009-10-12 06:38:01 e107coders Exp $ * * @author Moxiecode - * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. + * @copyright Copyright � 2004-2008, Moxiecode Systems AB, All rights reserved. */ (function() { - tinymce.create('tinymce.plugins.BBCodePlugin', { + tinymce.create('tinymce.plugins.e107BBCodePlugin', { init : function(ed, url) { var t = this, dialect = ed.getParam('bbcode_dialect', 'punbb').toLowerCase(); @@ -25,8 +25,8 @@ getInfo : function() { return { - longname : 'BBCode Plugin', - author : 'Moxiecode Systems AB', + longname : 'e107 BBCode Plugin', + author : 'Moxiecode Systems AB - Modified by e107 Inc', authorurl : 'http://tinymce.moxiecode.com', infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode', version : tinymce.majorVersion + "." + tinymce.minorVersion @@ -81,7 +81,14 @@ rep(/</gi,"<"); rep(/>/gi,">"); rep(/&/gi,"&"); - + + // e107 + rep(/
/gi,"[list]"); + rep(/<\/ul>/gi,"[/list]"); + rep(/
/gi,"[list=decimal]"); + rep(/<\/ol>/gi,"[/list]"); + rep(/
- /gi,"[*]"); + rep(/<\/li>/gi,"\n"); return s; }, @@ -108,10 +115,19 @@ rep(/\[code\](.*?)\[\/code\]/gi,"$1 "); rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"$1 "); + // e107 FIXME! + + rep(/\[list\]/gi,"
"); + rep(/\[\/list\]/gi,"
"); + + rep(/\[list=decimal\]/gi,""); + rep(/\[\/list\]/gi,"
"); + + return s; } }); // Register plugin - tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin); + tinymce.PluginManager.add('e107bbcode', tinymce.plugins.e107BBCodePlugin); })(); \ No newline at end of file diff --git a/e107_plugins/tinymce/tinymce_sql.php b/e107_plugins/tinymce/tinymce_sql.php new file mode 100644 index 000000000..6f49dde91 --- /dev/null +++ b/e107_plugins/tinymce/tinymce_sql.php @@ -0,0 +1,21 @@ +CREATE TABLE tinymce ( + `tinymce_id` int(5) NOT NULL AUTO_INCREMENT, + `tinymce_userclass` varchar(255) NOT NULL, + `tinymce_plugins` text NOT NULL, + `tinymce_buttons1` varchar(255) NOT NULL, + `tinymce_buttons2` varchar(255) NOT NULL, + `tinymce_buttons3` varchar(255) NOT NULL, + `tinymce_buttons4` varchar(255) NOT NULL, + `tinymce_custom` text NOT NULL, + `tinymce_prefs` text NOT NULL, + PRIMARY KEY (`tinymce_id`) +) TYPE=MyISAM; + +INSERT INTO tinymce ( +`tinymce_id`, `tinymce_name`, `tinymce_userclass`, `tinymce_plugins`, `tinymce_buttons1`, `tinymce_buttons2`, `tinymce_buttons3`, `tinymce_buttons4`, `tinymce_custom`, `tinymce_prefs`) VALUES +(1, 'Simple Users', '252', 'e107bbcode,emoticons', 'bold, italic, underline, undo, redo, link, unlink, image, forecolor, bullist, numlist, outdent, indent, emoticons', '', '', '', '', ''), +(2, 'Members', '253', 'e107bbcode,emoticons,table', 'bold, italic, underline, undo, redo, link, unlink, image, forecolor, removeformat, table, bullist, numlist, outdent, indent, emoticons', '', '', '', '', ''), +(3, 'Administrators', '254', 'contextmenu,e107bbcode,emoticons,ibrowser,iespell,paste,table,xhtmlxtras', 'bold, italic, underline, undo, redo, link, unlink, image, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, code, emoticons', '', '', '', '', ''), +(4, 'Main Admin', '250', 'advhr,advlink,autoresize,compat2x,contextmenu,directionality,emoticons,ibrowser,paste,table,visualchars,wordcount,xhtmlxtras,zoom', 'bold, italic, underline, undo, redo, link, unlink, ibrowser, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, code, emoticons', '', '', '', '', '' +); + diff --git a/e107_plugins/tinymce/wysiwyg.php b/e107_plugins/tinymce/wysiwyg.php index c2664977d..b1f62f59f 100644 --- a/e107_plugins/tinymce/wysiwyg.php +++ b/e107_plugins/tinymce/wysiwyg.php @@ -4,258 +4,343 @@ | e107 website system - Tiny MCE controller file. | | $Source: /cvs_backup/e107_0.8/e107_plugins/tinymce/wysiwyg.php,v $ -| $Revision: 1.16 $ -| $Date: 2009-10-02 18:50:59 $ +| $Revision: 1.17 $ +| $Date: 2009-10-12 06:38:01 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ -function wysiwyg($formids) -{ - $tinyMcePrefs = e107::getPlugConfig('tinymce')->getPref(); +class wysiwyg +{ + var $js; + var $config = array(); -global $pref,$HANDLERS_DIRECTORY,$PLUGINS_DIRECTORY,$IMAGES_DIRECTORY; - -$lang = e_LANGUAGE; -$tinylang = array( - "Arabic" => "ar", - "Danish" => "da", - "Dutch" => "nl", - "English" => "en", - "Farsi" => "fa", - "French" => "fr", - "German" => "de", - "Greek" => "el", - "Hebrew" => " ", - "Hungarian" => "hu", - "Italian" => "it", - "Japanese" => "ja", - "Korean" => "ko", - "Norwegian" => "nb", - "Polish" => "pl", - "Russian" => "ru", - "Slovak" => "sk", - "Spanish" => "es", - "Swedish" => "sv" -); - -if(!$tinylang[$lang]) -{ - $tinylang[$lang] = "en"; -} - -$admin_only = array("ibrowser","code"); - -foreach($tinyMcePrefs['plugins'] as $val) -{ - if(in_array($val,$admin_only) && !ADMIN) + + function wysiwyg($config=FALSE) { - continue; - } - - if(!$pref['smiley_activate'] && ($val=="emoticons")) - { - continue; - } - - $tinymce_plugins[] = $val; -} - - - -/* -if(strstr(varset($_SERVER["HTTP_ACCEPT_ENCODING"],""), "gzip") && (ini_get("zlib.output_compression") == false) && file_exists(e_PLUGIN."tinymce/tiny_mce_gzip.php")) -{ - //unset($tinymce_plugins[7]); // 'zoom' causes an error with the gzip version. - $text = " - - - "; -} -else -{*/ - $text = "\n"; -//} - - - -$text .= " + + + "; + } + else + {*/ + $text = "\n"; + //} + + + + $text .= "\n + "; + + $this->js = $text; + + } + + function tinymce_lang() + { + $lang = e_LANGUAGE; + $tinylang = array( + "Arabic" => "ar", + "Danish" => "da", + "Dutch" => "nl", + "English" => "en", + "Farsi" => "fa", + "French" => "fr", + "German" => "de", + "Greek" => "el", + "Hebrew" => " ", + "Hungarian" => "hu", + "Italian" => "it", + "Japanese" => "ja", + "Korean" => "ko", + "Norwegian" => "nb", + "Polish" => "pl", + "Russian" => "ru", + "Slovak" => "sk", + "Spanish" => "es", + "Swedish" => "sv" + ); + + if(!$tinylang[$lang]) + { + $tinylang[$lang] = "en"; + } + + return $tinylang[$lang]; + } + + + function tinyMce_config() + { + $text .= " + + function start_tinyMce() + { + //config as $key=>$val) + { + $text .= "\t\t ".$key." : '".$val."',\n"; + } + + if($tinyMcePrefs['customjs']) + { + $text .= "\n, + + // Start Custom TinyMce JS ----- + + ".$pref['tinymce']['customjs']." + + // End Custom TinyMce JS --- + + "; + + } + + $text .= " + }); + } - $text .= " +"; + + return $text; + } + + + + function getConfig($config=FALSE) + { + $sql = e107::getDb(); + + if($config) + { + $query = "SELECT * FROM #tinymce WHERE tinymce_id = ".$config." LIMIT 1"; + } + else + { + $query = "SELECT * FROM #tinymce WHERE tinymce_userclass REGEXP '".e_CLASS_REGEXP."' AND NOT (tinymce_userclass REGEXP '(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)') ORDER BY tinymce_userclass DESC LIMIT 1"; + } + + $sql -> db_Select_gen($query); + $config = $sql->db_Fetch(); + + //TODO Cache! + + $plug_array = explode(",",$config['tinymce_plugins']); + + + $this->config = array( + 'language' => $this->tinymce_lang(), + 'mode' => 'textareas', + 'editor_selector' => 'e-wysiwyg', + 'editor_deselector' => 'e-wysiwyg-off', + 'theme' => 'advanced', + 'plugins' => $this->filter_plugins($config['tinymce_plugins']) + ); + + $this->config += array( + + 'theme_advanced_buttons1' => $config['tinymce_buttons1'], + 'theme_advanced_buttons2' => $config['tinymce_buttons2'], + 'theme_advanced_buttons3' => $config['tinymce_buttons3'], + 'theme_advanced_buttons4' => $config['tinymce_buttons4'], + 'theme_advanced_toolbar_location' => 'bottom', + 'theme_advanced_toolbar_align' => 'center', + // 'theme_advanced_statusbar_location' => 'bottom', + 'theme_advanced_resizing' => 'true', + 'extended_valid_elements' => '', + 'invalid_elements' => 'p,font,align,script,applet,iframe', + 'auto_cleanup_word' => 'true', + 'convert_fonts_to_spans' => 'true', + 'trim_span_elements' => 'true', + 'inline_styles' => 'true', + 'debug' => 'false', + 'force_br_newlines' => 'true', + 'forced_root_block' => '', + 'force_p_newlines' => 'false', + 'entity_encoding' => 'raw', + 'convert_fonts_to_styles' => 'true', + 'remove_script_host' => 'true', + 'relative_urls' => 'true', + 'document_base_url' => SITEURL, + 'theme_advanced_styles' => 'border=border;fborder=fborder;tbox=tbox;caption=caption;fcaption=fcaption;forumheader=forumheader;forumheader3=forumheader3', + 'verify_css_classes' => 'false' - switch (type) { + ); + + if(!in_array('e107bbcode',$plug_array)) + { + $this->config['cleanup_callback'] = 'tinymce_html_bbcode_control'; + } + + + if($paste_plugin) + { + $this->config += array( + + 'remove_linebreaks' => 'false', // remove line break stripping by tinyMCE so that we can read the HTML + 'paste_create_paragraphs' => 'false', // for paste plugin - double linefeeds are converted to paragraph elements + 'paste_create_linebreaks' => 'false', // for paste plugin - single linefeeds are converted to hard line break elements + 'paste_use_dialog' => 'true', // for paste plugin - Mozilla and MSIE will present a paste dialog if true + 'paste_auto_cleanup_on_paste' => 'true', // for paste plugin - word paste will be executed when the user copy/paste content + 'paste_convert_middot_lists' => 'false', // for paste plugin - middot lists are converted into UL lists + 'paste_unindented_list_class' => 'unindentedList', // for paste plugin - specify what class to assign to the UL list of middot cl's + 'paste_convert_headers_to_strong' => 'true', // for paste plugin - converts H1-6 elements to strong elements on paste + 'paste_insert_word_content_callback' => 'convertWord', // for paste plugin - This callback is executed when the user pastes word content + 'auto_cleanup_word' => 'false' // auto clean pastes from Word + ); + } + + + if(ADMIN) + { + $this->config['external_link_list_url'] = e_PLUGIN_ABS."tiny_mce/filelist.php"; + } + - case 'get_from_editor': - // Convert HTML to e107-BBcode - source = source.replace(/target=\"_blank\"/, 'rel=\"external\"'); - source = source.replace(/^\s*|\s*$/g,''); - if(source != '') - { - source = '[html]\\n' + source + '\\n[/html]'; -/* - source = source.replace(/<\/strong>/gi,'[/b]'); - source = source.replace(//gi,'[b]'); - source = source.replace(/<\/em>/gi,'[/i]'); - source = source.replace(//gi,'[i]'); - source = source.replace(/<\/u>/gi,'[/u]'); - source = source.replace(//gi,'[u]'); - source = source.replace(/<\/strong>/gi,'[/b]'); - source = source.replace(//gi,'[/b]'); - source = source.replace(/(.*?)<\/a>/gi,'[link=$1 $2]$3[/link]'); -*/ - - } - - // Convert e107 paths. - source = source.replace(/\"".str_replace("/","\/",$IMAGES_DIRECTORY)."/g,'\"{e_IMAGE}'); - source = source.replace(/\"".str_replace("/","\/",$PLUGINS_DIRECTORY)."/g,'\"{e_PLUGIN}'); - source = source.replace(/\'".str_replace("/","\/",$IMAGES_DIRECTORY)."/g,'\'{e_IMAGE}'); - source = source.replace(/\'".str_replace("/","\/",$PLUGINS_DIRECTORY)."/g,'\'{e_PLUGIN}'); - - break; - - case 'insert_to_editor': - // Convert e107-BBcode to HTML - source = source.replace(/rel=\"external\"/, 'target=\"_blank\"'); - - html_bbcode_check = source.slice(0,6); - - if (html_bbcode_check == '[html]') { - source = source.slice(6); - } - - html_bbcode_check = source.slice(-7); - - if (html_bbcode_check == '[/html]') { - source = source.slice(0, -7); - } -/* - source = source.replace(/\[b\]/gi,''); - source = source.replace(/\[\/b\]/gi,'<\/strong>'); -*/ - source = source.replace(/\{e_IMAGE\}/gi,'".$IMAGES_DIRECTORY."'); - source = source.replace(/\{e_PLUGIN\}/gi,'".$PLUGINS_DIRECTORY."'); - - break; - } - - return source; + + } + + + function filter_plugins($plugs) + { + + $smile_pref = e107::getConfig()->getPref('smiley_activate'); + + $admin_only = array("ibrowser","code"); + + $plug_array = explode(",",$plugs); + + foreach($plug_array as $val) + { + if(in_array($val,$admin_only) && !ADMIN) + { + continue; + } + + if(!$smile_pref && ($val=="emoticons")) + { + continue; + } + + $tinymce_plugins[] = $val; + } + + return implode(",",$tinymce_plugins); + } + + + function render() + { + echo $this->js; + } } - // ]]> -function triggerSave() -{ - tinyMCE.triggerSave(); -} - - - - -\n -"; - -return $text; - -} - - -?> +?> \ No newline at end of file