Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-26-2010, 08:02 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default using preg_replace to turn one BB Code into another BB Code...

What I need to do is when a message is quoted to replace one bb code inside the quote with another bb code...

So let's say the message data contains:
Code:
[quote=BirOPrey;938322]This is a test [cust]http://www.google.com[/cust] more test. One more time  [cust]http://www.yahoo.com[/cust][/quote]

Hi. [cust]http://www.bing.com[/cust]
Bye.
I would want it to change to:
Code:
[quote=BirOPrey;938322]This is a test [xxx]http://www.google.com[/xxx] more test. One more time  [xxx]http://www.yahoo.com[/xxx][/quote]

Hi. [cust]http://www.bing.com[/cust]
Bye.
The hooks and variables I'm sure I can figure out... and I've been pretty good making regular expressions with regex buddy these days...

I'm thinking preg_replace will be the key to doing this... to match [cust] and [/cust] and replace with [xxx] and [/xxx] only within a quote- but I have read the pho manual on preg_replace and wondering if there isn't more to it?

I found some info in this thread: https://vborg.vbsupport.ru/showthread.php?t=77173
But that code doesn't seem to work in 3.7/3.8...

EDIT

That line from that thread looks exactly like I want to do.., in class_bbcode.php after line 1424 I want to do a preg_replace on $html and change all the [cust] tags to [xxx] but this is never matching:
Code:
$html = preg_replace('#\[test\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/test\]#iue', "[url]$1[/url]", $html);
Trying to change [test] to [ url ] in that example...

Edit AGAIN
It appears the problem is in 3.8 $html and $message are already converted to HTML so there are no bb code's left in the code at this point anymore, they have already been parsed.

--------------- Added [DATE]1293416282[/DATE] at [TIME]1293416282[/TIME] ---------------

Well I ended up just using str_replace, twice... Once to remove all the HTML in front of the {param} and replace it, and another to remove and replace all the code after the {param}... I was looking and I just don't see anywhere were the unparsed QUOTE only is available...

--------------- Added [DATE]1293417599[/DATE] at [TIME]1293417599[/TIME] ---------------

Wow... I found a mod that does everything I need really easily... at least this was a learning experience...

https://vborg.vbsupport.ru/showthread.php?t=191223 :up:
Reply With Quote
  #2  
Old 12-28-2010, 08:00 AM
Jaffery Jaffery is offline
 
Join Date: Dec 2009
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Btw, there is cleaner.php found under /impex/tools which lets you convert things and replaces variable in posts. Hope you didn't missed that as I had once converted various bb code into other formats.
Reply With Quote
  #3  
Old 12-28-2010, 01:10 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the info. :up:
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 02:00 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03883 seconds
  • Memory Usage 2,182KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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_postinfo_query
  • fetch_postinfo
  • 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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete