5 A PhpWiki plugin that allows insertion of tables using a richer syntax.
8 * Copyright (C) 2003 Sameer D. Sahasrabuddhe
9 * Copyright (C) 2005 $ThePhpWikiProgrammingTeam
10 * Copyright (C) 2008 Marc-Etienne Vargenau, Alcatel-Lucent
12 * This file is part of PhpWiki.
14 * PhpWiki is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * PhpWiki is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with PhpWiki; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 // error_reporting (E_ALL & ~E_NOTICE);
31 class WikiPlugin_RichTable
35 return _("RichTable");
38 function getDescription() {
39 return _("Layout tables using a very rich markup style.");
42 function getDefaultArguments() {
46 function getVersion() {
47 return preg_replace("/[Revision: $]/", '',
51 function run($dbi, $argstr, &$request, $basepage) {
53 include_once("lib/BlockParser.php");
54 // RichTablePlugin markup is new.
57 $lines = preg_split('/\n/', $argstr);
58 $table = HTML::table();
60 if ($lines[0][0] == '*') {
61 $line = substr(array_shift($lines),1);
62 $attrs = parse_attributes($line);
63 foreach ($attrs as $key => $value) {
64 if (in_array ($key, array("id", "class", "title", "style",
65 "bgcolor", "frame", "rules", "border",
66 "cellspacing", "cellpadding",
67 "summary", "align", "width"))) {
68 $table->setAttr($key, $value);
73 foreach ($lines as $line){
74 if (substr($line,0,1) == "-") {
77 if (isset($content)) {
78 $cell->pushContent(TransformText($content, $markup, $basepage));
81 $row->pushContent($cell);
84 $table->pushContent($row);
87 $attrs = parse_attributes(substr($line,1));
88 foreach ($attrs as $key => $value) {
89 if (in_array ($key, array("id", "class", "title", "style",
90 "bgcolor", "align", "valign"))) {
91 $row->setAttr($key, $value);
96 if (substr($line,0,1) == "|" and isset($row)) {
98 if (isset ($content)) {
99 $cell->pushContent(TransformText($content, $markup, $basepage));
102 $row->pushContent($cell);
105 $line = substr($line, 1);
106 if ($line[0] == "*" ) {
107 $attrs = parse_attributes(substr($line,1));
108 foreach ($attrs as $key => $value) {
109 if (in_array ($key, array("id", "class", "title", "style",
110 "colspan", "rowspan", "width", "height",
111 "bgcolor", "align", "valign"))) {
112 $cell->setAttr($key, $value);
118 if (isset($row) and isset($cell)) {
119 $line = str_replace("?\>", "?>", $line);
120 $line = str_replace("\~", "~", $line);
121 if (empty($content)) $content = '';
122 $content .= $line . "\n";
128 $cell->pushContent(TransformText($content, $markup, $basepage));
129 $row->pushContent($cell);
131 $table->pushContent($row);
142 // c-hanging-comment-ender-p: nil
143 // indent-tabs-mode: nil