Partiendo de este proyecto http://www.phpbb.com/community/viewtopic.php?f=72&t=1029315&start=0
voy a intentar explicar los pasos para añadir mis propios emoticonos.

Los ficheros que hay que modificar son:

tinymcejscriptstiny_mcepluginsbbcodeeditor_plugin.js

Este fichero es que el convierte html a bbcode y viceversa. Aquí meteremos las siguientes líneas:

// example: <strong> to [b]
rep(/&lt;a.*?href=&quot;(.*?)&quot;.*?&gt;(.*?)&lt;/a&gt;/gi,&quot;[url=$1]$2[/url]&quot;);
rep(/&lt;font.*?color=&quot;(.*?)&quot;.*?class=&quot;codeStyle&quot;.*?&gt;(.*?)&lt;/font&gt;/gi,&quot;[code][color=$1]$2[/color][/code]&quot;);
rep(/&lt;font.*?color=&quot;(.*?)&quot;.*?class=&quot;quoteStyle&quot;.*?&gt;(.*?)&lt;/font&gt;/gi,&quot;[quote][color=$1]$2[/color][/quote]&quot;);
rep(/&lt;font.*?class=&quot;codeStyle&quot;.*?color=&quot;(.*?)&quot;.*?&gt;(.*?)&lt;/font&gt;/gi,&quot;[code][color=$1]$2[/color][/code]&quot;);
rep(/&lt;font.*?class=&quot;quoteStyle&quot;.*?color=&quot;(.*?)&quot;.*?&gt;(.*?)&lt;/font&gt;/gi,&quot;[quote][color=$1]$2[/color][/quote]&quot;);
rep(/<span style="color: ?(.*?);">(.*?)</span>/gi,"[color=$1]$2[/color]");
rep(/&lt;font.*?color=&quot;(.*?)&quot;.*?&gt;(.*?)&lt;/font&gt;/gi,&quot;[color=$1]$2[/color]&quot;);
// font size
rep(/&lt;span.*?style=&quot;font-size: 8px;&quot;&gt;(.*?)&lt;/span&gt;/gi,&quot;[size=50]$1[/size]&quot;);
rep(/&lt;font.*?style=&quot;font-size: 8px;&quot;&gt;(.*?)&lt;/font&gt;/gi,&quot;[size=50]$1[/size]&quot;);
rep(/&lt;span.*?style=&quot;font-size: 10px;&quot;&gt;(.*?)&lt;/span&gt;/gi,&quot;[size=85]$1[/size]&quot;);
rep(/&lt;font.*?style=&quot;font-size: 10px;&quot;&gt;(.*?)&lt;/font&gt;/gi,&quot;[size=85]$1[/size]&quot;);
rep(/&lt;span.*?style=&quot;font-size: 12px;&quot;&gt;(.*?)&lt;/span&gt;/gi,&quot;$1&quot;);
rep(/&lt;font.*?style=&quot;font-size: 12px;&quot;&gt;(.*?)&lt;/font&gt;/gi,&quot;$1&quot;);
rep(/&lt;span.*?style=&quot;font-size: 14px;&quot;&gt;(.*?)&lt;/span&gt;/gi,&quot;[size=150]$1[/size]&quot;);
rep(/&lt;font.*?style=&quot;font-size: 14px;&quot;&gt;(.*?)&lt;/font&gt;/gi,&quot;[size=150]$1[/size]&quot;);
rep(/<span.*?style="font-size: 18px;">(.*?)</span>/gi,"[size=200]$1[/size]");
rep(/&lt;font.*?style=&quot;font-size: 18px;&quot;&gt;(.*?)&lt;/font&gt;/gi,&quot;[size=200]$1[/size]&quot;);
rep(/&lt;span.*?style=&quot;font-size: 24px;&quot;&gt;(.*?)&lt;/span&gt;/gi,&quot;[size=200]$1[/size]&quot;);
rep(/&lt;font.*?style=&quot;font-size: 24px;&quot;&gt;(.*?)&lt;/font&gt;/gi,&quot;[size=200]$1[/size]&quot;);
rep(/&lt;span.*?style=&quot;font-size: 36px;&quot;&gt;(.*?)&lt;/span&gt;/gi,&quot;[size=200]$1[/size]&quot;);
rep(/&lt;font.*?style=&quot;font-size: 36px;&quot;&gt;(.*?)&lt;/font&gt;/gi,&quot;[size=200]$1[/size]&quot;);
rep(/<font>(.*?)</font>/gi,"$1");

rep(/&lt;img.*?src=&quot;(.*?)&quot;.*?/&gt;/gi,&quot;[img]$1[/img]&quot;);
// emoticons

rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/angry.gif[/img]/gi,&quot;Y_Y&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/argh.gif[/img]/gi,&quot;:-@&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/bored.gif[/img]/gi,&quot;:-O&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/confused_smile.gif[/img]/gi,&quot;:-?&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/cry_smile.gif[/img]/gi,&quot;:'(&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/embaressed_smile.gif[/img]/gi,&quot;:-*)&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/furious.gif[/img]/gi,&quot;&gt;:@&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/glasses.gif[/img]/gi,&quot;8-)&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/indiferent.gif[/img]/gi,&quot;:-|&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/silent.gif[/img]/gi,":-x");
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/omg_smile.gif[/img]/gi,&quot;:-D&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/party.gif[/img]/gi,&quot;&lt;:-)&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/regular_smile.gif[/img]/gi,&quot;:-)&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/sad_smile.gif[/img]/gi,&quot;:-(&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/saint.gif[/img]/gi,&quot;O:-)&quot;);
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/shades_smile.gif[/img]/gi,&quot;:-D&quot;);

// lists
rep(/&lt;ul[^&gt;]*&gt;(.*?)&lt;/ul&gt;/gi,&quot;[list]n$1[/list]&quot;);
rep(/&lt;ol style=&quot;list-style-type: lower-alpha;&quot;&gt;(.*?)&lt;/ol&gt;/gi,&quot;[list=a]n$1[/list]&quot;);
rep(/&lt;ol[^&gt;]*&gt;(.*?)&lt;/ol&gt;/gi,&quot;[list=1]n$1[/list]&quot;);
rep(/<li>(.*?)</li>/gi,"[*]$1n");
rep(/&lt;span class=&quot;codeStyle&quot;&gt;(.*?)&lt;/span&gt;/gi,&quot;[code]$1[/code]&quot;);
rep(/&lt;span class=&quot;quoteStyle user_(.*?)&quot;&gt;(.*?)&lt;/span&gt;/gi,&quot;[quote=&quot;$1&quot;]$2[/quote]&quot;);
rep(/&lt;span class=&quot;quoteStyle&quot;&gt;(.*?)&lt;/span&gt;/gi,&quot;[quote]$1[/quote]&quot;);
rep(/&lt;strong class=&quot;codeStyle&quot;&gt;(.*?)&lt;/strong&gt;/gi,&quot;[code][b]$1[/b][/code]&quot;);
rep(/&lt;strong class=&quot;quoteStyle&quot;&gt;(.*?)&lt;/strong&gt;/gi,&quot;[quote][b]$1[/b][/quote]&quot;);
rep(/&lt;em class=&quot;codeStyle&quot;&gt;(.*?)&lt;/em&gt;/gi,&quot;[code][i]$1[/i][/code]&quot;);
rep(/<em class="quoteStyle">(.*?)</em>/gi,"[quote][i]$1[/i][/quote]");
rep(/&lt;u class=&quot;codeStyle&quot;&gt;(.*?)&lt;/u&gt;/gi,&quot;[code][u]$1[/u][/code]&quot;);
rep(/&lt;u class=&quot;quoteStyle&quot;&gt;(.*?)&lt;/u&gt;/gi,&quot;[quote][u]$1[/u][/quote]&quot;);
rep(/&lt;/(strong|b)&gt;/gi,&quot;[/b]&quot;);
rep(/<(strong|b)>/gi,"[b]");
rep(/&lt;/(em|i)&gt;/gi,&quot;[/i]&quot;);
rep(/&lt;(em|i)&gt;/gi,&quot;[i]&quot;);
rep(/&lt;/u&gt;/gi,&quot;[/u]&quot;);
rep(/&lt;span style=&quot;text-decoration: ?underline;&quot;&gt;(.*?)&lt;/span&gt;/gi,&quot;[u]$1[/u]&quot;);
rep(/<u>/gi,"[u]");
rep(/&lt;blockquote[^&gt;]*&gt;/gi,&quot;[quote]&quot;);
rep(/&lt;/blockquote&gt;/gi,&quot;[/quote]&quot;);
rep(/<br />/gi,"n");
rep(/&lt;br/&gt;/gi,&quot;n&quot;);
rep(/&lt;br&gt;/gi,&quot;n&quot;);
rep(/<p>/gi,"");
rep(/&lt;/p&gt;/gi,&quot;n&quot;);
rep(/&amp;nbsp;/gi,&quot; &quot;);
rep(/&amp;quot;/gi,&quot;&quot;&quot;);
rep(/&lt;/gi,"<");
rep(/&amp;gt;/gi,&quot;&gt;&quot;);
rep(/&amp;amp;/gi,&quot;&amp;&quot;);
y,

// example: [b] to &lt;strong&gt;
rep(/n/gi,&quot;&lt;br /&gt;&quot;);
rep(/[b]/gi,"<strong>");
rep(/[/b]/gi,&quot;&lt;/strong&gt;&quot;);
rep(/[i]/gi,&quot;&lt;em&gt;&quot;);
rep(/[/i]/gi,&quot;&lt;/em&gt;&quot;);
rep(/[u]/gi,"<u>");
rep(/[/u]/gi,&quot;&lt;/u&gt;&quot;);
rep(/[url=([^]]+)](.*?)[/url]/gi,&quot;&lt;a href=&quot;$1&quot;&gt;$2&lt;/a&gt;&quot;);
rep(/[url](.*?)[/url]/gi,&quot;&lt;a href=&quot;$1&quot;&gt;$1&lt;/a&gt;&quot;);
rep(/[img](.*?)[/img]/gi,&quot;&lt;img src=&quot;$1&quot; /&gt;&quot;);
rep(/[color=(.*?)](.*?)[/color]/gi,&quot;&lt;font color=&quot;$1&quot;&gt;$2&lt;/font&gt;&quot;);
rep(/[code](.*?)[/code]/gi,&quot;&lt;span class=&quot;codeStyle&quot;&gt;$1&lt;/span&gt;&amp;nbsp;&quot;);
rep(/[quote=&quot;(.*?)&quot;](.*?)[/quote]/gi,&quot;&lt;span class=&quot;quoteStyle user_$1&quot;&gt;$2&lt;/span&gt;&amp;nbsp;&quot;);
rep(/[quote.*?](.*?)[/quote]/gi,&quot;&lt;span class=&quot;quoteStyle&quot;&gt;$1&lt;/span&gt;&amp;nbsp;&quot;);
// font size
rep(/[size=50](.*?)[/size]/gi,&quot;&lt;span style=&quot;font-size: 8px;&quot;&gt;$1&lt;/span&gt;&quot;);
rep(/[size=85](.*?)[/size]/gi,&quot;&lt;span style=&quot;font-size: 10px;&quot;&gt;$1&lt;/span&gt;&quot;);
rep(/[size=150](.*?)[/size]/gi,&quot;&lt;span style=&quot;font-size: 14px;&quot;&gt;$1&lt;/span&gt;&quot;);
rep(/[size=200](.*?)[/size]/gi,&quot;&lt;span style=&quot;font-size: 18px;&quot;&gt;$1&lt;/span&gt;&quot;);
// emoticons
//rep(/:D/gi, &quot;&lt;img src=&quot;./images/smilies/icon_e_biggrin.gif&quot; /&gt;&quot;);
rep(/Y_Y/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/angry.gif&quot; /&gt;&quot;);
rep(/:-@/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/argh.gif&quot; /&gt;&quot;);
rep(/:-O/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/bored.gif&quot; /&gt;&quot;);
rep(/:-?/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/confused_smile.gif&quot; /&gt;&quot;);
rep(/:'(/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/cry_smile.gif&quot; /&gt;&quot;);
rep(/:-*)/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/embaressed_smile.gif&quot; /&gt;&quot;);
rep(/&gt;:@/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/furious.gif&quot; /&gt;&quot;);
rep(/8-)/gi,"<img src="../jscripts/tiny_mce/plugins/emoticons/img/glasses.gif" />");
rep(/:-|/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/indiferent.gif&quot; /&gt;&quot;);
rep(/:-x/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/silent.gif&quot; /&gt;&quot;);
rep(/:-D/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/omg_smile.gif&quot; /&gt;&quot;);
rep(/&lt;:-)/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/party.gif&quot; /&gt;&quot;);
rep(/:-)/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/regular_smile.gif&quot; /&gt;&quot;);
rep(/:-(/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/sad_smile.gif&quot; /&gt;&quot;);
rep(/O:-)/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/saint.gif&quot; /&gt;&quot;);
rep(/:-D/gi,&quot;&lt;img src=&quot;../jscripts/tiny_mce/plugins/emoticons/img/shades_smile.gif&quot; /&gt;&quot;);

// lists
rep(/[list](.*?)[/list]/gi, &quot;&lt;ul&gt;&lt;li&gt;$1&lt;/li&gt;&lt;/ul&gt;&quot;);
rep(/[list=1](.*?)[/list]/gi, &quot;&lt;ol&gt;&lt;li&gt;$1&lt;/li&gt;&lt;/ol&gt;&quot;);
rep(/[list=a](.*?)[/list]/gi, &quot;&lt;ol style=&quot;list-style-type: lower-alpha;&quot;&gt;&lt;li&gt;$1&lt;/li&gt;&lt;/ol&gt;&quot;);
rep(/[*]/g, "</li><li>");
// fix empty li's
rep(/&lt;li&gt;&lt;br /&gt;&lt;/li&gt;/g, &quot;&quot;);
rep(/<li/>/g, "");

Lo correcto hubiera sido crear un plugin nuevo, pero bueno.

Crear un plugin nuevo emoticons (a partir de &quot;emotions&quot;)

Este es el plugin que se encargará de insertar los emoticonos al hacer click en el icono correspondiente. Por lo tanto, hay que añadir los “.gif” que queramos usar y su correspondiente ruta en “editor_plugin.js”

Z:SINCROdevwwwcriticame – actualcriticamebintinymcejscriptstiny_mcethemesadvancedskinsdefaultui.css

Añadir la siguiente línea para que muestre el botón del plugin anterior:

.defaultSkin span.mce_emoticons {background-position:-60px -20px}

Script de ayuda

Para generar las líneas anteriores podemos usar este script:

$emoticonos = array(
"angry.gif" => "Y_Y",
"argh.gif" => ":-@",
"bored.gif" => ":-O",
"confused_smile.gif" => ":-?",
"cry_smile.gif" => ":'(",
"embaressed_smile.gif" => ":-*)",
"furious.gif" => ">:@",
"glasses.gif" => "8-)",
"indiferent.gif" => ":-|",
"silent.gif" => ":-x",
"omg_smile.gif" => ":-D",
"party.gif" => "<:-)",
"regular_smile.gif" => ":-)",
"sad_smile.gif" => ":-(",
"saint.gif" => "O:-)",
"shades_smile.gif" => ":-D"
);

// Esto es para editor_plugin.js
foreach ($emoticonos as $filename => $atajo) {
$html = ' ";
$html .= ""{#emotions_dlg.cool}"

n";
print $html;
}
print "n";

foreach ($emoticonos as $filename => $atajo) {
$filename = str_replace(".", ".", $filename);
$atajo = str_replace(""",""", $atajo);
?>
rep(/[img]../jscripts/tiny_mce/plugins/emoticons/img/[/img]/gi,"");
}
print "n";
// y esto también es para editor_plugin.js
foreach ($emoticonos as $filename => $atajo) {
$atajo = str_replace(""",""", $atajo);
$atajo = str_replace("*","*", $atajo);
$atajo = str_replace("'","'", $atajo);
$atajo = str_replace("|","|", $atajo);
$atajo = str_replace("?","?", $atajo);
print "rep(/$atajo/gi,"");n";
}
print "n";

?>