1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-05 02:15:13 +02:00

Initial commit of the highly experimental TinyMce4 CDN plugin.

This commit is contained in:
Cameron 2014-05-20 16:53:06 -07:00
parent 6829586be2
commit 771d7e5168
15 changed files with 1957 additions and 0 deletions

View File

@ -0,0 +1,176 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $URL$
* $Id$
*/
if (!defined('e107_INIT')) { exit; }
e107::css('inline','
a.e-wysiwyg-toggle { margin-top:5px }
');
$pref = e107::getPref();
if((e_WYSIWYG && check_class($pref['post_html'])) || strpos(e_SELF,"tinymce4/admin_config.php") )
{
if(e_PAGE != 'image.php')
{
//e107::js('tinymce','tiny_mce.js','jquery');
//e107::js('tinymce','wysiwyg.php','jquery',5);
e107::js('url', "//tinymce.cachefly.net/4.0/tinymce.min.js");
e107::js('tinymce4','wysiwyg.php','jquery',5);
// e107::js('inline', "
// tinymce.init({selector:'.e-wysiwyg'});
// ");
}
else
{
// e107::js('tinymce','tiny_mce_popup.js','jquery');
}
if(ADMIN)
{
$insert = "$('#'+id).after('<div>";
// $insert .= "<a href=\"#\" id=\"' + id + '\" class=\"e-wysiwyg-toggle btn btn-inverse btn-mini\">Switch to bbcode<\/a>";
if(e_PAGE == 'mailout.php')
{
$insert .= "&nbsp;&nbsp;<a href=\"#\" class=\"btn btn-mini tinyInsert\" data-value=\"|USERNAME|\" >".LAN_MAILOUT_16."<\/a>";
$insert .= "<a href=\"#\" class=\"btn btn-mini tinyInsert\" data-value=\"|DISPLAYNAME|\" >".LAN_MAILOUT_14."<\/a>";
$insert .= "<a href=\"#\" class=\"btn btn-mini tinyInsert\" data-value=\"|SIGNUP_LINK|\" >".LAN_MAILOUT_17."<\/a>";
$insert .= "<a href=\"#\" class=\"btn btn-mini tinyInsert\" data-value=\"|USERID|\" >".LAN_MAILOUT_18."<\/a>";
}
$insert .= "</div>');";
define("SWITCH_TO_BB",$insert);
}
else
{
define("SWITCH_TO_BB","");
}
// print_a($_POST);
// <div><a href='#' class='e-wysiwyg-switch' onclick=\"tinyMCE.execCommand('mceToggleEditor',false,'".$tinyMceID."');expandit('".$toggleID."');\">Toggle WYSIWYG</a></div>
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 = '<img src=\''+src +'\' alt=\'emote\' />';
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");
}
?>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<e107Plugin name="TinyMce4" version="1.0" date="2014-01-15" compatibility="2.0" installRequired="true">
<author name="e107 Inc." url="http://e107.org" />
<description>Experimental TinyMce4 CDN version</description>
<category>misc</category>
</e107Plugin>

View File

@ -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: <strong> to [b]
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
rep(/<font>(.*?)<\/font>/gi,"$1");
rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]");
rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]");
rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]");
rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]");
rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]");
rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]");
rep(/<u class=\"quoteStyle\">(.*?)<\/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 style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
rep(/<u>/gi,"[u]");
rep(/<blockquote[^>]*>/gi,"[quote]");
rep(/<\/blockquote>/gi,"[/quote]");
rep(/<br \/>/gi,"\n");
rep(/<br\/>/gi,"\n");
rep(/<br>/gi,"\n");
rep(/<p>/gi,"");
rep(/<\/p>/gi,"\n");
rep(/&nbsp;|\u00a0/gi," ");
rep(/&quot;/gi,"\"");
rep(/&lt;/gi,"<");
rep(/&gt;/gi,">");
rep(/&amp;/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 <strong>
rep(/\n/gi,"<br />");
rep(/\[b\]/gi,"<strong>");
rep(/\[\/b\]/gi,"</strong>");
rep(/\[i\]/gi,"<em>");
rep(/\[\/i\]/gi,"</em>");
rep(/\[u\]/gi,"<u>");
rep(/\[\/u\]/gi,"</u>");
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");
rep(/\[code\](.*?)\[\/code\]/gi,"<span class=\"codeStyle\">$1</span>&nbsp;");
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<span class=\"quoteStyle\">$1</span>&nbsp;");
return s;
}
});
// Register plugin
tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);
})();

View File

@ -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.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"),t(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),t(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),t(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),t(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),t(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]"),t(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"),t(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]"),t(/<font>(.*?)<\/font>/gi,"$1"),t(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]"),t(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]"),t(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]"),t(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"),t(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]"),t(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]"),t(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]"),t(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]"),t(/<u class=\"quoteStyle\">(.*?)<\/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 style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]"),t(/<u>/gi,"[u]"),t(/<blockquote[^>]*>/gi,"[quote]"),t(/<\/blockquote>/gi,"[/quote]"),t(/<br \/>/gi,"\n"),t(/<br\/>/gi,"\n"),t(/<br>/gi,"\n"),t(/<p>/gi,""),t(/<\/p>/gi,"\n"),t(/&nbsp;|\u00a0/gi," "),t(/&quot;/gi,'"'),t(/&lt;/gi,"<"),t(/&gt;/gi,">"),t(/&amp;/gi,"&"),e},_punbb_bbcode2html:function(e){function t(t,n){e=e.replace(t,n)}return e=tinymce.trim(e),t(/\n/gi,"<br />"),t(/\[b\]/gi,"<strong>"),t(/\[\/b\]/gi,"</strong>"),t(/\[i\]/gi,"<em>"),t(/\[\/i\]/gi,"</em>"),t(/\[u\]/gi,"<u>"),t(/\[\/u\]/gi,"</u>"),t(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'<a href="$1">$2</a>'),t(/\[url\](.*?)\[\/url\]/gi,'<a href="$1">$1</a>'),t(/\[img\](.*?)\[\/img\]/gi,'<img src="$1" />'),t(/\[color=(.*?)\](.*?)\[\/color\]/gi,'<font color="$1">$2</font>'),t(/\[code\](.*?)\[\/code\]/gi,'<span class="codeStyle">$1</span>&nbsp;'),t(/\[quote.*?\](.*?)\[\/quote\]/gi,'<span class="quoteStyle">$1</span>&nbsp;'),e}}),tinymce.PluginManager.add("bbcode",tinymce.plugins.BBCodePlugin)}();

View File

@ -0,0 +1,22 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#example_dlg.title}</title>
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="js/dialog.js"></script>
</head>
<body>
<form onsubmit="ExampleDialog.insert();return false;" action="#">
<p>Here is a example dialog.</p>
<p>Selected text: <input id="someval" name="someval" type="text" class="text" /></p>
<p>Custom arg: <input id="somearg" name="somearg" type="text" class="text" /></p>
<div class="mceActionPanel">
<input type="button" id="insert" name="insert" value="{#insert}" onclick="ExampleDialog.insert();" />
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
</div>
</form>
</body>
</html>

View File

@ -0,0 +1,489 @@
<?php
define("e_ADMIN_AREA", true);
require_once("../../../../class2.php");
//e107::lan('core','admin',TRUE);
define("e_IFRAME",true);
//require_once(e_ADMIN."auth.php");
if(!USER || check_class($pref['post_html']) == FALSE){
exit;
}
e107::css('inline',"
.selectEmote { display:inline-block; cursor:pointer;margin:3px }
body { text-align:center }
.area {
margin-top:-1px; padding:20px;
}
span.badge { cursor: pointer }
span.label { cursor: pointer }
ul.glyphicons { list-style:none; margin-left:0px; font-size:120%}
ul.glyphicons li { float:left; cursor:pointer; width:190px; padding:5px; }
a, li { outline: 0; }
");
e107::js('tinymce','tiny_mce_popup.js');
e107::js('inline',"
$(document).ready(function()
{
$('#insertButton').click(function () {
var buttonType = $('input:radio[name=buttonType]:checked').val();
var buttonSize = $('input:radio[name=buttonSize]:checked').val();
var buttonText = $('#buttonText').val();
var buttonUrl = $('#buttonUrl').val();
var buttonClass = (buttonType != '') ? 'btn-'+buttonType : '';
var html = '<a class=\"btn ' + buttonClass + ' ' + buttonSize + '\" href=\"' + buttonUrl + '\" >' + buttonText + '</a> ';
// alert(html);
tinyMCEPopup.editor.execCommand('mceInsertContent', false, html);
tinyMCEPopup.close();
});
$('span.label, span.badge').click(function () {
var cls = $(this).attr('class');
var html = '<span class=\"' + cls + '\">' + $(this).text() + '</span>&nbsp;';
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 = '<i class=\"' + cls + '\"></i>&nbsp;';
// 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 = '<bbcode alt=\"'+encodeURIComponent(s)+'\">' + html + '</bbcode> ' ;
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 = "<div class='alert alert-warning'>Warning: These will only work if you have a bootstrap-based theme installed</div>";
$text .= '
<ul class="nav nav-tabs">';
$text .= '<li class="active" ><a href="#mbuttons" data-toggle="tab">Buttons</a></li>';
$text .= '<li><a href="#badges" data-toggle="tab">Labels &amp; Badges</a></li>';
$text .= '<li><a href="#glyphs" data-toggle="tab">Glyphicons</a></li>';
$text .= '</ul>';
$text .= '<div class="tab-content">';
$text .= '<div class="tab-pane active left" id="mbuttons">'.$this->buttonForm().'</div>';
$text .= '<div class="tab-pane left" id="badges">'.$this->badgeForm().'</div>';
$text .= '<div class="tab-pane left" id="glyphs">'.$this->glyphicons().'</div>';
$text .= '</div>';
echo $text;
}
function buttonForm()
{
$frm = e107::getForm();
$buttonSizes = array(''=>'Default', 'btn-mini'=>"Mini", 'btn-small'=>"Small", 'btn-large' => "Large");
$buttonTypes = $this->styleClasses;
$butSelect = "";
$butSelect .= "<div class='form-inline' style='padding:5px'>";
foreach($buttonTypes as $type=>$diz)
{
$label = '<button class="btn btn-'.$type.'" >'.$diz.'</button>';
$butSelect .= $frm->radio('buttonType', $type, false, array('label'=>$label));
}
$butSelect .= "</div>";
$butSize = "<div class='form-inline' style='padding:5px'>";
foreach($buttonSizes as $size=>$label)
{
$selected = ($size == '') ? true : false;
$butSize .= $frm->radio('buttonSize', $size, $selected, array('label'=>$label));
}
$butSize .= "</div>";
$text = "
<table class='table area'>
<tr>
<td>Button Style</td>
<td>".$butSelect."</td>
</tr>
<tr>
<td>Button Size</td>
<td><p>".$butSize."</p></td>
</tr>
<tr>
<td>Button Text</td>
<td><p>".$frm->text('buttonText',$value,50)."</p></td>
</tr>
<tr>
<td>Button Url</td>
<td><p>".$frm->text('buttonUrl','',255,'size=xxlarge')."</p></td>
</tr>
</table>
<div class='center'>". $frm->admin_button('insertButton','save','other',"Insert") ."
<button class='btn ' id='e-cancel'>".LAN_CANCEL."</button>
</div>";
return $text;
}
function badgeForm()
{
unset($this->styleClasses['primary']);
foreach($this->styleClasses as $key=>$type)
{
$classLabel = ($key != '') ? " label-".$key : "";
$classBadge = ($key != '') ? " badge-".$key : "";
$text .= '<div class="area"><span class="label'.$classLabel.'">'.$type.'</span>&nbsp;';
$text .= '<span class="badge'.$classBadge.'">'.$type.'</span>';
$text .= "</div>";
}
return $text;
}
function bbcodeForm()
{
$list = e107::getPref('bbcode_list');
$text .= "
<h4>e107 Bbcodes</h4>
<div class='well'>
<table class='table table-striped'>
<tr><th>Plugin</th>
<th>Bbcode</th>
</tr>
";
foreach($list as $plugin=>$val)
{
$text .= "<tr><td>".$plugin."</td>
<td>";
foreach($val as $bb=>$v)
{
$text .= "<a href='#' class='bbcodeSelect' style='cursor:pointer'>[".$bb."][/".$bb."]</a>";
}
$text .= "</td>
</tr>";
}
$text .= "</table>
</div>";
$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 .= "<div class='area'>";
$text .= "<div class='inline-form'>Color: ".$frm->select('glyph-color',$sel)." Custom: ".$frm->text('glyph-custom','').$frm->button('glyph-save','Go')."</div>";
$text .= "<ul class='glyphicons well clearfix'>";
$inverse = (e107::getPref('admincss') == "admin_dark.css") ? " icon-white" : "";
foreach($icons as $ic)
{
$text .= '<li><i class="'.$ic.$inverse.'"></i> '.$ic.'</li>';
$text .= "\n";
}
$text .= "</ul>";
$text .= "</div>";
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;
//
?>

View File

@ -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(/<table(.*)>/gim, "[table]");
rep(/<\/table>/gim, "[/table]");
rep(/<td>/gim, "[td]");
rep(/<\/td>/gim, "[/td]");
rep(/<tr>/gim, "[tr]");
rep(/<\/tr>/gim, "[/tr]");
rep(/<tbody>/gim, "[tbody]");
rep(/<\/tbody>/gim, "[/tbody]");
rep(/<div style="text-align: center;">([\s\S]*)<\/div>/gi,"[center]$1[/center]"); // verified
rep(/<li>/gi, "[*]"); // verified
rep(/<\/li>/gi, ""); // verified
rep(/<ul>([\s\S]*?)<\/ul>\n/gim, "[list]$1[/list]"); // verified
rep(/<ol .* style=\'list-style-type:\s*([\w]*).*\'>([\s\S]*)<\/ol>/gim,"[list=$1]$2[/list]\n"); // verified
rep(/<ol>([\s\S]*?)<\/ol>/gim,"[list=decimal]$1[/list]\n"); // verified
rep(/<span style="color: (#?.*?);">([\s\S]*)<\/span>/gi,"[color=$1]$2[/color]"); // verified
rep(/<h2>/gim, "[h]"); // verified
rep(/<\/h2>/gim, "[/h]"); // verified
// example: <strong> to [b]
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[link=$1]$2[/link]");
rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
rep(/<font>(.*?)<\/font>/gi,"$1");
// rep(/<img.*?style=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img style=$1]$2[/img]");
// New Image Handler // verified
// rep(/<img(?:\s*)?(?:style="(.*)")?\s?(?:src="([^;"]*)")(?:\s*)?(?:width="([\d]*)")?\s*(?:height="([\d]*)")?(?:\s*)?(?:alt="(\S*)")? (?:\s*)?\/>/gi,"[img style=$1;width:$4px;height:$5px]$2[/img]" );
//rep(/<img(?:\s*)?(?:style="(.*)")?\s?(?:src="([\S ]*)")(?:\s*)?(?:alt="(\S*)")?(?:\s*)?(?:width="([\d]*)")?\s*(?:height="([\d]*)")?(?:\s*)?\/>/gi,"[img style=$1;width:$4px;height:$5px]$2[/img]" )
rep(/<img(?:\s*)?(?:style="([^"]*)")?\s?(?:src="([^"]*)")(?:\s*)?(?:alt="(\S*)")?(?:\s*)?(?:width="([\d]*)")?\s*(?:height="([\d]*)")?(?:\s*)?\/>/gm,"[img style=width:$4px;height:$5px;$1]$2[/img]" );
rep(/;width:px;height:px/gi, ""); // Img cleanup.
// rep(/<img\s*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
rep(/<blockquote[^>]*>/gi,"[blockquote]");
rep(/<\/blockquote>/gi,"[/blockquote]");
rep(/<code[^>]*>/gi,"[code]");
rep(/<\/code>/gi,"[/code]");
// rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]");
// rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]");
// rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
// rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]");
// rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]");
// rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]");
// rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]");
// rep(/<u class=\"quoteStyle\">(.*?)<\/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 style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
rep(/<u>/gi,"[u]");
// Compromise - but BC issues for sure.
// rep(/<br \/>/gi,"[br]");
// rep(/<br\/>/gi,"[br]");
// rep(/<br>/gi,"[br]");
rep(/<br \/>/gi,"\n");
rep(/<br\/>/gi,"\n");
rep(/<br>/gi,"\n");
rep(/<p>/gi,"");
rep(/<\/p>/gi,"\n");
rep(/&nbsp;/gi," ");
rep(/&quot;/gi,"\"");
rep(/&lt;/gi,"<");
rep(/&gt;/gi,">");
rep(/&amp;/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 <strong>
// rep(/<ul>(\r|\n)?/gim, "<ul>"); // remove line-breaks
// rep(/<\/li>(\r|\n)?/gim, "</li>"); // remove line-breaks
// rep(/<\/ul>(\r|\n)?/gim, "</ul>"); // remove line-breaks
rep(/\[table]/gim, "<table>");
rep(/\[\/table]/gim, "</table>");
rep(/\[td]/gim, "<td>");
rep(/\[\/td]/gim, "</td>");
rep(/\[tr]/gim, "<tr>");
rep(/\[\/tr]/gim, "</tr>");
rep(/\[tbody]/gim, "<tbody>");
rep(/\[\/tbody]/gim, "</tbody>");
rep(/\[h]/gim, "<h2>"); // verified
rep(/\[\/h]/gim, "</h2>"); // verified
rep(/\[list](?:\n)/gim, "<ul>\n"); // verified
// rep(/\[list]/gim, "<ul>"); // verified
rep(/\[\/list](?:\n)?/gim, "</ul>\n"); // verified
rep(/^ *?(?:\*|\[\*\])([^\*[]*)/gm,"<li>$1</li>\n");
// return s;
// rep(/(\[list=.*\])\\*([\s\S]*)(\[\/list])(\n|\r)/gim,"<ol>$2</ol>"); // verified
// rep(/(\[list\])\\*([\s\S]*)(\[\/list])(\n|\r)?/gim,"<ul>$2</ul>");// verified
rep(/\[center\]([\s\S]*)\[\/center\]/gi,"<div style=\"text-align:center\">$1</div>"); // verified
rep(/\[color=(.*?)\]([\s\S]*)\[\/color\]/gi,"<span style=\"color: $1;\">$2<\/span>"); // verified
// rep(/\[br]/gi,"<br />"); // compromise
rep(/\[blockquote\]/gi,"<blockquote>");
rep(/\[\/blockquote\]/gi,"</blockquote>");
rep(/\[code\]/gi,"<code>");
rep(/\[\/code\]/gi,"</code>");
//rep( /(?<!(\[list]))\r|\n/gim,"<br />" )
rep(/\[b\]/gi,"<strong>");
rep(/\[\/b\]/gi,"</strong>");
rep(/\[i\]/gi,"<em>");
rep(/\[\/i\]/gi,"</em>");
rep(/\[u\]/gi,"<u>");
rep(/\[\/u\]/gi,"</u>");
rep(/\[link=([^\]]+)\](.*?)\[\/link\]/gi,"<a href=\"$1\">$2</a>");
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
// rep(/\[img.*?style=(.*?).*?\](.*?)\[\/img\]/gi,"<img style=\"$1\" src=\"$2\" />");
// When Width and Height are present:
rep(/\[img\s*?style=(?:width:(\d*)px;height:(\d*)px;)([^\]]*)]([\s\S]*?)\[\/img]/gm, "<img style=\"$3\" src=\"$4\" alt=\"\" width=\"$1\" height=\"$2\" />");
// No width/height but style is present
rep(/\[img\s*?style=([^\]]*)]([\s\S]*?)\[\/img]/gi,"<img style=\"$1\" src=\"$2\" />");
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
// rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");
// rep(/\[code\](.*?)\[\/code\]/gi,"<span class=\"codeStyle\">$1</span>&nbsp;");
// rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<span class=\"quoteStyle\">$1</span>&nbsp;");
// rep(/<br \/>/gm, "<br />\n");
rep(/(\r|\n)$/gim,"<br />");
// rep(/(\r|\n)/gim,"<br />\n"); // this will break bullets.
// e107 FIXME!
// rep("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>');
//
return s;
}
});
// Register plugin
tinymce.PluginManager.add('e107bbcode', tinymce.plugins.e107BBCodePlugin);
})();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,13 @@
<?php
require_once("../../../../class2.php");
$types = array('img','video','glyph');
$bbcode = in_array(e_QUERY,$types) ? e_QUERY : 'img';
header("Location: ".e_ADMIN_ABS.'image.php?mode=main&action=dialog&for='.$_SESSION['media_category'].'&tagid=&iframe=1&bbcode='.$bbcode, true);
exit;
?>

View File

@ -0,0 +1,145 @@
<?php
/*
* e107 website system
*
* Copyright (C) e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_handlers/bbcode_handler.php $
* $Id: bbcode_handler.php 12778 2012-06-02 08:12:16Z e107coders $
*/
require_once("../../../../class2.php");
/**
* Two Modes supported below going to and from the Tinymce wysiwyg editor.
* 1) When the post_html pref is active - raw html is used in the editor and wrapped in [html] [/html] bbcodes in the background.
* 2) When the post_html pref is disabled - bbcodes are used in the background and converted to html for the editor.
* Tested extensively over 24 hours with Images - check with Cameron first if issues arise.
* TODO Test Lines breaks and out html tags.
* TODO Check with html5 tags active.
*/
if($_POST['mode'] == 'tohtml')
{
// XXX @Cam possible fix - convert to BB first, see news admin AJAX request/response values for reference why
$content = stripslashes($_POST['content']);
// $content = e107::getBB()->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',"<br />",$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("<!-- bbcode-html-start -->","<!-- bbcode-html-end -->","[html]","[/html]");
$content = str_replace($srch,"",$content);
$content = e107::getBB()->parseBBCodes($content); // parse the <bbcode> 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 = '/<img[^>]*src="{e_BASE}thumb.php\?src=([\S]*)w=([\d]*)&amp;h=([\d]*)"(.*)width="([\d]*)" height="([\d]*)"/i';
// $prepl = '<img src="{e_BASE}thumb.php?src=$1w=$5&amp;h=$6"$4width="$5" height="$6" ';
// $content = preg_replace($psrch, $prepl, $content);
$content = updateImg($content);
$content = $tp->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 <img> tags with modified thumbnail size.
*/
function updateImg($text)
{
$arr = e107::getParser()->getTags($text,'img');
$srch = array("?","&");
$repl = array("\?","&amp;");
foreach($arr['img'] as $img)
{
$regexp = '#(<img[^>]*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 = '<img'.$class.$style.' src="'.$src.'"'.$width.$height.$alt.' />';
$text = preg_replace($regexp, $replacement, $text);
}
return $text;
}
?>

View File

@ -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);
})();

View File

@ -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'
}]
});
}
});
});

View File

@ -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"}]})}})});

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<tinymce name="Main Admin" version="4">
<plugins>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</plugins>
<menubar>edit view format insert table tools</menubar>
<toolbar1>undo redo | styleselect | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | e107-image e107-video e107-glyph | preview</toolbar1>
<external_plugins>e107 example</external_plugins>
<image_advtab>true</image_advtab>
<extended_valid_elements>i[*], object[*],embed[*],bbcode[*]</extended_valid_elements>
</tinymce>

View File

@ -0,0 +1,413 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system - Tiny MCE controller file.
|
| $URL$
| $Id$
+----------------------------------------------------------------------------+
*/
$_E107['no_online'] = true;
require_once("../../class2.php");
$text = <<<TMPL
tinymce.init({
selector: ".e-wysiwyg",
theme: "modern",
plugins: [
"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 "
],
external_plugins: {
"example": "{e_PLUGIN_ABS}tinymce4/plugins/example/plugin.min.js",
"e107" : "{e_PLUGIN_ABS}tinymce4/plugins/e107/plugin.js"
},
menubar: "edit view format insert table tools",
toolbar1: "undo redo | styleselect | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | e107-image e107-video e107-glyph | preview",
image_advtab: true,
extended_valid_elements: 'span[*],i[*],iframe[*]',
trim_span_elements: false,
content_css: 'http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css',
templates: [
{title: 'Test template 1', content: 'Test 1'},
{title: 'Test template 2', content: 'Test 2'}
]
});
TMPL;
$output = str_replace("{e_PLUGIN_ABS}", e_PLUGIN_ABS, $text);
$wy = new wysiwyg();
$gen = $wy->renderConfig();
if(ADMIN && e_QUERY == 'debug')
{
require_once(HEADERF);
echo "<table class='table'><tr><td>";
print_a($output);
echo "</td>
<td>
".print_a($gen,true)."
</td>
</tr></table>";
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;
}
}
?>