mirror of
https://github.com/e107inc/e107.git
synced 2025-08-17 20:01:47 +02:00
table bbcodes
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
//<?
|
||||
|
||||
|
||||
$class = e107::getBB()->getClass('table');
|
||||
return "<table class='{$class}'>".$code_text."</table>";
|
||||
if($parm)
|
||||
{
|
||||
return "<table class='{$class}' {$parm}>".trim($code_text)."</table>";
|
||||
}
|
||||
|
||||
return "<table class='{$class}'>".trim($code_text)."</table>";
|
||||
|
@@ -1,4 +1,4 @@
|
||||
//<?php
|
||||
|
||||
$class = e107::getBB()->getClass('tbody');
|
||||
return "<tbody class='{$class}'>".$code_text."</tbody>\n";
|
||||
return "<tbody class='{$class}'>".trim($code_text)."</tbody>";
|
||||
|
@@ -44,7 +44,7 @@ class e_bbcode
|
||||
'b', 'justify', 'file', 'stream',
|
||||
'textarea', 'list', 'php', 'time',
|
||||
'spoiler', 'hide', 'youtube', 'sanitised',
|
||||
'p', 'h', 'nobr', 'block',
|
||||
'p', 'h', 'nobr', 'block','table','tr','tbody','td'
|
||||
);
|
||||
|
||||
foreach($this->core_bb as $c)
|
||||
@@ -507,7 +507,7 @@ class e_bbcode
|
||||
/**
|
||||
* Convert HTML to bbcode.
|
||||
*/
|
||||
function htmltoBbcode($text)
|
||||
function htmltoBBcode($text)
|
||||
{
|
||||
//return $text;
|
||||
$convert = array(
|
||||
@@ -526,6 +526,21 @@ class e_bbcode
|
||||
array( "[i]", '<em class="bbcode italic bbcode-i">'), // e107 bbcode markup
|
||||
array( "[i]", '<em>'),
|
||||
array( "[/i]", '</em>'),
|
||||
array( "[block]", '<div>'),
|
||||
array( "[/block]", '</div>'),
|
||||
array( "[table]\n", '<table>'),
|
||||
array( "[/table]", '</table>'),
|
||||
array( "[table]\n", '<table class="bbcode-table">'),
|
||||
array( "[tbody]\n", '<tbody class="bbcode-tbody">'),
|
||||
array( "[tr]", '<tr class="bbcode-tr">'),
|
||||
array( "\n\t[td]", '<td class="bbcode-td">'),
|
||||
|
||||
array( "[tbody]\n", '<tbody>'),
|
||||
array( "[/tbody]\n", '</tbody>'),
|
||||
array( "[tr]", '<tr>'),
|
||||
array( "\n[/tr]\n", '</tr>'),
|
||||
array( "\n\t[td]", '<td>'),
|
||||
array( "[/td]", '</td>'),
|
||||
);
|
||||
|
||||
foreach($convert as $arr)
|
||||
@@ -541,6 +556,9 @@ class e_bbcode
|
||||
$text = preg_replace('/<img class="bbcode bbcode-img"(?:\s*)?(?:style="([^"]*)")?\s?(?:src="([^"]*)")(?:\s*)?(?:alt="(\S*)")?(?:\s*)?(?:width="([\d]*)")?\s*(?:height="([\d]*)")?(?:\s*)?\/>/i',"[img style=width:$4px;height:$5px;$1]$2[/img]",$text );
|
||||
$text = preg_replace('/<span (?:class="bbcode-color" )?style=\"color: ?(.*?);\">(.*?)<\/span>/i',"[color=$1]$2[/color]",$text);
|
||||
$text = preg_replace('/<span (?:class="bbcode underline bbcode-u" )?style="text-decoration: underline;">(.*?)<\/span>/i',"[u]$1[/u]",$text);
|
||||
// $text = preg_replace('/<table([^"]*)>/i', "[table $1]",$text);
|
||||
$text = preg_replace('/<table style="([^"]*)"([\w ="]*)?>/i', "[table style=$1]\n",$text);
|
||||
$text = preg_replace('/<tbody([\w ="]*)?>/i', "[tbody]\n",$text);
|
||||
|
||||
|
||||
$blank = array('</li>','width:px;height:px;');
|
||||
|
@@ -1333,7 +1333,7 @@ class e_parse
|
||||
{
|
||||
// Split each text block into bits which are either within one of the 'key' bbcodes, or outside them
|
||||
// (Because we have to match end words, the 'extra' capturing subpattern gets added to output array. We strip it later)
|
||||
$content = preg_split('#(\[(html|php|code|scode|hide).*?\[/(?:\\2)\])#mis', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
|
||||
$content = preg_split('#(\[(table|html|php|code|scode|hide).*?\[/(?:\\2)\])#mis', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
|
||||
}
|
||||
|
||||
|
||||
@@ -1357,7 +1357,7 @@ class e_parse
|
||||
|
||||
// Have to have a good test in case a 'non-key' bbcode starts the block
|
||||
// - so pull out the bbcode parameters while we're there
|
||||
if (($parseBB !== FALSE) && preg_match('#(^\[(html|php|code|scode|hide)(.*?)\])(.*?)(\[/\\2\]$)#is', $full_text, $matches ))
|
||||
if (($parseBB !== FALSE) && preg_match('#(^\[(table|html|php|code|scode|hide)(.*?)\])(.*?)(\[/\\2\]$)#is', $full_text, $matches ))
|
||||
{
|
||||
// It's one of the 'key' bbcodes
|
||||
// Usually don't want 'normal' processing if its a 'special' bbcode
|
||||
@@ -1403,6 +1403,11 @@ class e_parse
|
||||
$convertNL = FALSE;
|
||||
break;
|
||||
|
||||
case 'table' : // strip <br /> from end of <table>
|
||||
|
||||
$convertNL = FALSE;
|
||||
// break;
|
||||
|
||||
case 'hide' :
|
||||
$proc_funcs = TRUE;
|
||||
|
||||
@@ -1665,7 +1670,6 @@ class e_parse
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($convertNL)
|
||||
{
|
||||
// Default replaces all \n with <br /> for HTML display
|
||||
|
@@ -20,7 +20,7 @@ if($_POST['mode'] == 'tohtml')
|
||||
if($_POST['mode'] == 'tobbcode')
|
||||
{
|
||||
//echo $_POST['content'];
|
||||
echo e107::getBB()->htmltoBbcode($_POST['content']);
|
||||
echo e107::getBB()->htmltoBBcode($_POST['content']);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user