summaryrefslogtreecommitdiff
path: root/plugins/format.tikiwiki.php
diff options
context:
space:
mode:
authorMax Kremmel <xing@synapse.plus.com>2006-12-25 11:59:23 +0000
committerMax Kremmel <xing@synapse.plus.com>2006-12-25 11:59:23 +0000
commit9ded9018feba9edabd845a01938b80308137e995 (patch)
treedad6b0363c40e23f8688dce263d4944115d8a0c1 /plugins/format.tikiwiki.php
parent3ca389fecf83c88e72f6686ee1d8aa0b0e6de1c6 (diff)
downloadliberty-9ded9018feba9edabd845a01938b80308137e995.tar.gz
liberty-9ded9018feba9edabd845a01938b80308137e995.tar.bz2
liberty-9ded9018feba9edabd845a01938b80308137e995.zip
adding a ~ at the beginning of a table, will generate a th instead or td in the first row: ||~th one|th who\ncell one|cell two||
Diffstat (limited to 'plugins/format.tikiwiki.php')
-rw-r--r--plugins/format.tikiwiki.php52
1 files changed, 33 insertions, 19 deletions
diff --git a/plugins/format.tikiwiki.php b/plugins/format.tikiwiki.php
index ca5cfb4..e3e9c27 100644
--- a/plugins/format.tikiwiki.php
+++ b/plugins/format.tikiwiki.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.79 $
+ * @version $Revision: 1.80 $
* @package liberty
*/
global $gLibertySystem;
@@ -1190,41 +1190,55 @@ class TikiWikiParser extends BitBase {
} else {
// New syntax for tables
// REWRITE THIS CODE
- if (preg_match_all("/\|\|(.*?)\|\|/s", $data, $tables)) {
+ if( preg_match_all( "/\|\|(.*?)\|\|/s", $data, $tables ) ) {
$maxcols = 1;
$cols = array();
- for ($i = 0; $i < count($tables[0]); $i++) {
- $rows = split("\n|\<br\/\>", $tables[0][$i]);
+ for( $i = 0; $i < count( $tables[0] ); $i++ ) {
+ $rows = split( "\n|\<br\/\>", $tables[0][$i] );
$col[$i] = array();
- for ($j = 0; $j < count($rows); $j++) {
- $rows[$j] = str_replace('||', '', $rows[$j]);
- $cols[$i][$j] = explode('|', $rows[$j]);
- if (count($cols[$i][$j]) > $maxcols)
- $maxcols = count($cols[$i][$j]);
+ for( $j = 0; $j < count( $rows ); $j++ ) {
+ $rows[$j] = str_replace( '||', '', $rows[$j] );
+ $cols[$i][$j] = explode( '|', $rows[$j] );
+ if( count( $cols[$i][$j] ) > $maxcols ) {
+ $maxcols = count( $cols[$i][$j] );
+ }
}
}
- for ($i = 0; $i < count($tables[0]); $i++) {
+ for( $i = 0; $i < count( $tables[0] ); $i++ ) {
$repl = '<table class="bittable">';
- for ($j = 0; $j < count($cols[$i]); $j++) {
- $ncols = count($cols[$i][$j]);
+ if( preg_match( "#^~#", $cols[$i][0][0] ) && $cols[$i][0][0] = preg_replace( "#^~#", "", $cols[$i][0][0] ) ) {
+ $th = TRUE;
+ } else {
+ $th = FALSE;
+ }
- if ($ncols == 1 && !$cols[$i][$j][0])
+ for( $j = 0; $j < count( $cols[$i] ); $j++ ) {
+ $ncols = count( $cols[$i][$j] );
+
+ if( $ncols == 1 && !$cols[$i][$j][0] ) {
continue;
+ }
- $repl .= '<tr class="'.( ( $j % 2 ) ? 'even' : 'odd' ).'">';
+ if( $j == 0 && $th ) {
+ $repl .= '<tr>';
+ } else {
+ $repl .= '<tr class="'.( ( $j % 2 ) ? 'odd' : 'even' ).'">';
+ }
- for ($k = 0; $k < $ncols; $k++) {
- $repl .= '<td ';
+ for( $k = 0; $k < $ncols; $k++ ) {
+ $thd = ( ( $j == 0 && $th ) ? 'th' : 'td' );
+ $repl .= "<$thd";
- if ($k == $ncols - 1 && $ncols < $maxcols)
- $repl .= ' colspan="' . ($maxcols - $k).'"';
+ if( $k == $ncols - 1 && $ncols < $maxcols ) {
+ $repl .= ' colspan="'.( $maxcols - $k ).'"';
+ }
- $repl .= '>' . $cols[$i][$j][$k] . '</td>';
+ $repl .= ">{$cols[$i][$j][$k]}</$thd>";
}
$repl .= '</tr>';