[2.0.17] Table BBCode

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
23
50%
Very Good
8
17%
Good
11
24%
Fair
2
4%
Poor
2
4%
 
Total votes: 46

RobRoe
Registered User
Posts: 4
Joined: Mon Apr 29, 2002 2:18 am
Location: Dresden, Germany
Contact:

Re: [2.0.17] Table BBCode

Post by RobRoe »

Hi,

is there anyone who has managed a kind of conversion of this MOD to phpBB3?

I've got a very large phpBB2 forum with many, many tables using this MOD. And I don't want to convert my forum into phpBB3 until I've found a way to keep those tables (or change them in an automatic way).

May one perhaps use that new feature with the "custom" BBCodes? Or any other way?

Best regards.
RobRoe
User avatar
noth
Registered User
Posts: 2528
Joined: Fri Jan 07, 2005 7:10 pm
Location: North Surrey
Contact:

Re: [2.0.17] Table BBCode

Post by noth »

exactly

I am in the same situation as RobRoe

all he said applies to me too

I have spread the TableBBcode MOD across four popular phpBB2 forums that I operate

I am impressed with phpBB3 and have certainly warmed to the idea over the last few weeks

when it goes gold I would like to use phpBB3 but not without Table BBCode

can anybody assist please? :lol:
TerraFrost
Former Team Member
Posts: 5957
Joined: Sun Dec 26, 2004 3:40 am
Location: Austin, TX

Re: [2.0.17] Table BBCode

Post by TerraFrost »

To convert the tables over to phpBB3, you'll first need to do this (in phpBB3):

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
install/convertors/functions_phpbb20.php
#
#-----[ FIND ]------------------------------------------
#
	if (isset($convert->row['old_bbcode_uid']) && $convert->row['old_bbcode_uid'] != '')
	{
		// Adjust size...
		if (strpos($message, '[size=') !== false)
		{
			$message = preg_replace_callback('/\[size=(\d*):(' . $convert->row['old_bbcode_uid'] . ')\]/', 'phpbb_replace_size', $message);
		}
#
#-----[ AFTER, ADD ]------------------------------------
#

		$message = preg_replace(
			'#(\[(?:mrow|mcol|row|col(?!or)|/table)[^\]]*\])#e',
			"table_callback(str_replace('\\\"','\"','$1'))",
			$message
		);
#
#-----[ FIND ]------------------------------------------
#

/**
* Return the bitfield calculated by the previous function
*/
function get_bbcode_bitfield()
{
#
#-----[ BEFORE, ADD ]-----------------------------------
#

/**
* Convert the Table BBCode MOD to a more phpBB3 friendly format
* (c) MMVIII by TerraFrost (http://www.frostjedi.com/terra/)
*/
function table_callback($long_tag)
{
	static $stack = array();
	static $subtag = array('mrow' => 'mcol', 'row' => 'col');

	preg_match('#^\[(/?\w+)#', $long_tag, $matches);
	$short_tag = $matches[1];

	switch ($short_tag)
	{
		case 'mrow':
		case 'row':
			$temp = '';
			while (count($stack))
			{
				$top = array_pop($stack);
				$temp.= '[/' . $top . ']';
			}
			$stack[] = $short_tag;

			$stack[] = $subtag[$short_tag];
			return $temp . $long_tag . '[' . $subtag[$short_tag] . ']';
		case 'mcol':
		case 'col':
			$top = array_pop($stack);

			$stack[] = $short_tag;
			return '[/' . $short_tag . ']' . $long_tag;
		case '/table':
			$temp = '';
			while (count($stack))
			{
				$top = array_pop($stack);
				$temp.= '[/' . $top . ']';
			}
			return $temp . '[/table]';
	}
}
After that, convert the phpBB2 as you usually would. Then add the following BBCodes in the ACP:
Once that's done, you'll need to go back to each post with a table, hit the edit button, and then submit. Or you can edit posts on an as-needed basis (that's what I'd do). You also don't actually need to make any edits - you just need to go through the process of resubmitting the post.

A few problems with this method...

The orig. version supported optional attributes. color and fontsize. This conversion does not support them. This is due to the way phpBB3's BBCode system works. If you want to add support for them, phpBB3 will have to be modified and it isn't a modification I really would want to write...

Also, this MOD changes the way tables have to be created. In phpBB2, with this MOD, you could do the following to create a table:

Code: Select all

[table][row]a[col]b[col]c[/table]
Here's how you'd do it in phpBB3 (and what the modifications I made to the convertor will make phpBB3 do)

Code: Select all

[table][row][col]a[/col][col]b[/col][col]c[/col][/row][/table]
Note that any new lines between successive [row] or [col] tags will get converted into <br />, leaving you with things like </tr> <br /> <tr>. The browser, seeing that these aren't in a row, will put them at the top. Unfortunately, I'm not really sure what can be done about this.

Anyway, do not expect to receive any support from me with regard to this script.
Letus2001
Registered User
Posts: 22
Joined: Thu Nov 04, 2004 8:22 pm

Re: [2.0.17] Table BBCode

Post by Letus2001 »

i agree that biggest issue here are the closing tags that werent needed in 2.0 mod, else it can be done via the code mentioned above. To address the color tag issue, i recommend to create instead of tag

[row color=xxxxxx]

new one

[rowcolor=xxxxxx]

which you can easily replace same way you did the other ones, but you need to run a code on your existing posts to update them to this one (rememer, you will need closing tag [/rowcolor] to this as well.

To address the new lines issue, i did a small modification to functions_content.php code

Code: Select all

function bbcode_nl2br($text)
{
	// custom BBCodes might contain carriage returns so they
	// are not converted into <br /> so now revert that
	$text = str_replace(array("tr>\n", "tr>\r", "\n", "\r",), array('tr>', 'tr>', '<br />', "\n"), $text);
	return $text;
}
from that you should get the idea - if there is enter / new line break at the end of the row of the table, which you usually do to have your table kind of readable when edit of that topic is needed, the parser will replace it to </tr>\n or </tr>\r, and at the end of the topic showing process, it turns it to </tr><br /> (both replacements). So, i added a special condition, if there is tr>\n or tr>\r, dont do <br />, but just remove the new line and return tr>. This gets rid of all the new lines in your post because of table. Same idea works for replacement of new lines after each cell, i leave it up to you to work it out :)
mikeel100
Registered User
Posts: 3
Joined: Thu Oct 30, 2008 1:20 am

Re: [2.0.17] Table BBCode

Post by mikeel100 »

Removed by poster...
Last edited by mikeel100 on Fri Dec 19, 2008 4:15 pm, edited 1 time in total.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53400
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: [2.0.17] Table BBCode

Post by Brf »

mikeel100 wrote: if I posted in the wrong place, my apologies.
This is the support topic for a phpBB2 mod, not a topic for phpbb3 custom bbcodes.

In any case, your bbcode is kind of silly, being usable in one one little situation. There are already bbcodes written up that allow you to make more flexable tables.
Post Reply

Return to “[2.0.x] MOD Database Releases”