4 SparseTable allows you to build up a table in a data oriented
7 <?plugin SparseTable columns="id, 2,p, a, b, c,d, e"
24 You could also assign a list of rows="..." instead of columns= names.
25 In both cases you separate the individual row/column entries with an
26 empty line, and use one of the specified identifiers and a "=" sign or
27 ":" colon to fill the table cells with data.
28 The row/column identifiers itself won't be printed and should therefore
29 be choosen like variables. The first block of assignments then was
30 typically used to make appropriate headings.
32 (This plugin resembles a feature as seen in ProWiki, or at least
33 tries to. You could get the ProWiki CDML syntax with an mpi framework
38 $ewiki_plugins["mpi"]["sparsetable"] = "ewiki_mpi_sparsetable";
39 function ewiki_mpi_sparsetable($action, $args, &$iii, &$s) {
47 $use_rows = isset($args["rows"]);
52 $i = $args["columns"];
54 $ind = preg_split("/\s*[:;,|]\s*/", strtolower(trim($i)));
56 return("Note: use rows= or columns= for SparseTable");
58 $ind = array_flip($ind);
59 $empty_line = array();
60 for ($n=0; $n<count($ind); $n++) {
65 $data = substr($args["_"], strpos($args["_"], "\n"));
66 $data = preg_split("/\n\s*\n/", $data);
69 #-- walk through rows/cols
70 foreach ($data as $block) {
74 $d = preg_split('/^\s*(\w+)\s*[:=]+/m', $block, -1, PREG_SPLIT_DELIM_CAPTURE);
77 for ($i=1; $i<count($d); $i++) {
78 $rname = strtolower(strtok(trim($d[$i]), " :=\t"));
79 $val = trim($d[++$i]);
80 $l[ $ind[$rname] ] = $val;
86 foreach ($t as $line) {
87 $o .= "$SEP " . implode(" $SEP ", $line) . " $SEP\n";
90 #-- put output back into $iii
91 $iii[$s["in"]] = array(