From: <var...@us...> - 2009-01-09 13:42:17
|
Revision: 6389 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6389&view=rev Author: vargenau Date: 2009-01-09 13:42:12 +0000 (Fri, 09 Jan 2009) Log Message: ----------- Add function compute_tablecell in stdlib Modified Paths: -------------- trunk/lib/plugin/WikicreoleTable.php trunk/lib/stdlib.php Modified: trunk/lib/plugin/WikicreoleTable.php =================================================================== --- trunk/lib/plugin/WikicreoleTable.php 2009-01-09 13:04:37 UTC (rev 6388) +++ trunk/lib/plugin/WikicreoleTable.php 2009-01-09 13:42:12 UTC (rev 6389) @@ -101,7 +101,7 @@ for ($i=0; $i<$nbrows; $i++) { for ($j=0; $j<$nbcols; $j++) { if ($table[$i][$j][0] == '@') { - $table[$i][$j] = $this->_compute($table, $i, $j, $nbrows, $nbcols); + $table[$i][$j] = compute_tablecell($table, $i, $j, $nbrows, $nbcols); } } } @@ -142,25 +142,6 @@ return $row; } - function _compute ($mytable, $i, $j, $imax, $jmax) { - - // What is implemented: - // @@SUM(R)@@ : sum of cells in current row - // @@SUM(C)@@ : sum of cells in current column - - $result=0; - if (trim($mytable[$i][$j]) == "@@SUM(C)@@") { - for ($index=0; $index<$imax; $index++) { - $result += $mytable[$index][$j]; - } - } - if (trim($mytable[$i][$j]) == "@@SUM(R)@@") { - for ($index=0; $index<$jmax; $index++) { - $result += $mytable[$i][$index]; - } - } - return $result; - } } // For emacs users Modified: trunk/lib/stdlib.php =================================================================== --- trunk/lib/stdlib.php 2009-01-09 13:04:37 UTC (rev 6388) +++ trunk/lib/stdlib.php 2009-01-09 13:42:12 UTC (rev 6389) @@ -2352,6 +2352,32 @@ return false; } +/** + * Compute cell in spreadsheet table + * $table: two-dimensional table + * $i and $j: indexes of cell to compute + * $imax and $jmax: table dimensions + */ +function compute_tablecell ($table, $i, $j, $imax, $jmax) { + + // What is implemented: + // @@SUM(R)@@ : sum of cells in current row + // @@SUM(C)@@ : sum of cells in current column + + $result=0; + if (trim($table[$i][$j]) == "@@SUM(C)@@") { + for ($index=0; $index<$imax; $index++) { + $result += $table[$index][$j]; + } + } + if (trim($table[$i][$j]) == "@@SUM(R)@@") { + for ($index=0; $index<$jmax; $index++) { + $result += $table[$i][$index]; + } + } + return $result; +} + // (c-file-style: "gnu") // Local Variables: // mode: php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |