, Copyright 2007.
## LICENSE: You can redistribute this software and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
MarkUp('table', 'table', '/\n?([ ]{0,2})\[([trc]{1})(.*?)\]/e', 'ZAPtables("$2", "$3", strlen("$1"))');
function ZAPtables($type, $attr, $level=0) {
global $tablememory;
if ($attr != '') $attr = ZAPtableattrs($attr, $type);
switch($type) {
case "t" :
if ($tablememory["$level-t"] != 'on') {
$tablememory["$level-t"] = 'on';
return "
";
}
case "c" :
if ($tablememory["$level-c"] != 'on') {
$tablememory["$level-c"] == 'on';
return "";
}
else return " | ";
default:
return '';
}
}
function ZAPtableattrs($attr, $type) {
global $debug;
$out = '';
$r1 = array(' center', ' left', ' right', ' top', ' middle', ' bottom', ' color', ' padding', ' spacing', ' rows', ' cols', ' image');
$r2 = array(' align=center', ' align=left', ' align=right', ' valign=top', ' valign=middle', ' valign=bottom', ' bgcolor', ' cellpadding', 'cellspacing', ' rowspan', ' colspan', ' background');
$attr = str_replace($r1, $r2, $attr);
$attrs['t'] = Array('align', 'background', 'bgcolor', 'border', 'cellpadding', 'cellspacing', 'width');
$attrs['r'] = Array('align', 'background', 'bgcolor', 'valign', 'border');
$attrs['c'] = Array('align', 'background', 'bgcolor', 'valign', 'border', 'colspan', 'rowspan', 'nowrap', 'valign', 'width');
$args = ParseArgs($attr);
foreach($args as $f => $v) {
if (is_array($v)) continue;
if (! in_array($f, $attrs[$type])) continue;
if (ereg('/[\'#0-9a-zA-Z]+/', $v)) continue;
$out .= " $f='$v' ";
}
return $out;
} |