Subject: abbc table support
file: abbctable.lib.php
file: abbctable.php
Syntax:
[ table = width_in_sanitized_css_optional ]
heading 1=width_col_1_optional | heading 2=width_2_opt | heading 3=width_3_opt
cell 1 | cell 2 | cell 3
[ / table ]
All width definitions are in pixel (default) or %.
You can colspan cells by _prefixing_ ";n" to the width modifier: heading 1 text;2=80%
Feedback is appreciated, of course.
Edit: Example can be seen at http://forum.silbermarken.de/thread/185
- <?php
- /* licence: gplv2 */
- function myabbctablecode($code, $table_width = '*') {
- $table_width='*';
- $rowc = 0;
- $max_num_of_cols = 0;
- $keep = "";
- foreach ($lines as $l) {
- continue;
- /* if ($l[-1] == '\\')
- $keep += $l . "\n";
- else
- $keep = $l;*/
- $keep = $l;
- $flines[] = $keep;
- }
- foreach ($flines as $l) {
- $colc = 0;
- foreach ($cols as $c) {
- $width = "*";
- $span = 1;
- // Only allow width definitions on the first row
- $width = $matches[3];
- $width .= "px";
- }
- if ($matches[2] != "")
- $c = $matches[1];
- }
- $colc += $span;
- }
- $max_num_of_cols = $colc;
- $table[] = $row;
- $rowc++;
- }
- $rowc = 0;
- $r = '<table style="border: 1px dashed black; width: '.$table_width.'; overflow: hidden;">';
- foreach ($table as $row) {
- $rowc++;
- $r .= '<tr>';
- // Calculate the total row count of this row
- $total_col_this_row = 0;
- foreach ($row as $cell)
- $total_col_this_row += $cell[2];
- while ($total_col_this_row != $max_num_of_cols) {
- // We cant chop anymore!
- if ($chomp == 0 && $row[$chomp][2] == 1) {
- // Raise error to user
- return "<b>Fehler in Tabelle: Zeile ".$rowc." hat zuwenig/zuviele Spalten</b>: ".
- $max_num_of_cols." erwartet, ".$total_col_this_row." gefunden.";
- }
- // Chomp of spans from the back
- if ($row[$chomp][2] > 1)
- $row[$chomp][2] -= 1;
- else
- $chomp -= 1;
- // Recalculate
- $total_col_this_row = 0;
- foreach ($row as $cell)
- $total_col_this_row += $cell[2];
- }
- foreach ($row as $cell) {
- $width = $cell[0];
- $content = $cell[1];
- $span = $cell[2];
- $vcol_this_row += $span;
- $content = AbbcProc($content);
- // Hack: Remove leading <br />
- $r .= '<td colspan="'.$span.'" style="border: 1px dotted grey;text-align: center; width: '.$width.';">'.$content.'</td>';
- }
- $r .= '</tr>';
- }
- $r .= '</table>';
- return $r;
- }
file: abbctable.php
- <?php
- /* licence: gplv2 */
- // Define plug-in meta-data
- UnbPluginMeta('Add table support to ABBC code tags');
- UnbPluginMeta('Bernhard \'elven\' Stoeckner <elven@swordcoast.net>', 'author');
- if (!UnbPluginEnabled()) return;
- function UnbHookAddTableABBC(&$data) {
- 'htmlopen0' => "~''.",
- 'htmlcont0' => "myabbctablecode('$1').",
- 'htmlclose0' => "''",
- 'textcont0' => ' $1',
- 'htmlopen1' => "~''.",
- 'htmlcont1' => "myabbctablecode('$2', '$1').",
- 'htmlclose1' => "''",
- 'textcont1' => ' $2',
- 'htmlblock' => true,
- 'minparam' => 0,
- 'maxparam' => 1,
- 'openclose' => true,
- 'nocase' => true,
- 'nested' => true,
- 'proccont' => false,
- 'subset' => ABBC_CUSTOM
- );
- }
- UnbRegisterHook('abbc.userconfig', 'UnbHookAddTableABBC');
- ?>
Syntax:
[ table = width_in_sanitized_css_optional ]
heading 1=width_col_1_optional | heading 2=width_2_opt | heading 3=width_3_opt
cell 1 | cell 2 | cell 3
[ / table ]
All width definitions are in pixel (default) or %.
You can colspan cells by _prefixing_ ";n" to the width modifier: heading 1 text;2=80%
Feedback is appreciated, of course.
Edit: Example can be seen at http://forum.silbermarken.de/thread/185
I reject your reality and substitute my own.

elven
Show profile
Link to this post