phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

How to keep smilies from getting parsed?


 
Search this topic... | Search MOD Writing... | Search Box
Register or Login to Post    Index » MOD Writing  Previous TopicPrint TopicNext Topic
Author Message
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Sat Oct 02, 2010 9:05 am 
Post subject: How to keep smilies from getting parsed?

I would like to show smilies as their code instead of as images, in topic view.

Where should I look for the code I will have to change?

Or will this require totally new code?

Is this part of bbcode.php the part were the smilies get parsed or is there more code involved?

Code:
//
// Smilies code ... would this be better tagged on to the end of bbcode.php?
// Probably so and I'll move it before B2
//
function smilies_pass($message)
{
    static $orig, $repl;

    if (!isset($orig))
    {
        global $db, $board_config;
        $orig = $repl = array();

        $sql = 'SELECT * FROM ' . SMILIES_TABLE;
        if( !$result = $db->sql_query($sql) )
        {
            message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
        }
        $smilies = $db->sql_fetchrowset($result);

        if (count($smilies))
        {
            usort($smilies, 'smiley_sort');
        }

        for ($i = 0; $i < count($smilies); $i++)
        {
            $orig[] = "/(?<=.\W|\W.|^\W)" . preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/";
            $repl[] = '<img src="'. $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" alt="' . $smilies[$i]['emoticon'] . '" border="0" />';
        }
    }

    if (count($orig))
    {
        $message = preg_replace($orig, $repl, ' ' . $message . ' ');
        $message = substr($message, 1, -1);
    }
   
    return $message;
}

_________________
phpBB2 will never die, I hope!
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Sat Oct 02, 2010 2:37 pm 
Post subject: Re: How to keep smilies from getting parsed?

I believe it's during the post that smilies are parsed. Notice underneath the post box when you reply to a topic the "Disable Smilies in this post" checkbox.

I believe the code you posted is just listing smilies, like in the rows beside the Reply box, in the ACP, or something like that. Though I'm not entirely sure.

I'd just snoop around viewtopic.php for anything smilie-related. Try simply removing code (if it looks like it might be what needs to be removed) and running it. Just paste it back if it doesn't work and/or breaks something. :P

If that doesn't work, just post again and I'll take a look in the files myself to see if I can hunt the code down.
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Sat Oct 02, 2010 4:34 pm 
Post subject: Re: How to keep smilies from getting parsed?

I believe you're right, smilies are parsed on posting, not on viewing.

And I guess the code I posted is the one that parses 'em. icon_mrgreen.gif

I'll have a looky as you suggest, but I guess something will have to be written to preg_replace them out of view.

**EDIT** Five minutes later.

Well, that was quick, and easy.

In viewtopic.php:

Code:
    //
    // Parse smilies
    //
    if ( $board_config['allow_smilies'] )
    {
        if ( $postrow[$i]['user_allowsmile'] && $user_sig != '' )
        {
            $user_sig = smilies_pass($user_sig);
        }

        if ( $postrow[$i]['enable_smilies'] )
        {
            $message = smilies_pass($message);
        }
    }


Removing
Code:
        if ( $postrow[$i]['enable_smilies'] )
        {
            $message = smilies_pass($message);
        }
does exactly what I want. icon_biggrin.gif
_________________
phpBB2 will never die, I hope!
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 663
Location: Texas


flag
PostPosted: Mon Oct 11, 2010 1:19 pm 
Post subject: Re: How to keep smilies from getting parsed?

Sorry I'm late (was out last week at a conference) but that is exactly what I have done here on this board, for the "Don't show smilies" profile option. You may also need to find the area that parses signatures. If you can't find it, let me know and I will post it.
_________________
phpBBDoctor Blog
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Writing  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0316 seconds using 16 queries. (SQL 0.0067 Parse 0.0009 Other 0.0240)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo