Computer Science Canada

Form Features for Final Project

Author:  Tycoon [ Tue Jan 09, 2007 11:04 pm ]
Post subject:  Form Features for Final Project

I have been working on my final project for computer programming class (I will post a link to the site once its done and needs testing) and I am currently working on the message section of the members area. But I have run into a problem, how do I make the posting section like the one they have on this forum.

With Bold, Italics, Underlining and the quote feature, thats all I need. Currently I have it replacing the codes, etc., with <b></b> using str_replace but I don't know how the |quote][/quote| (disabled it) function works.

I am sorry if something like this has already been posted.

Thanks, Tycoon.

Author:  Amailer [ Wed Jan 10, 2007 12:26 am ]
Post subject:  RE:Form Features for Final Project

php:
function replace_quote($message) {
               
        if(!empty($message)) {

                if($count = preg_match_all("#\[quote](.*?)\[/quote]#si", $message, $replace)) {
               
                        for($i=0; $i<count($count); $i++) {
                                $replace_string = $replace[1][$i];
                        }

                        $str_replace = "<b>$replace_string</b>";

                        return preg_replace("#\[quote](.*?)\[/quote]#si", $str_replace, $message);

                }
               
        } else {
               
                return false;

        }

}


Thats how phpBB does it; I am no good with regular expressions, not sure if it works-- but try

$new_msg = replace_quote($message)

Author:  Tycoon [ Wed Jan 10, 2007 10:03 am ]
Post subject:  Re: Form Features for Final Project

Oooh lovely. Thank you - I will test it out and get back to you.

edit --------------
Great, it works, but now I need to change the regular expression to read the quote box if |quote=<username] is added

I will do my best to edit the expression myself but I haven't learned those yet so I might fail.

2nd edit ----------
By using trial and error and a very basic understanding of the preg expression, I managed to figure it out Razz

Original expression (expression 1): "#\|quote](.*?)\[/quote]#si" - please note the | is actually [

Edited expression (expression2): "#\[quote=(.*?)](.*?)\[/quote]#si"

By using the second expression, combined with the first (in 2 separate loops) I can now have |quote]text[/quote| and |quote=<anything>]text[/quote|
--------------------
--------------------

Author:  Amailer [ Thu Jan 11, 2007 7:29 pm ]
Post subject:  Re: Form Features for Final Project

Nice, glad you got it. And by the way, insted of doing |quote], you should have just put your information in
code:
tags or just disabled BBcode for your post Very Happy

Author:  Clayton [ Thu Jan 11, 2007 11:23 pm ]
Post subject:  Re: Form Features for Final Project

Just like you should've Razz

Author:  Amailer [ Fri Jan 12, 2007 12:01 am ]
Post subject:  RE:Form Features for Final Project

I...i...I got attacked by the sessions bug and it logged me off, I was unable to! *runs*

Yeah Sad Thought I did? XD

Author:  Tycoon [ Sat Jan 13, 2007 2:03 am ]
Post subject:  Re: Form Features for Final Project

Yeah, I could do that.... lol [quote][/quote]


: