1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 03:40:37 +02:00

Fixed Emoticon Plugin and preview code

This commit is contained in:
CaMer0n
2009-07-01 04:19:55 +00:00
parent d2bc8727b6
commit d72ce8882f
5 changed files with 111 additions and 71 deletions

View File

@@ -9,8 +9,8 @@
* Plugin Administration - gsitemap
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/tinymce/admin_config.php,v $
* $Revision: 1.1 $
* $Date: 2009-07-01 02:52:08 $
* $Revision: 1.2 $
* $Date: 2009-07-01 04:19:55 $
* $Author: e107coders $
*
*/
@@ -22,11 +22,10 @@ if(!getperms("P") || !plugInstalled('tinymce'))
}
$e_wysiwyg = 'content';
require_once(e_ADMIN."auth.php");
require_once (e_HANDLER.'message_handler.php');
$emessage = &eMessage::getInstance();
if($_POST['save_settings'])
if($_POST['save_settings']) // Needs to be saved before e_meta.php is loaded by auth.php.
{
$pref['tinymce']['customjs'] = $_POST['customjs'];
$pref['tinymce']['theme_advanced_buttons1'] = $_POST['theme_advanced_buttons1'];
@@ -36,12 +35,18 @@ if($_POST['save_settings'])
$pref['tinymce']['plugins'] = $_POST['mce_plugins'];
save_prefs();
$emessage->add(LAN_UPDATED, E_MESSAGE_SUCCESS);
$e107->ns->tablerender(LAN_UPDATED, $emessage->render());
}
require_once(e_ADMIN."auth.php");
if($_POST['save_settings']) // is there an if $emessage? $emessage->hasMessage doesn't return TRUE.
{
$emessage->add(LAN_UPDATED, E_MESSAGE_SUCCESS);
$e107->ns->tablerender(LAN_UPDATED, $emessage->render());
}
require_once(e_HANDLER."file_class.php");
$fl = new e_file;
@@ -62,7 +67,7 @@ if($_POST['save_settings'])
if(!$pref['tinymce']['theme_advanced_buttons3'])
{
$pref['tinymce']['theme_advanced_buttons3'] = "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen";
$pref['tinymce']['theme_advanced_buttons3'] = "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen,emoticons";
}
if(!$pref['tinymce']['theme_advanced_buttons4'])
@@ -77,7 +82,7 @@ if($_POST['save_settings'])
<table style='".ADMIN_WIDTH."' class='fborder'>
<tr>
<td style='width:20%' class='forumheader3'>Preview</td>
<td style='width:20%' class='forumheader3'>Preview<br /><br />[<a href='javascript:start_tinyMce();'>Refresh Preview</a>]</td>
<td style='width:80%' class='forumheader3'>
<textarea id='content' rows='10' cols='10' name='name3' class='tbox' style='width:80%'> </textarea>
</td>

View File

@@ -1,56 +1,81 @@
/**
* $Id: editor_plugin.js,v 1.2 2009-07-01 04:19:55 e107coders Exp $
*
* @author Moxiecode
* @copyright Copyright <20> 2004-2008, Moxiecode Systems AB, All rights reserved.
*/
tinyMCE.importPluginLanguagePack('emoticons', 'en');
(function() {
// Load plugin specific language pack
tinymce.PluginManager.requireLangPack('emoticons');
// Plucin static class
var TinyMCE_emoticonsPlugin = {
getInfo : function() {
return {
longname : 'emoticons',
author : 'CaMer0n',
authorurl : 'http://e107coders.org',
infourl : 'http://www.e107.org',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
};
},
tinymce.create('tinymce.plugins.EmoticonsPlugin', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
ed.addCommand('mceEmotion', function() {
ed.windowManager.open({
file : url + '/emoticons.php',
width : 220 + parseInt(ed.getLang('emoticons.delta_width', 0)),
height : 220 + parseInt(ed.getLang('emoticons.delta_height', 0)),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
/**
* Returns the HTML contents of the emoticons control.
*/
getControlHTML : function(cn) {
switch (cn) {
case "emoticons":
return tinyMCE.getButtonHTML(cn, 'lang_emoticons_desc', '{$pluginurl}/images/emoticons.png', 'mceEmotion');
// Register example button
ed.addButton('emoticons', {
title : 'emoticons.desc',
cmd : 'mceEmotion',
image : url + '/images/emoticons.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('emoticons', n.nodeName == 'IMG');
});
},
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
createControl : function(n, cm) {
return null;
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'Emoticons plugin',
author : 'CaMer0n',
authorurl : 'http://e107coders.org',
infourl : '',
version : "1.0"
};
}
});
return "";
},
/**
* Executes the mceEmotion command.
*/
execCommand : function(editor_id, element, command, user_interface, value) {
// Handle commands
switch (command) {
case "mceEmotion":
var template = new Array();
template['file'] = '../../plugins/emoticons/emoticons.php'; // Relative to theme
template['width'] = 200;
template['height'] = 200;
// Language specific width and height addons
template['width'] += tinyMCE.getLang('lang_emoticons_delta_width', 0);
template['height'] += tinyMCE.getLang('lang_emoticons_delta_height', 0);
tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
return true;
}
// Pass to next handler in chain
return false;
}
};
// Register plugin
tinyMCE.addPlugin('emoticons', TinyMCE_emoticonsPlugin);
// Register plugin
tinymce.PluginManager.add('emoticons', tinymce.plugins.EmoticonsPlugin);
})();

View File

@@ -8,7 +8,7 @@ require_once(HEADERF);
$emotes = $sysprefs->getArray("emote_".$pref['emotepack']);
$str = "<div class='spacer' style='white-space:wrap;width:130px;text-align:center'>";
$str = "<div style='text-align:center'><div class='spacer' style='white-space:wrap;width:130px;text-align:center'>";
foreach($emotes as $key => $value){
$key = str_replace("!", ".", $key);
$key = preg_replace("#_(\w{3})$#", ".\\1", $key);
@@ -17,7 +17,8 @@ require_once(HEADERF);
$str .= "\n<a href='javascript:void(0);' onmousedown=\"javascript:insertEmotion('$key')\"><img src=\"".e_IMAGE_ABS."emotes/" . $pref['emotepack'] . "/$key\" style=\"border:0; padding-top:2px;\" alt=\"\" /></a> ";
}
$str .= "</div>";
$str .= "</div>
</div>";
echo $str;

View File

@@ -1,5 +1,5 @@
// UK lang variables
tinyMCELang['lang_insert_emoticons_title'] = 'Insert emotion';
tinyMCELang['lang_emoticons_desc'] = 'Emotions';
tinyMCE.addI18n('en.emoticons',{
desc : 'Insert emotion'
});

View File

@@ -4,8 +4,8 @@
| e107 website system - Tiny MCE controller file.
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/tinymce/wysiwyg.php,v $
| $Revision: 1.9 $
| $Date: 2009-07-01 02:52:08 $
| $Revision: 1.10 $
| $Date: 2009-07-01 04:19:55 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -45,9 +45,9 @@ $thescript = (strpos($_SERVER['SERVER_SOFTWARE'],"mod_gzip")) ? "tiny_mce_gzip.p
$text = "<script type='text/javascript' src='".e_PLUGIN."tinymce/".$thescript."'></script>\n";
$text .= "<script type='text/javascript'>\n
//<![CDATA[
function start_tinyMce() {
//<![CDATA[
tinyMCE.init({\n";
$text .= "language : '".$tinylang[$lang]."',\n";
@@ -128,7 +128,13 @@ if($pref['tinymce']['customjs'])
$text .= "
});
}
);
}
start_tinyMce();
function tinymce_html_bbcode_control(type, source) {
@@ -198,6 +204,9 @@ function triggerSave()
tinyMCE.triggerSave();
}
</script>\n
";