Well its been a long time but I finaly got time to look at the code

Since my knowledge of javascript was close to 0, it took a while and a lot of reading and learning javascript but I now know the basic javascript things so I analysed the problem and found a fix for it

The code can also fix the original post
http://forum.coppermine-gallery.net/index.php?topic=21863.0Here is the "problem" and explanation how to fix it :
WARNING ONLY FOR EXPERIENCED USERSthe warning is mainly because I will describe how to fix it instead of posting the complete pages here since my pages are completely different and experienced users will understand what I mean by the following parts. (see it as a guideline)
The problem was that :
* Popup clickable (and replace code transfering) smileys only worked for the new entry
* Editing existing comments would add the replace codes in the new entry instead of in the edit screen
Here is the solution and explanation
The popup screen was called by the function:
function smilieswin()
{
window.open('display_smilies.php', 'BoxSmilies', 'width=370,height=400,toolbar=0,location=0,menubar=0,directories=0,scrollbars=1');
}
this seems correct but there is a slight information thing missing in this call namely the name of the form for which the code is intended. The original function used for this
onclick="javascript:emoticon_' . $form . '(\'' . $smiley[0] . '\')"
and as you can see the $form was used in the original but disappeared in the new code. In the file display_smilies.php the name of the form was hardcode as "post" in the function:
function smilie(smilietext) {
opener.document.post.msg_body.value += " "+smilietext+" ";
}
(Extra information about this function : post = the name of the form you want to use, msg_body is the fieldname in the form you want to use )
As you seein this part the form name will always be post (which is the form name of the new entry) but when you edit comments this form name will never be called "post" but will have the name of the comment id : f{MSG_ID}
So what we need to do is to get the $form back in the function call and pass it on to the pop up screen
I used for that the following function in smilies.inc.php:
function smilieswin(from_msg)
{
var url = "display_smilies.php?message="+from_msg
window.open(url, 'BoxSmilies', 'left=0,top=0,width=300,height=800,toolbar=0,location=0,menubar=0,directories=0,scrollbars=1');
}
and renamed the generate smilies function into :
function generate_smilies($form, $field = 'message')
and used
<a href="javascript:smilieswin(\'' . $form . '\')">
instead of
><a href="javascript:smilieswin()">
to call the smilieswin function. The value of message will now be used and can be determined in the file display_smilies.php with the function
$message_id = $HTTP_GET_VARS['message'];
to pass it back to the main page edit the smilie function in this file with the following:
function smilie(smilietext,$message_id) {
opener.document.$message_id.msg_body.value += " "+smilietext+" ";
}
To get it fullly working you need to add another extra line of code in your smilies.inc.php file just at the start of the function generate_smilies, this will replace the blank values of $form and replace it with post for using at new comment entries
if ($form == "") { $form = "post"; }
Thats it!