Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Parse BBCode (in 3.5)
Andreas's Avatar
Andreas
Join Date: Jan 2004
Posts: 6,863

 

Germany
Show Printable Version Email this Page Subscription
Andreas Andreas is offline 06-07-2005, 10:00 PM

If you want to parse BBCodes somewhere in your hacks/scripts (assuming that global.php is already required):

PHP Code:
require_once(DIR '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
$parsed_text $parser->do_parse($text$do_html$do_smilies$do_bbcode$do_imgcode$do_nl2br$cachable); 
The parameters for method do_parse() are:
  • $text = Text to be parsed
  • $do_html = Whether to allow HTML or not (Default = false)
  • $do_smilies = Whether to parse smilies or not (Default = true)
  • $do_bbcode = Whether to parse BB code (Default = true)
  • $do_imgcode = Whether to parse the [img] BB code or not, independant of $do_bbcode (Default = true)
  • $do_nl2br = Whether to automatically replace new lines with HTML line breaks or not (Default = true)
    This should be set to false if you allow HTML.
  • $cachable = Whether the post text is cachable or not (Default = false)

All parameters except $text can be omitted and will use the defaults then.
Reply With Quote
  #2  
Old 06-16-2005, 02:40 AM
VBCoder VBCoder is offline
 
Join Date: Jun 2005
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can this only be used to go from BBCode --> HTML? Or can it also go from HTML --> BBCode?
Reply With Quote
  #3  
Old 06-16-2005, 02:43 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, Class vB_CodeParser can only be userd for BBCode -> HTML.

For limited HTML -> BBCode use convert_wysiwyg_html_to_bbcode() in functions_wysiwyg.php
Reply With Quote
  #4  
Old 06-16-2005, 12:44 PM
VBCoder VBCoder is offline
 
Join Date: Jun 2005
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Kirby,

Thanks. I've noticed that convert_ can handle &lt and &gt properly, but leaves &quot as &quot - not " . Any ideas?
Reply With Quote
  #5  
Old 08-03-2005, 02:57 AM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How can I do this in vB 3.0.7?
Reply With Quote
  #6  
Old 08-03-2005, 04:08 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could this be used to fix the /me problem in quotes for 3.5 RC 1?
Reply With Quote
  #7  
Old 08-09-2005, 02:22 AM
safiel's Avatar
safiel safiel is offline
 
Join Date: Mar 2002
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Search is my friend.

Thanks for posting this, was looking for a hint and this saved me lots of time.
Reply With Quote
  #8  
Old 08-11-2005, 03:32 AM
chanzero chanzero is offline
 
Join Date: Jul 2003
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

help for a noob please if i have the following...

PHP Code:
<?php
chdir
('./forums');
require_once(
'./global.php');
require_once(
'./includes/class_bbcode.php');

// test parse bb
$text "[url=http://www.mysite.com/reviews.php?id=4661][b]My Review![/b][/url]";

$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
$parsed_text $parser->do_parse($text$do_html$do_smilies$do_bbcode$do_imgcode$do_nl2br$cachable);  

print 
"parsed text = " $parsed_text;
?>
if i understand what this code does, i should get back something like this:

parsed text = My Review!

but i just get

HTML Code:
[url=http://www.mysite.com/reviews.php?id=4661][b]My Review![/b][/url]
Reply With Quote
  #9  
Old 08-11-2005, 04:57 AM
Ky Kiske's Avatar
Ky Kiske Ky Kiske is offline
 
Join Date: Dec 2001
Location: Miami, Florida
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How do you do this if it's like forum.yoursite.com? And that directory has a password?
Reply With Quote
  #10  
Old 08-30-2005, 04:44 PM
chanzero chanzero is offline
 
Join Date: Jul 2003
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by chanzero
help for a noob please if i have the following...

PHP Code:
<?php
chdir
('./forums');
require_once(
'./global.php');
require_once(
'./includes/class_bbcode.php');

// test parse bb
$text "[url=http://www.mysite.com/reviews.php?id=4661][b]My Review![/b][/url]";

$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
$parsed_text $parser->do_parse($text$do_html$do_smilies$do_bbcode$do_imgcode$do_nl2br$cachable);  

print 
"parsed text = " $parsed_text;
?>
if i understand what this code does, i should get back something like this:

parsed text = My Review!

but i just get

HTML Code:
[url=http://www.mysite.com/reviews.php?id=4661][b]My Review![/b][/url]
i should note that kirby helped me figure this out by pointing out that i did not definie $do_html, $do_smilies, $do_bbcode, $do_imgcode, etc

thanks kirby!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:00 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07144 seconds
  • Memory Usage 2,305KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_html
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete