smilies in popup box smilies in popup box
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

smilies in popup box

Started by Justttt, June 24, 2006, 02:31:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Justttt

if you would like your smiles to show in popup box

simply edit you (include/smilies.inc.php)



find
$html .= '                <td width="5%"><img src="images/smiles/' . $smiley[1] . '" alt="' . $caption . '" width="15" height="15" border="0" style="cursor:pointer;" title="' . $caption . '" onclick="javascript:emoticon_' . $form . '(\'' . $smiley[0] . '\')" /></td>' . "\n";


replace with
$html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' . "\n" . '        <tr align="center" valign="middle">' . "\n";
    $html .= '<td align=center><a href="javascript:smilieswin()">Add Smilies</a></td>     
   
    </tr>' . "\n" . '</table>' . "\n";
    $html .= <<<EOT
<script language="JavaScript" type="text/javascript">
<!--
function smilieswin()
{
window.open('display_smilies.php', 'BoxSmilies', 'width=370,height=400,toolbar=0,location=0,menubar=0,directories=0,scrollbars=1');
}

//-->
EOT;
    $html .= "</script>\n";
    return $html;



and then create a new page called display_smilies.php (stramms Work)
and insert
$html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' . "\n" . '        <tr align="center" valign="middle">' . "\n";
    $html .= '<td align=center><a href="javascript:smilieswin()"><iframe name="iwindow" style="border:1px dotted orange" scrolling=auto width=600 height=150 align=top frameborder=0 src="smiles.php"></iframe></a></td>     
   
    </tr>' . "\n" . '</table>' . "\n";
    $html .= <<<EOT
<script language="JavaScript" type="text/javascript">
<!--
function smilieswin()
{
window.open('display_smilies.php', 'BoxSmilies', 'width=370,height=400,toolbar=0,location=0,menubar=0,directories=0,scrollbars=1');
}

//-->
EOT;
    $html .= "</script>\n";
    return $html;
}


also add to your themes css (stramms work)
.pms_linecolor3
{
background-color: #EFEFEF;
font-size: 10px;
}
.pms_linecolor4
{
background-color: #D1D7DC;
font-size: 10px;
}


:)
J U S T T T T

xplicit

Since there is no link to a gallery I wanted to ask one question:

Does this one work correct when editing existing comments?

Or does the smiley appear in the new comment box instead of the comment you want to edit?

Can somebody confirm correct behaviour?
Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

owein

just tested it out...the smiley shows up in the new comment box.

xplicit

Yeah that is the kind of behaviour I expected.  :(

I have seen this behaviour before and have even checked the code to see if I could think of a soulution for this but unfortunately javascript is not one of my best skills...  :'( and haven't figured it out yet how to solve this.

The only thing I now can think of is just make it an inactive popup without interaction so the people have to enter the code themself.  And use the popup as a reminder for the smiley codes since the code is displayed next to it. I tend to favour the last for the time being






Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

Justttt

#4
hmm i dont under stand is somthing not going right ? ...

www.trippy-illusion.co.uk/album

user test
pass test123


and if you goto a image you will notice i have some smilies showing and a link saying click here for more smiles.. and all works fine so i dont understand your problem ?..

, justttt
J U S T T T T

xplicit

Quote from: Justttt on July 23, 2006, 01:02:48 PM
and if you goto a image you will notice i have some smilies showing and a link saying click here for more smiles.. and all works fine so i dont understand your problem ?..
, justttt

No it does not work fine. Try this page with the password and username you gave:

http://www.trippy-illusion.co.uk/album/displayimage.php?pos=-375

try to edit the comment and try to add a big smily from the popup. The code of the smiley will NOT appear in the box you want to edit but in the box of new comment
Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

Justttt

hmmm i never noticed that before , sorry . ok i will check on this see what i can do (Y)
J U S T T T T

xplicit

#7
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.0

Here is the "problem" and explanation how to fix it :

WARNING ONLY FOR EXPERIENCED USERS
the 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!
Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

xplicit

as an extra feature you can also add this the the ecards,

(if you leave the code as I sugested it will otherwise also say argument missing)

So add the same technique to your ecard.

But remember to change the form field for your ecard text into "msg_body" instead of "message"

Find
  <textarea name="message" class="textinput"
change into
  <textarea name="msg_body" class="textinput"

also remember to change the part were the data is proceeded
find:
$message = get_post_var('message');
change into:
$message = get_post_var('msg_body');

greetz! and happy coding!

Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

MasterOD

so is there now a solution for the popup window problem which works with the newest (1.4.12) Version?

Or does the solution, described by xplicit still work?
Anyone got any experience with that?

greetings

MasterOD

Joachim Müller

Why don't you try it and report back? We could hardly go through all modification suggestions in thousands of postings once a new version gets released, trying to figure out if the modification suggested by users works with the new release. Usually, modifications designed for cpg1.4.X work for cpg1.4.Y as well.

MasterOD

Yeah Sry... but this thread is that complicated... whatever I tried this outdated thread

http://forum.coppermine-gallery.net/index.php?topic=21863

which i used some time ago...

and it still works...