Support Forum
Greetings,
I have innumerable posts with BBCode such as:
[img:2zipfoae]http://farm8.staticflickr.com/7402/10853492303_1b86dd39c1_z.jpg[/img:2zipfoae]
[url:250psi0z]http://www.orgonise-africa.net[/url:250psi0z]
[b:335c7gbv][u:335c7gbv]Our first gifting run in Malaysia May 2006 (Part 1 of 4)[/u:335c7gbv][/b:335c7gbv]
etc.... now that I've imported into SP. Now all instances of BBCode appear "unrendered". Is there any way that SP can parse these? some plugin? or am I going to have to write code to troll through wp_sfposts and convert each of these to html? I have to, at least, get the images working, and then the urls...
Thanks,
--Azti
ok, I just read this:
https://simple-press.com/suppo.....b3/page-2/
From the above I understand that the problem is in that these tags embed a random string as a pointer to specific, uploaded, media and, as they are unique, your parsers don't handle them. I also believe, from this thread, that whenever SP does parse BBCode such as simple (rather than in my case) <img src="url<img src=" markup code in sp-api-filters.php replaces this with html and stores it in the database.
It looks to me that the changes that were proposed by Yellow Swordfish and Joan Alamo Vallejo are implemented having looked at the code at line 930 of the current version of SP:
# apply any users custom filters for pre-content display processing
$content = apply_filters('sph_display_post_content_pre_filter', $content);
So, do I just need to write a filter in my functions.php and replace the offending BBCode Tags with the simple tags that will then be automatically replaced by SP code with html?
This would save me from a lot of perl regexp DBI hackery...
thanks,
--Azti
PS: Ah... yes, confirmed... If I edit a post with one of these offending tags, and replace them with simple <img src="url" alt="url[img] markup code in sp-api-filters.php replaces this with html and stores it in the database.
PPS: Nope... that didn't work it just displayed [img]url" alt="url" alt="url[img] markup code in sp-api-filters.php replaces this with html and stores it in the database.
sorry, you have confused me with your edits...
first, even with bbcode (which can be supported), we will store it in the db as html... but it will display properly...
careful if you edit the post as tinymce is wysiwg... it may not 'write' true html unless you do it in the html popup window...
but yes, you can use that filter to replace phpbb specific bbcode tags with the general ones that sp knows...
so, if I have missed something, please elaborate because not sure what you edits were trying to tell me...
Visit Cruise Talk Central and Mr Papa's World
Mr Papa,
What I did was to write a quick perl script that edited a database dump to a sql file, then replaced every instance of [img:<randomstr>] with [img] as well as doing the same for the closing tags. This did not work. The Forum showed the bbcode rather than rendering the image. I believe what I would have to do, in a php solution, is to use the same code (or similar) that transforms bbcode to html, and writes it to the database upon an editor submission using bbcode, but do so before the page is displayed, through a functions.php filter.
However, I would rather just clean up the database all at once and so what I am going to do is to perform a global search and replace for these offending tags. I am writing a quick perl script that will take a database dump to a sql file, do the edits, and then I just drop the db, create it, execute the sql file, and start from there.
I will make it available once I'm done with it.
Thanks again and sorry for the confusion with the edits...
--Azti
you should be able edit it fine... works for me - just tried... but you cant edit the db since its not stored as bbcode in the db - its html... when read from the db, it will be interpreted as a wp shortcode...
Visit Cruise Talk Central and Mr Papa's World
I wrote a perl script that fixed all my images, and I'm adding more regexps to fix other things. It uses DBI to access the database, edits each record in wp_sfposts, searches for tags, replaces them with html, and writes back to the db. I will go ahead and clean this up, add command line arguments handling of dsn variables, and table names, and post it for others to use...
#!/usr/bin/perl
use strict;
use warnings;
use DBI;my $user = '<replace with your user>';
my $pass = '<replace with your password>';
my $db = '<replace with your database name>';
my $dsn = "dbi:mysql:database=$db";my $dbh = DBI->connect($dsn, $user, $pass)
or die "Unable to connect to database: $DBI::errstr";my $sth = $dbh->prepare("SELECT post_id, post_content FROM $db.wp_sfposts;");
my $sth_update = $dbh->prepare("UPDATE $db.wp_sfposts SET post_content = ? WHERE post_id = ?");
$sth->execute();# Regex looks for http or https and looks for [img] or [img:<random string>]. The next regexp looks for the
# related closing tag
while(my @row = $sth->fetchrow_array()){my $id = $row[0];
my $record = $row[1];
$record =~ s/\[img(?:\]|:[\w]+\])/<img src="/g;
$record =~ s/\/?\[\/img(?:\]|:[\w]+\])/"\/>/g;
print "Processing post_id: $id\n";
$sth_update->bind_param(1, $record);
$sth_update->bind_param(2, $id);
$sth_update->execute() or die $dbh->errstr;
}--Azti
ah sorry, thought you were converting to bbcode not html... the latter,of course, will work since that's how its stored... cool!
Visit Cruise Talk Central and Mr Papa's World
1 Guest(s)