1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-29 19:00:26 +02:00

TinyMce now includes e107 emoticons.

This commit is contained in:
Cameron
2015-04-10 18:58:13 -07:00
parent cc76f8e75e
commit 3aa5633533
29 changed files with 365 additions and 11 deletions

View File

@@ -74,12 +74,15 @@ class eurl_admin_ui extends e_admin_controller_ui
}
else
{
$modRewrite = false;
$modRewrite = true; //we don't really know.
}
if($modRewrite === false)
{
e107::getMessage()->addInfo("Apache mod_rewrite was not found on this server and is required to use this feature. ");
e107::getMessage()->addDebug(print_a($modules,true));
}
if($htaccess && $modRewrite && !deftrue('e_MOD_REWRITE'))
@@ -621,12 +624,14 @@ class eurl_admin_form_ui extends e_admin_form_ui
$cssClass = 'e-hideme'; // always hidden for now, some interface changes could come after pre-alpha
$exampleUrl = array();
foreach($section['examples'] as $ex)
{
$exampleUrl[] = str_replace($srch,$repl,$ex);
}
if(!empty($section['examples']))
{
foreach($section['examples'] as $ex)
{
$exampleUrl[] = str_replace($srch,$repl,$ex);
}
}
if(strpos($path,'noid')!==false)
{
// $exampleUrl .= "   ‡"; //XXX Add footer - denotes more CPU required. ?

View File

@@ -41,7 +41,7 @@
// Emoticons
ed.addButton('e107-emotes', {
text: 'Media Manager',
text: '',
icon: 'emoticons',
onclick: function() {
// Open window

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 732 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

View File

@@ -0,0 +1,300 @@
tinymce.PluginManager.add('smileys', function (editor, url) {
var defaultSmileys = [
[
{ shortcut: '(^^^)', url: url + '/img/shark.gif', title: 'shark' },
{ shortcut: 'O:)', url: url + '/img/angel.png', title: 'angel' },
{ shortcut: 'o.O', url: url + '/img/confused.png', title: 'confused' },
{ shortcut: '3:)', url: url + '/img/devil.png', title: 'devil' },
{ shortcut: ':-O', url: url + '/img/gasp.png', title: 'gasp' },
{ shortcut: '8-)', url: url + '/img/glasses.png', title: 'glasses' },
{ shortcut: ':-D', url: url + '/img/grin.png', title: 'grin' }
],
[
{ shortcut: ':-)', url: url + '/img/smile.png', title: 'smile' },
{ shortcut: ":'(", url: url + '/img/cry.png', title: 'cry' },
{ shortcut: '<3', url: url + '/img/heart.png', title: 'heart' },
{ shortcut: '^_^', url: url + '/img/kiki.png', title: 'kiki' },
{ shortcut: ':-*', url: url + '/img/kiss.png', title: 'kiss' },
{ shortcut: ':v', url: url + '/img/pacman.png', title: 'pacman' },
{ shortcut: '<(<28>)', url: url + '/img/penguin.gif', title: 'penguin' }
],
[
{ shortcut: ':|]', url: url + '/img/robot.gif', title: 'robot' },
{ shortcut: '-_-', url: url + '/img/squint.png', title: 'squint' },
{ shortcut: '8-|', url: url + '/img/sunglasses.png', title: 'sunglasses' },
{ shortcut: ':-P', url: url + '/img/tongue.png', title: 'tongue' },
{ shortcut: ':/', url: url + '/img/unsure.png', title: 'unsure' },
{ shortcut: '>:O', url: url + '/img/upset.png', title: 'upset' },
{ shortcut: '>:(', url: url + '/img/grumpy.png', title: 'grumpy' }
]
];
var smileys = editor.settings.smileys || defaultSmileys, fullSmileysList = editor.settings.extended_smileys ? smileys.concat(editor.settings.extended_smileys) : smileys;
function getHtml() {
var smileysHtml;
smileysHtml = '<table role="presentation" class="mce-grid">';
tinymce.each(fullSmileysList, function (row) {
smileysHtml += '<tr>';
tinymce.each(row, function (icon) {
smileysHtml += '<td><a href="#" data-mce-url="' + icon.url + '" tabindex="-1" title="' + icon.title + '"><img src="' +
icon.url + '" style="width: 16px; height: 16px"></a></td>';
});
smileysHtml += '</tr>';
});
smileysHtml += '</table>';
return smileysHtml;
}
function concatArray(array) {
var each = tinymce.each, result = [];
each(array, function (item) {
result = result.concat(item);
});
return result.length > 0 ? result : array;
}
function findAndReplaceDOMText(regex, node, replacementNode, captureGroup, schema) {
var m, matches = [], text, count = 0, doc;
var blockElementsMap, hiddenTextElementsMap, shortEndedElementsMap;
doc = node.ownerDocument;
blockElementsMap = schema.getBlockElements(); // H1-H6, P, TD etc
hiddenTextElementsMap = schema.getWhiteSpaceElements(); // TEXTAREA, PRE, STYLE, SCRIPT
shortEndedElementsMap = schema.getShortEndedElements(); // BR, IMG, INPUT
function getMatchIndexes(m, captureGroup) {
captureGroup = captureGroup || 0;
var index = m.index;
if (captureGroup > 0) {
var cg = m[captureGroup];
index += m[0].indexOf(cg);
m[0] = cg;
}
return [index, index + m[0].length, [m[0]]];
}
function getText(node) {
var txt;
if (node.nodeType === 3) {
return node.data;
}
if (hiddenTextElementsMap[node.nodeName] && !blockElementsMap[node.nodeName]) {
return '';
}
txt = '';
if (blockElementsMap[node.nodeName] || shortEndedElementsMap[node.nodeName]) {
txt += '\n';
}
if ((node = node.firstChild)) {
do {
txt += getText(node);
} while ((node = node.nextSibling));
}
return txt;
}
function stepThroughMatches(node, matches, replaceFn) {
var startNode, endNode, startNodeIndex,
endNodeIndex, innerNodes = [], atIndex = 0, curNode = node,
matchLocation = matches.shift(), matchIndex = 0;
out: while (true) {
if (blockElementsMap[curNode.nodeName] || shortEndedElementsMap[curNode.nodeName]) {
atIndex++;
}
if (curNode.nodeType === 3) {
if (!endNode && curNode.length + atIndex >= matchLocation[1]) {
// We've found the ending
endNode = curNode;
endNodeIndex = matchLocation[1] - atIndex;
} else if (startNode) {
// Intersecting node
innerNodes.push(curNode);
}
if (!startNode && curNode.length + atIndex > matchLocation[0]) {
// We've found the match start
startNode = curNode;
startNodeIndex = matchLocation[0] - atIndex;
}
atIndex += curNode.length;
}
if (startNode && endNode) {
curNode = replaceFn({
startNode: startNode,
startNodeIndex: startNodeIndex,
endNode: endNode,
endNodeIndex: endNodeIndex,
innerNodes: innerNodes,
match: matchLocation[2],
matchIndex: matchIndex
});
// replaceFn has to return the node that replaced the endNode
// and then we step back so we can continue from the end of the
// match:
atIndex -= (endNode.length - endNodeIndex);
startNode = null;
endNode = null;
innerNodes = [];
matchLocation = matches.shift();
matchIndex++;
if (!matchLocation) {
break; // no more matches
}
} else if ((!hiddenTextElementsMap[curNode.nodeName] || blockElementsMap[curNode.nodeName]) && curNode.firstChild) {
// Move down
curNode = curNode.firstChild;
continue;
} else if (curNode.nextSibling) {
// Move forward:
curNode = curNode.nextSibling;
continue;
}
// Move forward or up:
while (true) {
if (curNode.nextSibling) {
curNode = curNode.nextSibling;
break;
} else if (curNode.parentNode !== node) {
curNode = curNode.parentNode;
} else {
break out;
}
}
}
}
/**
* Generates the actual replaceFn which splits up text nodes
* and inserts the replacement element.
*/
function genReplacer(nodeName) {
var makeReplacementNode;
if (typeof nodeName != 'function') {
var stencilNode = nodeName.nodeType ? nodeName : doc.createElement(nodeName);
makeReplacementNode = function () {
var clone = stencilNode.cloneNode(false);
return clone;
};
} else {
makeReplacementNode = nodeName;
}
return function replace(range) {
var before, after, parentNode, startNode = range.startNode,
endNode = range.endNode;
if (startNode === endNode) {
var node = startNode;
parentNode = node.parentNode;
if (range.startNodeIndex > 0) {
// Add `before` text node (before the match)
before = doc.createTextNode(node.data.substring(0, range.startNodeIndex));
parentNode.insertBefore(before, node);
}
// Create the replacement node:
var el = makeReplacementNode();
parentNode.insertBefore(el, node);
if (range.endNodeIndex < node.length) {
// Add `after` text node (after the match)
after = doc.createTextNode(node.data.substring(range.endNodeIndex));
parentNode.insertBefore(after, node);
}
node.parentNode.removeChild(node);
return el;
}
};
}
text = getText(node);
if (!text) {
return;
}
while ((m = regex.exec(text))) {
matches.push(getMatchIndexes(m, captureGroup));
}
if (matches.length) {
count = matches.length;
stepThroughMatches(node, matches, genReplacer(replacementNode));
}
return count;
}
function replaceAllMatches(smiley) {
var each = tinymce.each, node = editor.selection.getNode(), marker, text;
if (typeof (smiley.shortcut) === 'string') {
text = smiley.shortcut.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
marker = editor.dom.create('img', { "src": smiley.url, "title": smiley.title });
return findAndReplaceDOMText(new RegExp(text, 'gi'), node, marker, false, editor.schema);
}
else if (Array.isArray(smiley.shortcut)) {
each(smiley.shortcut, function(item) {
marker = editor.dom.create('img', { "src": smiley.url, "title": smiley.title });
return findAndReplaceDOMText(new RegExp(item.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), 'gi'), node, marker, false, editor.schema);
});
}
}
editor.on("keyup", function (e) {
if (!!editor.settings.auto_convert_smileys) {
var each = tinymce.each, selection = editor.selection, node = selection.getNode();
if (node) {
each(concatArray(fullSmileysList), function (smiley) {
replaceAllMatches(smiley);
});
}
}
});
editor.addButton('smileys', {
type: 'panelbutton',
icon: 'emoticons',
panel: {
autohide: true,
html: getHtml,
onclick: function (e) {
var linkElm = editor.dom.getParent(e.target, 'a');
if (linkElm) {
editor.insertContent('<img src="' + linkElm.getAttribute('data-mce-url') + '" title="' + linkElm.getAttribute('title') + '" />');
this.hide();
}
}
},
tooltip: 'Smileys'
});
});

View File

@@ -0,0 +1,4 @@
tinymce.PluginManager.add("smileys",function(n,t){function e(){var n;return n='<table role="presentation" class="mce-grid">',tinymce.each(r,function(t){n+="<tr>";tinymce.each(t,function(t){n+='<td><a href="#" data-mce-url="'+t.url+'" tabindex="-1" title="'+t.title+'"><img src="'+t.url+'" style="width: 16px; height: 16px"><\/a><\/td>'});n+="<\/tr>"}),n+="<\/table>"}function o(n){var i=tinymce.each,t=[];return i(n,function(n){t=t.concat(n)}),t.length>0?t:n}function u(n,t,i,r,u){function y(n,t){var i,r;return t=t||0,i=n.index,t>0&&(r=n[t],i+=n[0].indexOf(r),n[0]=r),[i,i+n[0].length,[n[0]]]}function v(n){var t;if(n.nodeType===3)return n.data;if(h[n.nodeName]&&!f[n.nodeName])return"";if(t="",(f[n.nodeName]||c[n.nodeName])&&(t+="\n"),n=n.firstChild)do t+=v(n);while(n=n.nextSibling);return t}function p(n,t,i){var o,s,v,l,a=[],u=0,r=n,e=t.shift(),y=0;n:for(;;){if((f[r.nodeName]||c[r.nodeName])&&u++,r.nodeType===3&&(!s&&r.length+u>=e[1]?(s=r,l=e[1]-u):o&&a.push(r),!o&&r.length+u>e[0]&&(o=r,v=e[0]-u),u+=r.length),o&&s){if(r=i({startNode:o,startNodeIndex:v,endNode:s,endNodeIndex:l,innerNodes:a,match:e[2],matchIndex:y}),u-=s.length-l,o=null,s=null,a=[],e=t.shift(),y++,!e)break}else if((!h[r.nodeName]||f[r.nodeName])&&r.firstChild){r=r.firstChild;continue}else if(r.nextSibling){r=r.nextSibling;continue}for(;;)if(r.nextSibling){r=r.nextSibling;break}else if(r.parentNode!==n)r=r.parentNode;else break n}}function w(n){var t,i;return typeof n!="function"?(i=n.nodeType?n:o.createElement(n),t=function(){return i.cloneNode(!1)}):t=n,function(n){var f,e,r,s=n.startNode,h=n.endNode,i,u;if(s===h)return i=s,r=i.parentNode,n.startNodeIndex>0&&(f=o.createTextNode(i.data.substring(0,n.startNodeIndex)),r.insertBefore(f,i)),u=t(),r.insertBefore(u,i),n.endNodeIndex<i.length&&(e=o.createTextNode(i.data.substring(n.endNodeIndex)),r.insertBefore(e,i)),i.parentNode.removeChild(i),u}}var l,e=[],s,a=0,o,f,h,c;if(o=t.ownerDocument,f=u.getBlockElements(),h=u.getWhiteSpaceElements(),c=u.getShortEndedElements(),s=v(t),s){while(l=n.exec(s))e.push(y(l,r));return e.length&&(a=e.length,p(t,e,w(i))),a}}function s(t){var e=tinymce.each,r=n.selection.getNode(),i,f;if(typeof t.shortcut=="string")return f=t.shortcut.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=n.dom.create("img",{src:t.url,title:t.title}),u(new RegExp(f,"gi"),r,i,!1,n.schema);Array.isArray(t.shortcut)&&e(t.shortcut,function(f){return i=n.dom.create("img",{src:t.url,title:t.title}),u(new RegExp(f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),"gi"),r,i,!1,n.schema)})}var f=[[{shortcut:"(^^^)",url:t+"/img/shark.gif",title:"shark"},{shortcut:"O:)",url:t+"/img/angel.png",title:"angel"},{shortcut:"o.O",url:t+"/img/confused.png",title:"confused"},{shortcut:"3:)",url:t+"/img/devil.png",title:"devil"},{shortcut:":-O",url:t+"/img/gasp.png",title:"gasp"},{shortcut:"8-)",url:t+"/img/glasses.png",title:"glasses"},{shortcut:":-D",url:t+"/img/grin.png",title:"grin"}],[{shortcut:":-)",url:t+"/img/smile.png",title:"smile"},{shortcut:":'(",url:t+"/img/cry.png",title:"cry"},{shortcut:"<3",url:t+"/img/heart.png",title:"heart"},{shortcut:"^_^",url:t+"/img/kiki.png",title:"kiki"},{shortcut:":-*",url:t+"/img/kiss.png",title:"kiss"},{shortcut:":v",url:t+"/img/pacman.png",title:"pacman"},{shortcut:"<(<28>)",url:t+"/img/penguin.gif",title:"penguin"}],[{shortcut:":|]",url:t+"/img/robot.gif",title:"robot"},{shortcut:"-_-",url:t+"/img/squint.png",title:"squint"},{shortcut:"8-|",url:t+"/img/sunglasses.png",title:"sunglasses"},{shortcut:":-P",url:t+"/img/tongue.png",title:"tongue"},{shortcut:":/",url:t+"/img/unsure.png",title:"unsure"},{shortcut:">:O",url:t+"/img/upset.png",title:"upset"},{shortcut:">:(",url:t+"/img/grumpy.png",title:"grumpy"}]],i=n.settings.smileys||f,r=n.settings.extended_smileys?i.concat(n.settings.extended_smileys):i;n.on("keyup",function(){if(!!n.settings.auto_convert_smileys){var t=tinymce.each,i=n.selection,u=i.getNode();u&&t(o(r),function(n){s(n)})}});n.addButton("smileys",{type:"panelbutton",icon:"emoticons",panel:{autohide:!0,html:e,onclick:function(t){var i=n.dom.getParent(t.target,"a");i&&(n.insertContent('<img src="'+i.getAttribute("data-mce-url")+'" title="'+i.getAttribute("title")+'" />'),this.hide())}},tooltip:"Smileys"})});
/*
//# sourceMappingURL=plugin.min.js.map
*/

View File

@@ -1,9 +1,9 @@
<?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>
insertdatetime media nonbreaking save table contextmenu directionality emoticons template paste textcolor emoticons</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 template | e107-image e107-video e107-glyph | preview</toolbar1>
<toolbar1>undo redo | styleselect | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image template | e107-image e107-video e107-glyph smileys | preview</toolbar1>
<external_plugins>e107 example compat3x</external_plugins>
<image_advtab>true</image_advtab>
<extended_valid_elements>i[*], object[*],embed[*],bbcode[*]</extended_valid_elements>

View File

@@ -215,15 +215,22 @@ class wysiwyg
{
return;
}
$tmp = explode(" ",$data);
if(e107::pref('core','smiley_activate',false))
{
$tmp[] = "smileys";
}
$ext = array();
foreach($tmp as $val)
{
$ext[$val] = e_PLUGIN_ABS."tinymce4/plugins/".$val."/plugin.js";
}
return json_encode($ext);
@@ -274,6 +281,7 @@ class wysiwyg
{
$tp = e107::getParser();
$fl = e107::getFile();
if(getperms('0'))
{
@@ -331,6 +339,43 @@ class wysiwyg
// Emoticon Support @see //https://github.com/nhammadi/Smileys
if(e107::pref('core','smiley_activate',false))
{
$emo = e107::getConfig("emote")->getPref();
$pack = e107::pref('core','emotepack');
$emotes = array();
$i = 0;
$c = 0;
foreach($emo as $path=>$co)
{
$codes = explode(" ",$co);
$url = SITEURLBASE.e_IMAGE_ABS."emotes/" . $pack . "/" . str_replace("!",".",$path);
$emotes[$i][] = array('shortcut'=>$codes, 'url'=>$url, 'title'=>ucfirst($path));
if($c == 6)
{
$i++;
$c = 0;
}
else
{
$c++;
}
}
// print_r($emotes);
$ret['extended_smileys'] = json_encode($emotes);
}
$ret['convert_fonts_to_spans'] = false;
$ret['content_css'] = e_PLUGIN_ABS.'tinymce4/editor.css,https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css,http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css';