From: <var...@us...> - 2011-01-07 09:30:20
|
Revision: 7816 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7816&view=rev Author: vargenau Date: 2011-01-07 09:30:14 +0000 (Fri, 07 Jan 2011) Log Message: ----------- Better handle tables with uneven number of columns Modified Paths: -------------- trunk/lib/plugin/WikicreoleTable.php Modified: trunk/lib/plugin/WikicreoleTable.php =================================================================== --- trunk/lib/plugin/WikicreoleTable.php 2011-01-07 08:51:09 UTC (rev 7815) +++ trunk/lib/plugin/WikicreoleTable.php 2011-01-07 09:30:14 UTC (rev 7816) @@ -94,11 +94,18 @@ if ($nbrows == 0) { return HTML::raw(''); } - $nbcols = sizeof($table[0]); + // Number of columns is the number of cells in the longer row + $nbcols = 0; for ($i=0; $i<$nbrows; $i++) { + $nbcols = max($nbcols, sizeof($table[$i])); + } + + for ($i=0; $i<$nbrows; $i++) { for ($j=0; $j<$nbcols; $j++) { - if (preg_match('/@@/', $table[$i][$j])) { + if (!isset($table[$i][$j])) { + $table[$i][$j] = ''; + } else if (preg_match('/@@/', $table[$i][$j])) { $table[$i][$j] = compute_tablecell($table, $i, $j, $nbrows, $nbcols); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |