UBB.Dev
Posted By: Max Fisch Automatic Smileys - 11/27/2001 6:03 AM
Here's an adaptation of Gerrit's automatic smileys hack, posted on the Perl board on https://www.ubbdev.com/threads/perl/showthreaded.pl?Cat=&Board=custom&Number=34040

With this hack, smileys are automatically converted to markup, so if you type in :-) , you get []https://www.ubbdev.com/threads/php/images/icons/smile.gif[/] , etc

In ubbt.inc.php, after line 442 which is
$Body = eregi_replace("\[$lang[ICON_WINK]\]","<img src="$config[images]/icons/wink.gif">",$Body);

enter the following section:

// Automatically convert text smileys to graphics ***** Added *****
$Body = eregi_replace("\:-\)","<img src="$config[images]/icons/smile.gif">",$Body);
$Body = eregi_replace("\}\:-\(","<img src="$config[images]/icons/mad.gif">",$Body);
$Body = eregi_replace("\:-\(","<img src="$config[images]/icons/frown.gif">",$Body);
$Body = eregi_replace("\:-o","<img src="$config[images]/icons/blush.gif">",$Body);
$Body = eregi_replace("8-\)","<img src="$config[images]/icons/cool.gif">",$Body);
$Body = eregi_replace("\:-\}","<img src="$config[images]/icons/crazy.gif">",$Body);
$Body = eregi_replace("\:-D","<img src="$config[images]/icons/laugh.gif">",$Body);
$Body = eregi_replace("\:-O","<img src="$config[images]/icons/shocked.gif">",$Body);
$Body = eregi_replace("\:-P","<img src="$config[images]/icons/tongue.gif">",$Body);
$Body = eregi_replace("\;-\)","<img src="$config[images]/icons/wink.gif">",$Body);

That should be it!
Max
Posted By: AllenAyres Re: Automatic Smileys - 11/27/2001 5:38 PM
nice one []https://www.ubbdev.com/threads/php/images/icons/smile.gif[/]

This is being done on 5.5 as well, helps my slow fingers for sure :)

Do most people use the - in smilies? As in :-), or do you just type in smile ? I've been used to the shorter method for so long, I guess it would be easy enough to just add both to the files so they both work smile
Posted By: Max Fisch Re: Automatic Smileys - 11/27/2001 5:51 PM
I actually use the short form myself - but I kindof like forcing the "-", that way there are fewer "accidental" translations.

Some users don't like the automatic translation, find the graphics goofy, and this way they're not forced to switch off Markup to make their posts.

Just my 2 cents.

By the way, please note that I modified one of the smileys: the original "mad" symbol, >:-( , was giving me problems for some reason, so I modified it to }:-(

Cheers,
Max
Posted By: powerlord Re: Automatic Smileys - 11/28/2001 9:33 AM
It's because of html tags. I actually made a hack to do smileys a while back. You can find my version here in the various subdirectories. The only real differences between versions are the line numbers updated.

This line in particular is probably what you're looking for:
$Body = eregi_replace("<br<img src="$config[images]/icons/mad.gif">","<br><img src="$config[images]/icons/frown.gif">",$Body);
Posted By: Max Fisch Re: Automatic Smileys - 11/28/2001 5:21 PM
Thanks powerlord,

but that's not it... I continue to have a problem with > .

If I'm interpreting your line correctly, it would correct situations where a newline is followed by :-( , and the closing bracket of <br> is getting incorrectly incorporated into the translation.

The actual situation I'm describing is that >:-( is not getting translated into "mad" at all, the > is getting ignored and I get the following:
>[]https://www.ubbdev.com/threads/php/images/icons/frown.gif[/] instead of []https://www.ubbdev.com/threads/php/images/icons/mad.gif[/]

As soon as I replace the closing bracket with another character, the problem goes away.

Regards,
Max
Posted By: AllenAyres Re: Automatic Smileys - 11/28/2001 5:46 PM
we use mad in ubb, you might consider that one... it's easy to type and all smile
Posted By: Rick Re: Automatic Smileys - 11/28/2001 6:11 PM
Does your regex for mad come before frown? If frown comes first then it is going to match that first and give you this problem.
Posted By: Max Fisch Re: Automatic Smileys - 11/28/2001 6:27 PM
Nope... that was actually my first thought. I tried removing all other translations, with no success.

Note that I was having the same problem in Perl, as per the discussion on https://www.ubbdev.com/threads/perl/showthreaded.pl?Cat=&Board=custom&Number=43145 .

I wonder if it's something specific to my server/php/mysql installation. In any case, I don't think it's too important: I think I disagree with the use of > as part of an automatically translated smiley: it creates too many exception conditions, that would need to be reverse-translated. These were heroically identified by Powerlord on http://www.vgmusic.com/~powerlord/wwwthreads/5.4.4php/Smileys.txt

Max
Posted By: Max Fisch Re: Automatic Smileys - 11/28/2001 6:28 PM
Well, that's not too different from using the traditional markup.
Max
Posted By: Rick Re: Automatic Smileys - 11/28/2001 6:57 PM
Ah, it's probably the > that is doing it. Normally this is an HTML character, so it get's translated to > on boards where HTML is not enabled. Which is probably why it isn't matching.
Posted By: Max Fisch Re: Automatic Smileys - 11/28/2001 10:35 PM
Ah, ok, that makes sense. I'll stick to } , since I don't want to have multiple translation/untranslation routines depending on whether html is enabled or not on that particular post (I allow users to select).
Max
Posted By: powerlord Re: Automatic Smileys - 11/29/2001 12:21 AM
That's probably a good idea.

I'd be interested in seeing how Scream does it in the next version. I prefer getting rid of my hacks in favor of built in functions. :)

Oh, you might have noticed an adaptation of Eileen's Icons4Attachments in my directories. I'm surprised that Scream hasn't made something like that part of the main distribution, or at least the part that has an icon next to the word Attachment.

The one next to the topics in expanded mode on the postlist page isn't all that important, but my users like having a visual to cue them in to what type of file is attached. (Did I mention that one of my sites boards has a lot of files attached?)
Posted By: Max Fisch Re: Automatic Smileys - 11/29/2001 1:06 AM
> I prefer getting rid of my hacks in favor of built in functions.

Same here!

> Oh, you might have noticed an adaptation of Eileen's
> Icons4Attachments in my directories

I don't use icons on my boards... too many gizmos make me dizzy :)

Max
Posted By: AllenAyres Re: Automatic Smileys - 12/06/2001 1:00 AM
Nice one, works well []https://www.ubbdev.com/threads/php/images/icons/wink.gif[/]
© UBB.Developers