4f889b06cdbabf4e89ce7fcda7dfadf773e92f7c
[atutor.git] / mods / wiki / plugins / markup / complextbl.php
1 <?php
2 /*
3
4   code by Hans B Pufal <hansp@aconit.org>
5
6   allows html arguments inside the
7   |{border=1} wiki | table |
8   |         markup |       |
9
10 */
11  
12
13
14  $ewiki_plugins["format_table"][] = "ewiki_format_complex_tables";
15
16
17  function ewiki_format_complex_tables(&$o, &$line, &$post, $table=0) {
18
19          if (!$table)
20          {
21             if ((@$line[0] == '{') && ($e = strpos ($line, '}', 2)))
22             {
23                $o .= "<table " . trim (substr ($line, 1, $e - 2)) . ">\n";
24                $line = "|" . substr ($line, $e + 1);
25             }
26             else
27                $o .= "<table>\n";
28             $table = 1;
29          }
30
31          $line = trim ($line, "|");
32          $telements = explode ("|", $line);
33
34          $line = "";
35          foreach ($telements as $td)
36          {
37             if (empty($line))
38             {
39                if ((strlen($td) > 1) && (@$td[0] == '{') && ($e = strpos ($td, '}', 1)))
40                {
41                   $line = "<tr " . trim (substr ($td, 1, $e - 1)) . ">";
42                   $td = substr ($td, $e + 1);
43                }
44                else
45                   $line = "<tr>";
46             }
47
48             if ((strlen($td) > 1) && (@$td[0] == '{') && ($e = strpos ($td, '}', 1)))
49                $line .= "<td " . trim (substr ($td, 1, $e - 1)) . ">" . trim(substr ($td, $e + 1)) . "</td>";
50             else
51                $line .= "<td>" . trim ($td) . "</td>";
52          }
53          $line .= "</tr>";
54
55  }
56
57
58 ?>