Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Old BBCodes after importing from phpbb3
Avatar
Joan Alamo Vallejo
Member
Free Members
sp_UserOfflineSmall Offline
Apr 28, 2012 - 6:39 am

My old BBCodes now look like this after importing

[img:1ni7nvys]url[/img:1ni7nvys]

[video:7h4pmtqq]url[/video:7h4pmtqq]

Does anyone have a sql script around to get rid of these nasty codes? Or should I put a replace in php before showing the post content?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 28, 2012 - 12:49 pm

interesting as the bbcode standard does not support either of those...  the img tags should not have the :1ni7nvys in it so certainly throwing off the regex stuff...  same for a video tag...

so you are saying after the import they show in the content of an SP post - which is what I would expect - just checking...

are you good with regexp? probably take one either in php or mysql to remove...

if you want to strip out with php, you probably can use one of our hooks, the sph_save_post_content_filter filter and remove...

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 29, 2012 - 5:17 am

The issue - as I understand it - is that these are embedded keys to an attachment. This makes every one a unique pointer. As far as I am aware - and I am not that familiar with phpBB - we have had many users import without these tags. So I am thinking it might be a circumstance of version or perhaps some sot of setup option.

But they are non-standard accepted bbCode tags which make them very difficult to predict and parse for.

If anyone reading this has any specific information on these phpBB specific bbCode structures then we would be interested to hear more about them.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Joan Alamo Vallejo
Member
Free Members
sp_UserOfflineSmall Offline
Apr 29, 2012 - 2:40 pm

I tried to use the sph_display_post_content_filter hook since I didn't want to save each post again, but it just showed the url but not the image, video, etc. Did I miss something or should I give sql a try?

By the way, this is the code I used in case anyone is interested (see attachment)

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 29, 2012 - 2:46 pm

As we state on the importer form help panel we can only import the p[osyt content - this does not include attachments I am afraid

andy-signature.png
YELLOW
SWORDFISH
Avatar
Joan Alamo Vallejo
Member
Free Members
sp_UserOfflineSmall Offline
Apr 29, 2012 - 3:03 pm

Sorry, maybe I didn't make myself clear

I mean, I had this imported bbcode tag: [img:1ni7nvys]url[/img:1ni7nvys]

I replaced it using the sph_display_post_content_filter and I got:  [img ]url[ /img]

But the image wasn't showing on the post, just the url. Nothing to do with attachments..

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 29, 2012 - 6:40 pm

and the image location is valid?  ie, can you load it up in the browser?

ah, you did it in the display filter...  that is really too late as it really needs to be stored in the database as html, ie converted...  so when a post is made, we convert bbcode to html and save it...  doing it on display means its in the db as bbcode and thus wont get displayed in an html (ie wysiwyg tinymce) browser...

Avatar
Joan Alamo Vallejo
Member
Free Members
sp_UserOfflineSmall Offline
Apr 30, 2012 - 1:37 pm

Ok, I get it.. So, using the sph_display_post_content_filter hook, I could remove the tags before and then call the oEmbed method passing the url

Something like this: 

add_filter('sph_display_post_content_filter','replace_bbcode');

function replace_bbcode($text) {
   return oembed(preg_replace(...));
}

I think this would work but I have no idea on how to call the oembed method from fuctions.php, does anyone know?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 30, 2012 - 2:13 pm

No that wont work.
I think in your case - and to do this - then we need a new filter positioned before any of ours are actioned.
I have no objection to adding a new one and if we agree on one now then I can make sure iot will be added to the core in 5.1
Are you happy to make a small edit to core SP code?

andy-signature.png
YELLOW
SWORDFISH
Avatar
Joan Alamo Vallejo
Member
Free Members
sp_UserOfflineSmall Offline
May 1, 2012 - 11:16 am

Sure, it could be useful for everybody!

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 616
Members: 17348
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10118
Posts: 79603