Page 20 of 20

Re: [2.0.17] Table BBCode

Posted: Tue Nov 06, 2007 8:56 am
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

Re: [2.0.17] Table BBCode

Posted: Tue Nov 06, 2007 9:39 am
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:

Re: [2.0.17] Table BBCode

Posted: Thu Feb 14, 2008 9:42 pm
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.

Re: [2.0.17] Table BBCode

Posted: Thu Mar 20, 2008 4:10 pm
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 :)

Re: [2.0.17] Table BBCode

Posted: Mon Nov 17, 2008 11:11 pm
by mikeel100
Removed by poster...

Re: [2.0.17] Table BBCode

Posted: Tue Nov 18, 2008 12:17 pm
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.