Topic: Include baseurl with smileyparsing

function do_smilies($text)
{
    global $smiley_text, $smiley_img, $pun_config;

    $text = ' '.$text.' ';

    $num_smilies = count($smiley_text);
    for ($i = 0; $i < $num_smilies; ++$i)
        $text = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote($smiley_text[$i], '#')."(?=.\W|\W.|\W$)#m", '$1<img src="'.$pun_config['o_base_url'].'/img/smilies/'.$smiley_img[$i].'" alt="'.substr($smiley_img[$i], 0, strrpos($smiley_img[$i], '.')).'" />$2', $text);

    return substr($text, 1, -1);
}

Mind the "src="'.$pun_config['o_base_url'].'/", this helped me integrate the parsingfunctions into my site a lot faster smile Maybe it's a handy thing for 1.3 smile

Re: Include baseurl with smileyparsing

It has been added for 1.3 a few days ago tongue

3 (edited by neographikal 2006-09-06 14:30)

Re: Include baseurl with smileyparsing

Damned tongue So much for my brilliant idea :+

Another thing that could be handy: get the smiley-array's out of the parser.php and into the config.php, so you don't lose the changes with a upgrade.

Re: Include baseurl with smileyparsing

ANY modifications you make are going to be lost if you just drag/drop new files to update tongue
So, use the patch or hdiff if you've modded an affected file smile

Re: Include baseurl with smileyparsing

Sure, that's another way, but this is such a common thing: why don't centralize it?

Re: Include baseurl with smileyparsing

Because I was going to suggest using one of the mods that moves smilies to the database, and then I realized that you'd lose the mod whenever you upgraded like that anyway. tongue

Re: Include baseurl with smileyparsing

Why not seperate your smiley array into a different file, and then have the parser include that file?

Re: Include baseurl with smileyparsing

Exactly, just use the config.php as the external file smile

Re: Include baseurl with smileyparsing

I think extensions will solve these problems.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

10 (edited by guardian34 2006-09-06 17:45)

Re: Include baseurl with smileyparsing

Neo, extensions aside, do you really expect this to be an added feature. Where do you stop? I've edited the bbcode and generate_navlinks functions, should I put those in a different file? And what about this? and that? and another thing?

[This glyph didn't display right.]

Re: Include baseurl with smileyparsing

Things that are often customized and that can be centralized should be in one central place imo; ease of use smile With an upgrade you don't lose your changes smile

Re: Include baseurl with smileyparsing

Like Smartys said, you can use the hdiff to upgrade, and like Rickard said, 1.3's extensions should be a solution to this problem. I seriously doubt that any changes will be made to 1.2.x aside from bug fixes, so it's probably best to sit tight and be satisfied with the hdiff until 1.3 arrives.

Looking for a certain modification for your forum? Please take a look here before posting.