diff --git a/e107_plugins/tinymce4/e_meta.php b/e107_plugins/tinymce4/e_meta.php
new file mode 100644
index 000000000..5e83bdf84
--- /dev/null
+++ b/e107_plugins/tinymce4/e_meta.php
@@ -0,0 +1,176 @@
+";
+ // $insert .= "Switch to bbcode<\/a>";
+
+ if(e_PAGE == 'mailout.php')
+ {
+ $insert .= " ".LAN_MAILOUT_16."<\/a>";
+ $insert .= "".LAN_MAILOUT_14."<\/a>";
+ $insert .= "".LAN_MAILOUT_17."<\/a>";
+ $insert .= "".LAN_MAILOUT_18."<\/a>";
+ }
+
+ $insert .= "');";
+
+ define("SWITCH_TO_BB",$insert);
+
+ }
+ else
+ {
+ define("SWITCH_TO_BB","");
+ }
+
+// print_a($_POST);
+
+ //
+
+
+ e107::js('inline',"
+
+ $(function() {
+
+
+
+
+
+ $('.e-wysiwyg').each(function() {
+
+ var id = $(this).attr('id'); // 'e-wysiwyg';
+ ".SWITCH_TO_BB."
+ // alert(id);
+ $('#bbcode-panel-'+id+'--preview').hide();
+
+ });
+
+ $('.tinyInsert').click(function() {
+
+ var val = $(this).attr('data-value');
+ top.tinymce.activeEditor.execCommand('mceInsertContent',0,val);
+ return false;
+ });
+
+ /*
+ $('img.tinyInsertEmote').live('click',function() {
+
+ var src = $(this).attr('src');
+ alert(src);
+ // var html = '
';
+ tinyMCE.execCommand('mceInsertRawHTML',false, 'hi there');
+ ;
+ $('.mceContentBody', window.top.document).tinymce().execCommand('mceInsertContent',false,src);
+
+ // tinyMCE.selectedInstance.execCommand('mceInsertContent',0,src);
+
+ $('#uiModal').modal('hide');
+ return true;
+ });*/
+
+
+
+
+ // When new tab is added - convert textarea to TinyMce.
+ $('.e-tabs-add').on('click',function(){
+
+ alert('New Page Added'); // added for delay - quick and dirty work-around. XXX fixme
+
+ var idt = $(this).attr('data-target'); // eg. news-body
+ var ct = parseInt($('#e-tab-count').val());
+ var id = idt + '-' + ct;
+ $('#bbcode-panel-'+id+'--preview').hide();
+ ".SWITCH_TO_BB."
+ top.tinymce.activeEditor.execCommand('mceAddControl', false, id);
+ });
+
+
+ $('a.e-wysiwyg-toggle').toggle(function(){
+ var id = $(this).attr('id'); // eg. news-body
+ $('#bbcode-panel-'+id+'--preview').show();
+ $(this).text('Switch to wysiwyg');
+ tinymce.activeEditor.execCommand('mceRemoveControl', false, id);
+ }, function () {
+ var id = $(this).attr('id');
+ $('#bbcode-panel-'+id+'--preview').hide();
+ $(this).text('Switch to bbcode');
+ tinymce.activeEditor.execCommand('mceAddControl', false, id);
+ });
+
+ $('.e-dialog-save').click(function(){
+
+ var html = $('#html_holder').val();
+
+ if(html === undefined)
+ {
+ return;
+ }
+
+ // tinyMCE.execCommand('mceInsertContent',false,html);
+ top.tinymce.activeEditor.execCommand('mceInsertRawHTML',false,html);
+ top.tinymce.activeEditor.windowManager.close();
+
+ });
+
+ $('.e-dialog-close').click(function(){
+
+ top.tinymce.activeEditor.windowManager.close();
+ });
+
+
+
+
+
+
+ });
+
+
+
+
+ ","jquery");
+
+
+}
+
+
+?>
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/plugin.xml b/e107_plugins/tinymce4/plugin.xml
new file mode 100644
index 000000000..dc2328c67
--- /dev/null
+++ b/e107_plugins/tinymce4/plugin.xml
@@ -0,0 +1,6 @@
+
+
+
+ Experimental TinyMce4 CDN version
+ misc
+
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/plugins/bbcode/plugin.js b/e107_plugins/tinymce4/plugins/bbcode/plugin.js
new file mode 100644
index 000000000..b3ac04b80
--- /dev/null
+++ b/e107_plugins/tinymce4/plugins/bbcode/plugin.js
@@ -0,0 +1,123 @@
+/**
+ * plugin.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+/*global tinymce:true */
+
+(function() {
+ tinymce.create('tinymce.plugins.BBCodePlugin', {
+ init : function(ed) {
+ var t = this, dialect = ed.getParam('bbcode_dialect', 'punbb').toLowerCase();
+
+ ed.on('beforeSetContent', function(e) {
+ e.content = t['_' + dialect + '_bbcode2html'](e.content);
+ });
+
+ ed.on('postProcess', function(e) {
+ if (e.set) {
+ e.content = t['_' + dialect + '_bbcode2html'](e.content);
+ }
+
+ if (e.get) {
+ e.content = t['_' + dialect + '_html2bbcode'](e.content);
+ }
+ });
+ },
+
+ getInfo: function() {
+ return {
+ longname: 'BBCode Plugin',
+ author: 'Moxiecode Systems AB',
+ authorurl: 'http://www.tinymce.com',
+ infourl: 'http://www.tinymce.com/wiki.php/Plugin:bbcode'
+ };
+ },
+
+ // Private methods
+
+ // HTML -> BBCode in PunBB dialect
+ _punbb_html2bbcode : function(s) {
+ s = tinymce.trim(s);
+
+ function rep(re, str) {
+ s = s.replace(re, str);
+ }
+
+ // example: to [b]
+ rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]");
+ rep(/(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
+ rep(/(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
+ rep(/(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
+ rep(/(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
+ rep(/(.*?)<\/span>/gi,"[color=$1]$2[/color]");
+ rep(/(.*?)<\/font>/gi,"[color=$1]$2[/color]");
+ rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]");
+ rep(/(.*?)<\/font>/gi,"$1");
+ rep(//gi,"[img]$1[/img]");
+ rep(/(.*?)<\/span>/gi,"[code]$1[/code]");
+ rep(/(.*?)<\/span>/gi,"[quote]$1[/quote]");
+ rep(/(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
+ rep(/(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]");
+ rep(/(.*?)<\/em>/gi,"[code][i]$1[/i][/code]");
+ rep(/(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]");
+ rep(/(.*?)<\/u>/gi,"[code][u]$1[/u][/code]");
+ rep(/(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]");
+ rep(/<\/(strong|b)>/gi,"[/b]");
+ rep(/<(strong|b)>/gi,"[b]");
+ rep(/<\/(em|i)>/gi,"[/i]");
+ rep(/<(em|i)>/gi,"[i]");
+ rep(/<\/u>/gi,"[/u]");
+ rep(/(.*?)<\/span>/gi,"[u]$1[/u]");
+ rep(//gi,"[u]");
+ rep(/]*>/gi,"[quote]");
+ rep(/<\/blockquote>/gi,"[/quote]");
+ rep(/
/gi,"\n");
+ rep(/
/gi,"\n");
+ rep(/
/gi,"\n");
+ rep(//gi,"");
+ rep(/<\/p>/gi,"\n");
+ rep(/ |\u00a0/gi," ");
+ rep(/"/gi,"\"");
+ rep(/</gi,"<");
+ rep(/>/gi,">");
+ rep(/&/gi,"&");
+
+ return s;
+ },
+
+ // BBCode -> HTML from PunBB dialect
+ _punbb_bbcode2html : function(s) {
+ s = tinymce.trim(s);
+
+ function rep(re, str) {
+ s = s.replace(re, str);
+ }
+
+ // example: [b] to
+ rep(/\n/gi,"
");
+ rep(/\[b\]/gi,"");
+ rep(/\[\/b\]/gi,"");
+ rep(/\[i\]/gi,"");
+ rep(/\[\/i\]/gi,"");
+ rep(/\[u\]/gi,"");
+ rep(/\[\/u\]/gi,"");
+ rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"$2");
+ rep(/\[url\](.*?)\[\/url\]/gi,"$1");
+ rep(/\[img\](.*?)\[\/img\]/gi,"
");
+ rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"$2");
+ rep(/\[code\](.*?)\[\/code\]/gi,"$1 ");
+ rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"$1 ");
+
+ return s;
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);
+})();
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/plugins/bbcode/plugin.min.js b/e107_plugins/tinymce4/plugins/bbcode/plugin.min.js
new file mode 100644
index 000000000..70a88a7d6
--- /dev/null
+++ b/e107_plugins/tinymce4/plugins/bbcode/plugin.min.js
@@ -0,0 +1 @@
+!function(){tinymce.create("tinymce.plugins.BBCodePlugin",{init:function(e){var t=this,n=e.getParam("bbcode_dialect","punbb").toLowerCase();e.on("beforeSetContent",function(e){e.content=t["_"+n+"_bbcode2html"](e.content)}),e.on("postProcess",function(e){e.set&&(e.content=t["_"+n+"_bbcode2html"](e.content)),e.get&&(e.content=t["_"+n+"_html2bbcode"](e.content))})},getInfo:function(){return{longname:"BBCode Plugin",author:"Moxiecode Systems AB",authorurl:"http://www.tinymce.com",infourl:"http://www.tinymce.com/wiki.php/Plugin:bbcode"}},_punbb_html2bbcode:function(e){function t(t,n){e=e.replace(t,n)}return e=tinymce.trim(e),t(/(.*?)<\/a>/gi,"[url=$1]$2[/url]"),t(/(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),t(/(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),t(/(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),t(/(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),t(/(.*?)<\/span>/gi,"[color=$1]$2[/color]"),t(/(.*?)<\/font>/gi,"[color=$1]$2[/color]"),t(/(.*?)<\/span>/gi,"[size=$1]$2[/size]"),t(/(.*?)<\/font>/gi,"$1"),t(//gi,"[img]$1[/img]"),t(/(.*?)<\/span>/gi,"[code]$1[/code]"),t(/(.*?)<\/span>/gi,"[quote]$1[/quote]"),t(/(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"),t(/(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]"),t(/(.*?)<\/em>/gi,"[code][i]$1[/i][/code]"),t(/(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]"),t(/(.*?)<\/u>/gi,"[code][u]$1[/u][/code]"),t(/(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]"),t(/<\/(strong|b)>/gi,"[/b]"),t(/<(strong|b)>/gi,"[b]"),t(/<\/(em|i)>/gi,"[/i]"),t(/<(em|i)>/gi,"[i]"),t(/<\/u>/gi,"[/u]"),t(/(.*?)<\/span>/gi,"[u]$1[/u]"),t(//gi,"[u]"),t(/]*>/gi,"[quote]"),t(/<\/blockquote>/gi,"[/quote]"),t(/
/gi,"\n"),t(/
/gi,"\n"),t(/
/gi,"\n"),t(//gi,""),t(/<\/p>/gi,"\n"),t(/ |\u00a0/gi," "),t(/"/gi,'"'),t(/</gi,"<"),t(/>/gi,">"),t(/&/gi,"&"),e},_punbb_bbcode2html:function(e){function t(t,n){e=e.replace(t,n)}return e=tinymce.trim(e),t(/\n/gi,"
"),t(/\[b\]/gi,""),t(/\[\/b\]/gi,""),t(/\[i\]/gi,""),t(/\[\/i\]/gi,""),t(/\[u\]/gi,""),t(/\[\/u\]/gi,""),t(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'$2'),t(/\[url\](.*?)\[\/url\]/gi,'$1'),t(/\[img\](.*?)\[\/img\]/gi,'
'),t(/\[color=(.*?)\](.*?)\[\/color\]/gi,'$2'),t(/\[code\](.*?)\[\/code\]/gi,'$1 '),t(/\[quote.*?\](.*?)\[\/quote\]/gi,'$1 '),e}}),tinymce.PluginManager.add("bbcode",tinymce.plugins.BBCodePlugin)}();
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/plugins/e107/dialog.htm b/e107_plugins/tinymce4/plugins/e107/dialog.htm
new file mode 100644
index 000000000..d6f2856aa
--- /dev/null
+++ b/e107_plugins/tinymce4/plugins/e107/dialog.htm
@@ -0,0 +1,22 @@
+
+
+
+ {#example_dlg.title}
+
+
+
+
+
+
+
+
+
diff --git a/e107_plugins/tinymce4/plugins/e107/dialog.php b/e107_plugins/tinymce4/plugins/e107/dialog.php
new file mode 100644
index 000000000..0b951241e
--- /dev/null
+++ b/e107_plugins/tinymce4/plugins/e107/dialog.php
@@ -0,0 +1,489 @@
+' + buttonText + '
';
+ // alert(html);
+ tinyMCEPopup.editor.execCommand('mceInsertContent', false, html);
+ tinyMCEPopup.close();
+ });
+
+
+ $('span.label, span.badge').click(function () {
+ var cls = $(this).attr('class');
+ var html = '' + $(this).text() + ' ';
+ tinyMCEPopup.editor.execCommand('mceInsertContent', false, html);
+ tinyMCEPopup.close();
+ });
+
+
+ $('ul.glyphicons li, #glyph-save').click(function () {
+
+ var color = $('#glyph-color').val();
+ var custom = $('#glyph-custom').val();
+ var cls = (custom != '') ? custom : $(this).find('i').attr('class');
+
+ var html = ' ';
+
+ // alert(html);
+ tinyMCEPopup.editor.execCommand('mceInsertContent', false, html);
+ tinyMCEPopup.close();
+ });
+
+ $('#bbcodeInsert').click(function ()
+ {
+ s = $('#bbcodeValue').val();
+ s = s.trim(s);
+
+ var html = $.ajax({
+ type: 'POST',
+ url: './parser.php',
+ data: { content: s, mode: 'tohtml' },
+ async : false,
+
+ dataType: 'html',
+ success: function(html) {
+ return html;
+ }
+ }).responseText;
+
+ html = '' + html + ' ' ;
+
+ tinyMCEPopup.editor.execCommand('mceInsertContent', false, html);
+ tinyMCEPopup.close();
+ });
+
+ $('a.bbcodeSelect').click(function () {
+ var html = $(this).html();
+ $('#bbcodeValue').val(html);
+ });
+
+ $('#e-cancel').click(function () {
+
+ tinyMCEPopup.close();
+ });
+
+});
+
+
+",'jquery');
+
+
+class e_bootstrap
+{
+
+ private $styleClasses = array(''=>'Default', 'primary'=>"Primary", 'success'=>"Success", 'info'=>"Info", 'warning'=>"Warning",'danger'=>"Danger",'inverse'=>"Inverse");
+
+
+
+ function init()
+ {
+ $ns = e107::getRender();
+
+
+ if(e_QUERY == 'bbcode')
+ {
+ echo $this->bbcodeForm();
+ return;
+ }
+
+
+
+
+ $text = "
Warning: These will only work if you have a bootstrap-based theme installed
";
+
+
+ $text .= '
+ ';
+
+ $text .= '';
+
+ $text .= '
'.$this->buttonForm().'
';
+
+ $text .= '
'.$this->badgeForm().'
';
+
+ $text .= '
'.$this->glyphicons().'
';
+
+
+ $text .= '
';
+
+ echo $text;
+
+ }
+
+
+
+
+
+
+ function buttonForm()
+ {
+ $frm = e107::getForm();
+
+ $buttonSizes = array(''=>'Default', 'btn-mini'=>"Mini", 'btn-small'=>"Small", 'btn-large' => "Large");
+
+ $buttonTypes = $this->styleClasses;
+
+ $butSelect = "";
+ $butSelect .= "";
+ foreach($buttonTypes as $type=>$diz)
+ {
+
+ $label = '';
+ $butSelect .= $frm->radio('buttonType', $type, false, array('label'=>$label));
+
+ }
+ $butSelect .= "
";
+
+ $butSize = "";
+
+ foreach($buttonSizes as $size=>$label)
+ {
+ $selected = ($size == '') ? true : false;
+ $butSize .= $frm->radio('buttonSize', $size, $selected, array('label'=>$label));
+ }
+ $butSize .= "
";
+
+
+
+ $text = "
+
+
+ Button Style |
+ ".$butSelect." |
+
+
+ Button Size |
+ ".$butSize." |
+
+
+ Button Text |
+ ".$frm->text('buttonText',$value,50)." |
+
+
+ Button Url |
+ ".$frm->text('buttonUrl','',255,'size=xxlarge')." |
+
+
+
+
+
+ ". $frm->admin_button('insertButton','save','other',"Insert") ."
+
+
";
+
+
+ return $text;
+
+ }
+
+
+
+ function badgeForm()
+ {
+ unset($this->styleClasses['primary']);
+
+ foreach($this->styleClasses as $key=>$type)
+ {
+ $classLabel = ($key != '') ? " label-".$key : "";
+ $classBadge = ($key != '') ? " badge-".$key : "";
+
+ $text .= ''.$type.' ';
+ $text .= ''.$type.'';
+ $text .= "
";
+ }
+
+ return $text;
+
+ }
+
+
+ function bbcodeForm()
+ {
+ $list = e107::getPref('bbcode_list');
+
+ $text .= "
+ e107 Bbcodes
+
+
+ Plugin |
+ Bbcode |
+
+ ";
+ foreach($list as $plugin=>$val)
+ {
+ $text .= "".$plugin." |
+ ";
+
+ foreach($val as $bb=>$v)
+ {
+ $text .= "[".$bb."][/".$bb."]";
+ }
+ $text .= " |
+
";
+ }
+
+ $text .= "
+
";
+
+ $frm = e107::getForm();
+ $text .= $frm->text('bbcodeValue','',false,'size=xlarge');
+ $text .= $frm->button('bbcodeInsert','go','other','Insert');
+
+
+ return $text;
+
+
+ }
+
+
+
+ function glyphicons()
+ {
+ $icons = array(
+ "icon-glass",
+ "icon-music",
+ "icon-search",
+ "icon-envelope",
+ "icon-heart",
+ "icon-star",
+ "icon-star-empty",
+ "icon-user",
+ "icon-film",
+ "icon-th-large",
+ "icon-th",
+ "icon-th-list",
+ "icon-ok",
+ "icon-remove",
+ "icon-zoom-in",
+ "icon-zoom-out",
+ "icon-off",
+ "icon-signal",
+ "icon-cog",
+ "icon-trash",
+ "icon-home",
+ "icon-file",
+ "icon-time",
+ "icon-road",
+ "icon-download-alt",
+ "icon-download",
+ "icon-upload",
+ "icon-inbox",
+ "icon-play-circle",
+ "icon-repeat",
+ "icon-refresh",
+ "icon-list-alt",
+ "icon-lock",
+ "icon-flag",
+ "icon-headphones",
+ "icon-volume-off",
+ "icon-volume-down",
+ "icon-volume-up",
+ "icon-qrcode",
+ "icon-barcode",
+ "icon-tag",
+ "icon-tags",
+ "icon-book",
+ "icon-bookmark",
+ "icon-print",
+ "icon-camera",
+ "icon-font",
+ "icon-bold",
+ "icon-italic",
+ "icon-text-height",
+ "icon-text-width",
+ "icon-align-left",
+ "icon-align-center",
+ "icon-align-right",
+ "icon-align-justify",
+ "icon-list",
+
+ "icon-indent-left",
+ "icon-indent-right",
+ "icon-facetime-video",
+ "icon-picture",
+ "icon-pencil",
+ "icon-map-marker",
+ "icon-adjust",
+ "icon-tint",
+ "icon-edit",
+ "icon-share",
+ "icon-check",
+ "icon-move",
+ "icon-step-backward",
+ "icon-fast-backward",
+ "icon-backward",
+ "icon-play",
+ "icon-pause",
+ "icon-stop",
+ "icon-forward",
+ "icon-fast-forward",
+ "icon-step-forward",
+ "icon-eject",
+ "icon-chevron-left",
+ "icon-chevron-right",
+ "icon-plus-sign",
+ "icon-minus-sign",
+ "icon-remove-sign",
+ "icon-ok-sign",
+
+ "icon-question-sign",
+ "icon-info-sign",
+ "icon-screenshot",
+ "icon-remove-circle",
+ "icon-ok-circle",
+ "icon-ban-circle",
+ "icon-arrow-left",
+ "icon-arrow-right",
+ "icon-arrow-up",
+ "icon-arrow-down",
+ "icon-share-alt",
+ "icon-resize-full",
+ "icon-resize-small",
+ "icon-plus",
+ "icon-minus",
+ "icon-asterisk",
+ "icon-exclamation-sign",
+ "icon-gift",
+ "icon-leaf",
+ "icon-fire",
+ "icon-eye-open",
+ "icon-eye-close",
+ "icon-warning-sign",
+ "icon-plane",
+ "icon-calendar",
+ "icon-random",
+ "icon-comment",
+ "icon-magnet",
+
+ "icon-chevron-up",
+ "icon-chevron-down",
+ "icon-retweet",
+ "icon-shopping-cart",
+ "icon-folder-close",
+ "icon-folder-open",
+ "icon-resize-vertical",
+ "icon-resize-horizontal",
+ "icon-hdd",
+ "icon-bullhorn",
+ "icon-bell",
+ "icon-certificate",
+ "icon-thumbs-up",
+ "icon-thumbs-down",
+ "icon-hand-right",
+ "icon-hand-left",
+ "icon-hand-up",
+ "icon-hand-down",
+ "icon-circle-arrow-right",
+ "icon-circle-arrow-left",
+ "icon-circle-arrow-up",
+ "icon-circle-arrow-down",
+ "icon-globe",
+ "icon-wrench",
+ "icon-tasks",
+ "icon-filter",
+ "icon-briefcase",
+ "icon-fullscreen"
+ );
+
+ $frm = e107::getForm();
+ $sel = array(''=>'Dark Gray','icon-white'=>'White');
+
+ $text .= "";
+ $text .= "
Color: ".$frm->select('glyph-color',$sel)." Custom: ".$frm->text('glyph-custom','').$frm->button('glyph-save','Go')."
";
+
+ $text .= "
";
+
+ $inverse = (e107::getPref('admincss') == "admin_dark.css") ? " icon-white" : "";
+
+ foreach($icons as $ic)
+ {
+ $text .= '- '.$ic.'
';
+ $text .= "\n";
+ }
+
+ $text .= "
";
+ $text .= "
";
+
+ return $text;
+
+}
+
+
+
+
+
+
+
+
+
+
+}
+
+
+require_once(e_ADMIN."auth.php");
+//e107::lan('core','admin',TRUE);
+
+
+$bootObj = new e_bootstrap;
+$bootObj->init();
+
+
+
+
+
+require_once(e_ADMIN."footer.php");
+exit;
+//
+
+
+?>
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/plugins/e107/editor_plugin.js b/e107_plugins/tinymce4/plugins/e107/editor_plugin.js
new file mode 100644
index 000000000..535708c20
--- /dev/null
+++ b/e107_plugins/tinymce4/plugins/e107/editor_plugin.js
@@ -0,0 +1,323 @@
+/**
+ * $Id$
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
+ */
+
+(function() {
+ tinymce.create('tinymce.plugins.e107BBCodePlugin', {
+ init : function(ed, url) {
+
+ // Bootstrap
+ ed.addCommand('mceBoot', function() {
+ ed.windowManager.open({
+ file : url + '/dialog.php',
+ width : 900 , // + parseInt(ed.getLang('e107bbcode.delta_width', 0)),
+ height : 450, // + parseInt(ed.getLang('e107bbcode.delta_height', 0)),
+ inline : 1
+ }, {
+ plugin_url : url, // Plugin absolute URL
+ some_custom_arg : 'custom arg' // Custom argument
+ });
+ });
+
+ // Register button
+ ed.addButton('bootstrap', {
+ title : 'Insert Bootstrap Elements',
+ cmd : 'mceBoot',
+ image : url + '/img/bootstrap.png'
+ });
+
+ // e107 Bbcode
+ ed.addCommand('mcee107', function() {
+ ed.windowManager.open({
+ file : url + '/dialog.php?bbcode',
+ width : 900 , // + parseInt(ed.getLang('e107bbcode.delta_width', 0)),
+ height : 450, // + parseInt(ed.getLang('e107bbcode.delta_height', 0)),
+ inline : 1
+ }, {
+ plugin_url : url, // Plugin absolute URL
+ some_custom_arg : 'custom arg' // Custom argument
+ });
+ });
+
+ // Register button
+ ed.addButton('e107bbcode', {
+ title : 'Insert e107 Bbcode',
+ cmd : 'mcee107',
+ image : url + '/img/bbcode.png'
+ });
+
+
+
+ // Add a node change handler, selects the button in the UI when a image is selected
+ // ed.onNodeChange.add(function(ed, cm, n) {
+ // cm.setActive('example', n.nodeName == 'IMG');
+ // });
+
+
+ // ------------
+
+
+ var t = this, dialect = ed.getParam('bbcode_dialect', 'e107').toLowerCase();
+
+ ed.onBeforeSetContent.add(function(ed, o) {
+
+ o.content = t['_' + dialect + '_bbcode2html'](o.content,url);
+ });
+
+ ed.onPostProcess.add(function(ed, o) {
+ if (o.set)
+ o.content = t['_' + dialect + '_bbcode2html'](o.content,url);
+
+ if (o.get)
+ o.content = t['_' + dialect + '_html2bbcode'](o.content,url);
+ });
+ },
+
+ getInfo : function() {
+ return {
+ longname : 'e107 BBCode Plugin',
+ author : 'Moxiecode Systems AB - Modified by e107 Inc',
+ authorurl : 'http://e107.org',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ },
+
+ // Private methods
+
+ // HTML -> BBCode in PunBB dialect
+ _e107_html2bbcode : function(s,url) {
+ s = tinymce.trim(s);
+
+
+ var p = $.ajax({
+ type: "POST",
+ url: url + "/parser.php",
+ data: { content: s, mode: 'tobbcode' },
+ async : false,
+
+ dataType: "html",
+ success: function(html) {
+ return html;
+ }
+ }).responseText;
+
+ return p;
+
+
+
+
+ function rep(re, str) {
+ s = s.replace(re, str);
+ };
+
+ // return s;
+
+ rep(//gim, "[table]");
+ rep(/<\/table>/gim, "[/table]");
+ rep(//gim, "[td]");
+ rep(/<\/td>/gim, "[/td]");
+ rep(/ | /gim, "[tr]");
+ rep(/<\/tr>/gim, "[/tr]");
+ rep(/
/gim, "[tbody]");
+ rep(/<\/tbody>/gim, "[/tbody]");
+
+
+ rep(/([\s\S]*)<\/div>/gi,"[center]$1[/center]"); // verified
+
+ rep(/
/gi, "[*]"); // verified
+ rep(/<\/li>/gi, ""); // verified
+ rep(/([\s\S]*?)<\/ul>\n/gim, "[list]$1[/list]"); // verified
+
+ rep(/([\s\S]*)<\/ol>/gim,"[list=$1]$2[/list]\n"); // verified
+ rep(/([\s\S]*?)<\/ol>/gim,"[list=decimal]$1[/list]\n"); // verified
+ rep(/([\s\S]*)<\/span>/gi,"[color=$1]$2[/color]"); // verified
+ rep(//gim, "[h]"); // verified
+ rep(/<\/h2>/gim, "[/h]"); // verified
+
+
+ // example: to [b]
+ rep(/(.*?)<\/a>/gi,"[link=$1]$2[/link]");
+ rep(/(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
+ rep(/(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
+ rep(/(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
+ rep(/(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
+ rep(/(.*?)<\/span>/gi,"[color=$1]$2[/color]");
+ rep(/(.*?)<\/font>/gi,"[color=$1]$2[/color]");
+ rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]");
+ rep(/(.*?)<\/font>/gi,"$1");
+
+ // rep(//gi,"[img style=$1]$2[/img]");
+
+
+ // New Image Handler // verified
+ // rep(/
/gi,"[img style=$1;width:$4px;height:$5px]$2[/img]" );
+
+ //rep(/
/gi,"[img style=$1;width:$4px;height:$5px]$2[/img]" )
+ rep(/
/gm,"[img style=width:$4px;height:$5px;$1]$2[/img]" );
+ rep(/;width:px;height:px/gi, ""); // Img cleanup.
+ // rep(/
/gi,"[img]$1[/img]");
+
+ rep(/]*>/gi,"[blockquote]");
+ rep(/<\/blockquote>/gi,"[/blockquote]");
+
+ rep(/]*>/gi,"[code]");
+ rep(/<\/code>/gi,"[/code]");
+
+ // rep(/(.*?)<\/span>/gi,"[code]$1[/code]");
+ // rep(/(.*?)<\/span>/gi,"[quote]$1[/quote]");
+ // rep(/(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
+ // rep(/(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]");
+ // rep(/(.*?)<\/em>/gi,"[code][i]$1[/i][/code]");
+ // rep(/(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]");
+ // rep(/(.*?)<\/u>/gi,"[code][u]$1[/u][/code]");
+ // rep(/(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]");
+
+ rep(/<\/(strong|b)>/gi,"[/b]");
+ rep(/<(strong|b)>/gi,"[b]");
+ rep(/<\/(em|i)>/gi,"[/i]");
+ rep(/<(em|i)>/gi,"[i]");
+ rep(/<\/u>/gi,"[/u]");
+ rep(/(.*?)<\/span>/gi,"[u]$1[/u]");
+ rep(//gi,"[u]");
+
+
+ // Compromise - but BC issues for sure.
+ // rep(/
/gi,"[br]");
+ // rep(/
/gi,"[br]");
+ // rep(/
/gi,"[br]");
+
+ rep(/
/gi,"\n");
+ rep(/
/gi,"\n");
+ rep(/
/gi,"\n");
+
+
+ rep(//gi,"");
+ rep(/<\/p>/gi,"\n");
+ rep(/ /gi," ");
+ rep(/"/gi,"\"");
+ rep(/</gi,"<");
+ rep(/>/gi,">");
+ rep(/&/gi,"&");
+
+ // e107
+
+
+ return s;
+ },
+
+ // BBCode -> HTML from PunBB dialect
+ _e107_bbcode2html : function(s,url) {
+ s = tinymce.trim(s);
+
+ var p = $.ajax({
+ type: "POST",
+ url: url + "/parser.php",
+ data: { content: s, mode: 'tohtml' },
+ async : false,
+
+ dataType: "html",
+ success: function(html) {
+ return html;
+ }
+ }).responseText;
+
+ return p;
+
+
+ return s;
+
+
+ function rep(re, str) {
+ s = s.replace(re, str);
+ };
+
+
+ // example: [b] to
+
+ // rep(/(\r|\n)?/gim, ""); // remove line-breaks
+ // rep(/<\/li>(\r|\n)?/gim, "
"); // remove line-breaks
+ // rep(/<\/ul>(\r|\n)?/gim, ""); // remove line-breaks
+
+ rep(/\[table]/gim, "
");
+ rep(/\[\/table]/gim, "
");
+ rep(/\[td]/gim, "
");
+ rep(/\[\/td]/gim, " | ");
+ rep(/\[tr]/gim, "
");
+ rep(/\[\/tr]/gim, "
");
+ rep(/\[tbody]/gim, "
");
+ rep(/\[\/tbody]/gim, "");
+
+ rep(/\[h]/gim, "
"); // verified
+ rep(/\[\/h]/gim, "
"); // verified
+
+ rep(/\[list](?:\n)/gim, "
\n"); // verified
+ // rep(/\[list]/gim, ""); // verified
+
+ rep(/\[\/list](?:\n)?/gim, "
\n"); // verified
+ rep(/^ *?(?:\*|\[\*\])([^\*[]*)/gm,"- $1
\n");
+ // return s;
+ // rep(/(\[list=.*\])\\*([\s\S]*)(\[\/list])(\n|\r)/gim,"$2
"); // verified
+ // rep(/(\[list\])\\*([\s\S]*)(\[\/list])(\n|\r)?/gim,"");// verified
+
+
+ rep(/\[center\]([\s\S]*)\[\/center\]/gi,"$1
"); // verified
+ rep(/\[color=(.*?)\]([\s\S]*)\[\/color\]/gi,"$2<\/span>"); // verified
+
+ // rep(/\[br]/gi,"
"); // compromise
+
+ rep(/\[blockquote\]/gi,"");
+ rep(/\[\/blockquote\]/gi,"
");
+
+ rep(/\[code\]/gi,"");
+ rep(/\[\/code\]/gi,"
");
+
+ //rep( /(?" )
+
+
+ rep(/\[b\]/gi,"");
+ rep(/\[\/b\]/gi,"");
+ rep(/\[i\]/gi,"");
+ rep(/\[\/i\]/gi,"");
+ rep(/\[u\]/gi,"");
+ rep(/\[\/u\]/gi,"");
+ rep(/\[link=([^\]]+)\](.*?)\[\/link\]/gi,"$2");
+ rep(/\[url\](.*?)\[\/url\]/gi,"$1");
+ // rep(/\[img.*?style=(.*?).*?\](.*?)\[\/img\]/gi,"
");
+
+ // When Width and Height are present:
+ rep(/\[img\s*?style=(?:width:(\d*)px;height:(\d*)px;)([^\]]*)]([\s\S]*?)\[\/img]/gm, "
");
+
+ // No width/height but style is present
+ rep(/\[img\s*?style=([^\]]*)]([\s\S]*?)\[\/img]/gi,"
");
+
+ rep(/\[img\](.*?)\[\/img\]/gi,"
");
+ // rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"$2");
+ // rep(/\[code\](.*?)\[\/code\]/gi,"$1 ");
+ // rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"$1 ");
+
+ // rep(/
/gm, "
\n");
+ rep(/(\r|\n)$/gim,"
");
+ // rep(/(\r|\n)/gim,"
\n"); // this will break bullets.
+
+
+ // e107 FIXME!
+
+
+ // rep("/\[list\](.+?)\[\/list\]/is", '');
+
+
+
+
+//
+
+ return s;
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('e107bbcode', tinymce.plugins.e107BBCodePlugin);
+})();
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/plugins/e107/img/logo-bootstrap.png b/e107_plugins/tinymce4/plugins/e107/img/logo-bootstrap.png
new file mode 100644
index 000000000..14b6ee21b
Binary files /dev/null and b/e107_plugins/tinymce4/plugins/e107/img/logo-bootstrap.png differ
diff --git a/e107_plugins/tinymce4/plugins/e107/mediamanager.php b/e107_plugins/tinymce4/plugins/e107/mediamanager.php
new file mode 100644
index 000000000..ed3e75673
--- /dev/null
+++ b/e107_plugins/tinymce4/plugins/e107/mediamanager.php
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/plugins/e107/parser.php b/e107_plugins/tinymce4/plugins/e107/parser.php
new file mode 100644
index 000000000..f05690f82
--- /dev/null
+++ b/e107_plugins/tinymce4/plugins/e107/parser.php
@@ -0,0 +1,145 @@
+htmltoBBcode($content); //XXX This breaks inserted images from media-manager. :/
+ e107::getBB()->setClass($_SESSION['media_category']);
+
+ if(check_class($pref['post_html'])) // raw HTML within [html] tags.
+ {
+
+ if(strstr($content,"[html]") === false) // BC - convert old BB code text to html.
+ {
+ e107::getBB()->clearClass();
+
+ $content = str_replace('\r\n',"
",$content);
+ $content = nl2br($content, true);
+ $content = $tp->toHtml($content, true);
+ }
+
+ $content = str_replace("{e_BASE}","",$content); // We want {e_BASE} in the final data going to the DB, but not the editor.
+ $srch = array("","","[html]","[/html]");
+ $content = str_replace($srch,"",$content);
+ $content = e107::getBB()->parseBBCodes($content); // parse the tag so we see the HTML equivalent while editing!
+ echo $content;
+ }
+ else // bbcode Mode.
+ {
+
+ // XXX @Cam this breaks new lines, currently we use \n instead [br]
+ //echo $tp->toHtml(str_replace("\n","",$content), true);
+
+ $content = str_replace("{e_BASE}",e_HTTP, $content); // We want {e_BASE} in the final data going to the DB, but not the editor.
+ $content = $tp->toHtml($content, true);
+ $content = str_replace(e_MEDIA_IMAGE,"{e_MEDIA_IMAGE}",$content);
+
+ echo $content;
+ }
+
+ e107::getBB()->clearClass();
+}
+
+if($_POST['mode'] == 'tobbcode')
+{
+ // echo $_POST['content'];
+ $content = stripslashes($_POST['content']);
+
+ if(check_class($pref['post_html'])) // Plain HTML mode.
+ {
+ $srch = array('src="'.e_HTTP.'thumb.php?','src="/{e_MEDIA_IMAGE}');
+ $repl = array('src="{e_BASE}thumb.php?','src="{e_BASE}thumb.php?src=e_MEDIA_IMAGE/');
+ $content = str_replace($srch, $repl, $content);
+
+ // resize the thumbnail to match wysiwyg width/height.
+
+ // $psrch = '/
]*src="{e_BASE}thumb.php\?src=([\S]*)w=([\d]*)&h=([\d]*)"(.*)width="([\d]*)" height="([\d]*)"/i';
+ // $prepl = '
parseBBTags($content,true); // replace html with bbcode equivalent
+
+ echo ($content) ? "[html]".$content."[/html]" : ""; // Add the tags before saving to DB.
+ }
+ else // bbcode Mode. //XXX Disabled at the moment in tinymce/e_meta.php - post_html is required to activate.
+ {
+ // [img width=400]/e107_2.0/thumb.php?src={e_MEDIA_IMAGE}2012-12/e107org_white_stripe.png&w=400&h=0[/img]
+ // $content = str_replace("{e_BASE}","", $content); // We want {e_BASE} in the final data going to the DB, but not the editor.
+
+ echo e107::getBB()->htmltoBBcode($content); // not reliable enough yet.
+ }
+
+}
+
+/**
+ * Rebuld
tags with modified thumbnail size.
+ */
+function updateImg($text)
+{
+
+ $arr = e107::getParser()->getTags($text,'img');
+
+ $srch = array("?","&");
+ $repl = array("\?","&");
+
+ foreach($arr['img'] as $img)
+ {
+ $regexp = '#(
]*src="'.str_replace($srch, $repl, $img['src']).'"[^>]*>)#';
+
+ $width = vartrue($img['width']) ? ' width="'.$img['width'].'"' : '';
+ $height = vartrue($img['height']) ? ' height="'.$img['height'].'"' : '';
+ $style = vartrue($img['style']) ? ' style="'.$img['style'].'"' : '';
+ $class = vartrue($img['class']) ? ' class="'.$img['class'].'"' : '';
+ $alt = vartrue($img['alt']) ? ' alt="'.$img['alt'].'"' : '';
+
+ list($url,$qry) = explode("?",$img['src']);
+
+ parse_str($qry,$qr);
+
+ $qr['w'] = $img['width'];
+ $qr['h'] = $img['height'];
+
+ $src = $url."?".urldecode(http_build_query($qr));
+
+ $replacement = '
';
+
+ $text = preg_replace($regexp, $replacement, $text);
+
+
+ }
+
+ return $text;
+
+}
+
+?>
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/plugins/e107/plugin.js b/e107_plugins/tinymce4/plugins/e107/plugin.js
new file mode 100644
index 000000000..ab38822f2
--- /dev/null
+++ b/e107_plugins/tinymce4/plugins/e107/plugin.js
@@ -0,0 +1,180 @@
+/**
+ * plugin.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+/*global tinymce:true */
+
+(function() {
+ tinymce.create('tinymce.plugins.e107Plugin', {
+
+
+ init : function(ed,url) {
+
+
+
+ var t = this, dialect = ed.getParam('bbcode_dialect', 'e107').toLowerCase();
+
+
+ ed.on('beforeSetContent', function(e) {
+ e.content = t['_' + dialect + '_bbcode2html'](e.content, url);
+ });
+
+
+
+
+ ed.on('postProcess', function(e) {
+ if (e.set) {
+ e.content = t['_' + dialect + '_bbcode2html'](e.content, url);
+ }
+
+ if (e.get) {
+ e.content = t['_' + dialect + '_html2bbcode'](e.content, url);
+ }
+ });
+
+
+ // Emoticons
+ ed.addButton('e107-emotes', {
+ text: 'Media Manager',
+ icon: 'emoticons',
+ onclick: function() {
+ // Open window
+
+ ed.windowManager.open({
+ title: 'Example plugin',
+ body: [
+ {type: 'textbox', name: 'title', label: 'Title'}
+ ],
+ onsubmit: function(e) {
+ // Insert content when the window form is submitted
+ ed.insertContent('Title: ' + e.data.title);
+ }
+ });
+ }
+ });
+
+
+ // Media Manager Button
+ ed.addButton('e107-image', {
+ text: '',
+ title: 'Insert Media-Manager Image',
+ icon: 'image',
+ onclick: function() {
+
+ ed.windowManager.open({
+ title: 'Media Manager',
+ url: url + '/mediamanager.php?image',
+ width: 1050,
+ height: 650
+
+ });
+ }
+ });
+
+ // Media Manager Button
+ ed.addButton('e107-video', {
+ text: '',
+ title: 'Insert Media-Manager Video',
+ icon: 'media',
+ resizable : 'no',
+ inline : 'yes',
+ close_previous : 'no',
+
+ onclick: function() {
+
+ ed.windowManager.open({
+ title: 'Media Manager',
+ url: url + '/mediamanager.php?video',
+ width: 1050,
+ height: 650
+
+ });
+ }
+ });
+
+ ed.addButton('e107-glyph', {
+ text: '',
+ title: 'Insert Media-Manager Glyph',
+ icon: 'charmap',
+ onclick: function() {
+
+ ed.windowManager.open({
+ title: 'Media Manager',
+ url: url + '/mediamanager.php?glyph',
+ width: 1050,
+ height: 650
+
+ });
+ }
+ });
+
+
+ },
+
+ getInfo: function() {
+ return {
+ longname: 'e107 Parser Plugin',
+ author: 'Moxiecode Systems AB',
+ authorurl: 'http://www.tinymce.com',
+ infourl: 'http://www.tinymce.com/wiki.php/Plugin:bbcode'
+ };
+ },
+
+ // Private methods
+
+ // HTML -> BBCode in PunBB dialect
+ _e107_html2bbcode : function(s, url) {
+ s = tinymce.trim(s);
+
+ // return s;
+
+ var p = $.ajax({
+ type: "POST",
+ url: url + "/parser.php",
+ data: { content: s, mode: 'tobbcode' },
+ async : false,
+
+ dataType: "html",
+ success: function(html) {
+ return html;
+ }
+ }).responseText;
+
+ return p;
+
+
+ },
+
+ // BBCode -> HTML from PunBB dialect
+ _e107_bbcode2html : function(s, url) {
+ s = tinymce.trim(s);
+
+ // return s;
+
+ var p = $.ajax({
+ type: "POST",
+ url: url + "/parser.php",
+ data: { content: s, mode: 'tohtml' },
+ async : false,
+
+ dataType: "html",
+ success: function(html) {
+ return html;
+ }
+ }).responseText;
+
+ return p;
+
+
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('e107', tinymce.plugins.e107Plugin);
+})();
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/plugins/example/plugin.js b/e107_plugins/tinymce4/plugins/example/plugin.js
new file mode 100644
index 000000000..e35569e4a
--- /dev/null
+++ b/e107_plugins/tinymce4/plugins/example/plugin.js
@@ -0,0 +1,55 @@
+/**
+ * plugin.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+/*jshint unused:false */
+/*global tinymce:true */
+
+/**
+ * Example plugin that adds a toolbar button and menu item.
+ */
+tinymce.PluginManager.add('example', function(editor, url) {
+ // Add a button that opens a window
+ editor.addButton('example', {
+ text: 'My button',
+ icon: false,
+ onclick: function() {
+ // Open window
+ editor.windowManager.open({
+ title: 'Example plugin',
+ body: [
+ {type: 'textbox', name: 'title', label: 'Title'}
+ ],
+ onsubmit: function(e) {
+ // Insert content when the window form is submitted
+ editor.insertContent('Title: ' + e.data.title);
+ }
+ });
+ }
+ });
+
+ // Adds a menu item to the tools menu
+ editor.addMenuItem('example', {
+ text: 'Example plugin',
+ context: 'tools',
+ onclick: function() {
+ // Open window with a specific url
+ editor.windowManager.open({
+ title: 'TinyMCE site',
+ url: 'http://www.tinymce.com',
+ width: 800,
+ height: 600,
+ buttons: [{
+ text: 'Close',
+ onclick: 'close'
+ }]
+ });
+ }
+ });
+});
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/plugins/example/plugin.min.js b/e107_plugins/tinymce4/plugins/example/plugin.min.js
new file mode 100644
index 000000000..1ff20b46b
--- /dev/null
+++ b/e107_plugins/tinymce4/plugins/example/plugin.min.js
@@ -0,0 +1 @@
+tinymce.PluginManager.add("example",function(t){t.addButton("example",{text:"My button",icon:!1,onclick:function(){t.windowManager.open({title:"Example plugin",body:[{type:"textbox",name:"title",label:"Title"}],onsubmit:function(e){t.insertContent("Title: "+e.data.title)}})}}),t.addMenuItem("example",{text:"Example plugin",context:"tools",onclick:function(){t.windowManager.open({title:"TinyMCE site",url:"http://www.tinymce.com",width:800,height:600,buttons:[{text:"Close",onclick:"close"}]})}})});
\ No newline at end of file
diff --git a/e107_plugins/tinymce4/templates/mainadmin.xml b/e107_plugins/tinymce4/templates/mainadmin.xml
new file mode 100644
index 000000000..afd1790de
--- /dev/null
+++ b/e107_plugins/tinymce4/templates/mainadmin.xml
@@ -0,0 +1,10 @@
+
+
+ advlist autolink lists link image charmap print preview hr anchor pagebreak searchreplace wordcount visualblocks visualchars code fullscreen
+ insertdatetime media nonbreaking save table contextmenu directionality emoticons template paste textcolor
+ edit view format insert table tools
+ undo redo | styleselect | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | e107-image e107-video e107-glyph | preview
+ e107 example
+ true
+ i[*], object[*],embed[*],bbcode[*]
+
diff --git a/e107_plugins/tinymce4/wysiwyg.php b/e107_plugins/tinymce4/wysiwyg.php
new file mode 100644
index 000000000..bab743ff7
--- /dev/null
+++ b/e107_plugins/tinymce4/wysiwyg.php
@@ -0,0 +1,413 @@
+renderConfig();
+
+
+if(ADMIN && e_QUERY == 'debug')
+{
+ require_once(HEADERF);
+
+ echo "";
+
+ print_a($output);
+
+ echo " |
+
+ ".print_a($gen,true)."
+ |
+
";
+
+ require_once(FOOTERF);
+
+}
+else
+{
+ ob_start();
+ ob_implicit_flush(0);
+ //header("last-modified: " . gmdate("D, d M Y H:i:s",mktime(0,0,0,15,2,2004)) . " GMT");
+ header('Content-type: text/javascript', TRUE);
+ echo $gen;
+}
+
+
+exit;
+
+
+
+
+
+echo_gzipped_page();
+
+class wysiwyg
+{
+ var $js;
+ var $config = array();
+ var $configName;
+
+ function renderConfig()
+ {
+ $this->getConfig($config);
+ $text .= "\n /* TinyMce Config: ".$this->configName." */\n\n";
+ $text .= "tinymce.init(";
+ $text .= json_encode($this->config, JSON_PRETTY_PRINT);
+ $text .= ");";
+
+ return stripslashes($text);
+ }
+
+
+
+ function __construct($config=FALSE)
+ {
+
+ }
+
+ function tinymce_lang()
+ {
+ $lang = e_LANGUAGE;
+ $tinylang = array(
+ "Arabic" => "ar",
+ "Bulgarian" => "bg",
+ "Danish" => "da",
+ "Dutch" => "nl",
+ "English" => "en",
+ "Persian" => "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 getExternalPlugins($data)
+ {
+ if(empty($data))
+ {
+ return;
+ }
+
+ $tmp = explode(" ",$data);
+
+ $ext = array();
+
+ foreach($tmp as $val)
+ {
+ $ext[$val] = e_PLUGIN_ABS."tinymce4/plugins/".$val."/plugin.js";
+ }
+
+
+ return $ext;
+ }
+
+
+
+ function convertBoolean($string)
+ {
+ $string = str_replace("\n","",$string);
+
+ if($string === 'true')
+ {
+ return true;
+ }
+
+ if($string === 'false')
+ {
+ return false;
+ }
+
+ return $string;
+ }
+
+
+
+ function getConfig($config=FALSE)
+ {
+ $tp = e107::getParser();
+ $fl = e107::getFile();
+
+ if(getperms('0'))
+ {
+ $template = "mainadmin.xml";
+ }
+ elseif(ADMIN)
+ {
+ $template = "admin.xml";
+ }
+ elseif(USER)
+ {
+ $template = "member.xml";
+ }
+ else
+ {
+ $template = "public.xml";
+ }
+
+ $configPath = (is_readable(THEME."templates/tinymce/".$template)) ? THEME."templates/tinymce/".$template : e_PLUGIN."tinymce4/templates/".$template;
+ $config = e107::getXml()->loadXMLfile($configPath, true);
+
+ //TODO Cache!
+
+ $this->configName = $config['@attributes']['name'];
+
+ unset($config['@attributes']);
+
+ $this->config = array(
+ 'selector' => '.e-wysiwyg',
+ 'theme' => 'modern',
+ 'plugins' => $this->filter_plugins($config['tinymce_plugins']),
+ 'language' => $this->tinymce_lang()
+
+ );
+
+
+ // Loop thru XML parms.
+ foreach($config as $k=>$xml)
+ {
+ if($k == 'external_plugins')
+ {
+ $this->config['external_plugins'] = $this->getExternalPlugins($xml);
+ continue;
+ }
+
+ $this->config[$k] = $this->convertBoolean($xml);
+ }
+
+ $this->config['convert_fonts_to_spans'] = false;
+ $this->config['content_css'] = 'http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css';
+
+ return;
+
+ // -------------------------------------------------------------------------------------
+
+
+
+ $cssFiles = $fl->get_files(THEME,"\.css",'',2);
+
+
+ foreach($cssFiles as $val)
+ {
+ $css[] = str_replace(THEME,THEME_ABS,$val['path'].$val['fname']);
+ }
+ $css[] = "{e_WEB_ABS}js/bootstrap/css/bootstrap.min.css";
+ $content_css = vartrue($config['content_css'], implode(",",$css));
+
+ $content_styles = array('Bootstrap Button' => 'btn btn-primary', 'Bootstrap Table' => 'table');
+
+
+
+ $this->config += array(
+
+ // 'theme_advanced_buttons1' => $config['tinymce_buttons1'],
+ // 'theme_advanced_buttons2' => vartrue($config['tinymce_buttons2']),
+ // 'theme_advanced_buttons3' => vartrue($config['tinymce_buttons3']),
+ // 'theme_advanced_buttons4' => vartrue($config['tinymce_buttons4']),
+ // 'theme_advanced_toolbar_location' => vartrue($config['theme_advanced_toolbar_location'],'top'),
+ // 'theme_advanced_toolbar_align' => 'left',
+ // 'theme_advanced_blockformats' => 'p,h2,h3,h4,h5,h6,blockquote,pre,code',
+ // 'theme_advanced_styles' => str_replace(array("+")," ",http_build_query($content_styles)), //'Bootstrap Button=btn btn-primary;Bootstrap Table=table;border=border;fborder=fborder;tbox=tbox;caption=caption;fcaption=fcaption;forumheader=forumheader;forumheader3=forumheader3',
+
+ // 'theme_advanced_resize_vertical' => 'true',
+ 'dialog_type' => "modal",
+ // 'theme_advanced_source_editor_height' => '400',
+
+ // ------------- html5 Stuff.
+
+ // 'visualblocks_default_state' => 'true',
+
+ // Schema is HTML5 instead of default HTML4
+ // 'schema' => "html5",
+
+ // End container block element when pressing enter inside an empty block
+ // 'end_container_on_empty_block' => true,
+
+ // HTML5 formats
+ /*
+ 'style_formats' => "[
+ {title : 'h1', block : 'h1'},
+ {title : 'h2', block : 'h2'},
+ {title : 'h3', block : 'h3'},
+ {title : 'h4', block : 'h4'},
+ {title : 'h5', block : 'h5'},
+ {title : 'h6', block : 'h6'},
+ {title : 'p', block : 'p'},
+ {title : 'div', block : 'div'},
+ {title : 'pre', block : 'pre'},
+ {title : 'section', block : 'section', wrapper: true, merge_siblings: false},
+ {title : 'article', block : 'article', wrapper: true, merge_siblings: false},
+ {title : 'blockquote', block : 'blockquote', wrapper: true},
+ {title : 'hgroup', block : 'hgroup', wrapper: true},
+ {title : 'aside', block : 'aside', wrapper: true},
+ {title : 'figure', block : 'figure', wrapper: true}
+ ]",
+ */
+ // --------------------------------
+
+
+ // 'theme_advanced_statusbar_location' => 'bottom',
+ 'theme_advanced_resizing' => 'true',
+ 'remove_linebreaks' => 'false',
+ 'extended_valid_elements' => vartrue($config['extended_valid_elements']),
+ // 'pagebreak_separator' => "[newpage]",
+ 'apply_source_formatting' => 'true',
+ 'invalid_elements' => 'font,align,script,applet',
+ 'auto_cleanup_word' => 'true',
+ 'cleanup' => 'true',
+ 'convert_fonts_to_spans' => 'true',
+ // 'content_css' => $tp->replaceConstants($content_css),
+ 'popup_css' => 'false',
+
+ 'trim_span_elements' => 'true',
+ 'inline_styles' => 'true',
+ 'auto_resize' => 'false',
+ 'debug' => 'true',
+ 'force_br_newlines' => 'true',
+ 'media_strict' => 'false',
+ 'width' => vartrue($config['width'],'100%'),
+ // 'height' => '90%', // higher causes padding at the top?
+ 'forced_root_block' => 'false', //remain as false or it will mess up some theme layouts.
+
+ 'convert_newlines_to_brs' => 'true', // will break [list] if set to true
+ // 'force_p_newlines' => 'false',
+ 'entity_encoding' => 'raw',
+ 'convert_fonts_to_styles' => 'true',
+ 'remove_script_host' => 'true',
+ 'relative_urls' => 'false', //Media Manager prefers it like this.
+ 'preformatted' => 'true',
+ 'document_base_url' => SITEURL,
+ 'verify_css_classes' => 'false'
+
+ );
+
+ // if(!in_array('e107bbcode',$plug_array))
+ {
+ // $this->config['cleanup_callback'] = 'tinymce_e107Paths';
+ }
+
+ $paste_plugin = false; // (strpos($config['tinymce_plugins'],'paste')!==FALSE) ? TRUE : FALSE;
+
+ if($paste_plugin)
+ {
+ $this->config += array(
+
+ 'paste_text_sticky' => 'true',
+ 'paste_text_sticky_default' => 'true',
+ 'paste_text_linebreaktype' => 'br',
+
+ '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' => 'true', // 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' => 'true' // auto clean pastes from Word
+ );
+ }
+
+ if(ADMIN)
+ {
+ // $this->config['external_link_list_url'] = e_PLUGIN_ABS."tiny_mce/filelist.php";
+ }
+ }
+
+
+ function filter_plugins($plugs)
+ {
+
+ $smile_pref = e107::getConfig()->getPref('smiley_activate');
+
+ $admin_only = array("ibrowser");
+
+ $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 $tinymce_plugins;
+ }
+
+
+
+}
+
+?>
\ No newline at end of file