vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Parse BBCode (in 3.5) (https://vborg.vbsupport.ru/showthread.php?t=82693)

Andreas 06-07-2005 10:00 PM

Parse BBCode (in 3.5)
 
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.

VBCoder 06-16-2005 02:40 AM

Can this only be used to go from BBCode --> HTML? Or can it also go from HTML --> BBCode?

Andreas 06-16-2005 02:43 AM

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

VBCoder 06-16-2005 12:44 PM

Kirby,

Thanks. I've noticed that convert_ can handle &lt and &gt properly, but leaves &quot as &quot - not " . Any ideas?

Kirk Y 08-03-2005 02:57 AM

How can I do this in vB 3.0.7?

Boofo 08-03-2005 04:08 AM

Could this be used to fix the /me problem in quotes for 3.5 RC 1?

safiel 08-09-2005 02:22 AM

Search is my friend.

Thanks for posting this, was looking for a hint and this saved me lots of time.

chanzero 08-11-2005 03:32 AM

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]

Ky Kiske 08-11-2005 04:57 AM

How do you do this if it's like forum.yoursite.com? And that directory has a password?

chanzero 08-30-2005 04:44 PM

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!


All times are GMT. The time now is 03:48 AM.

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.01413 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_html_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete