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-2009 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 if (is_numeric(trim($content))) {
79 $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($content)));
81 $cell->pushContent(TransformText($content, $markup, $basepage));
85 $row->pushContent($cell);
88 $table->pushContent($row);
91 $attrs = parse_attributes(substr($line,1));
92 foreach ($attrs as $key => $value) {
93 if (in_array ($key, array("id", "class", "title", "style",
94 "bgcolor", "align", "valign"))) {
95 $row->setAttr($key, $value);
100 if (substr($line,0,1) == "|" and isset($row)) {
102 if (isset ($content)) {
103 if (is_numeric(trim($content))) {
104 $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($content)));
106 $cell->pushContent(TransformText($content, $markup, $basepage));
110 $row->pushContent($cell);
113 $line = substr($line, 1);
114 if ($line[0] == "*" ) {
115 $attrs = parse_attributes(substr($line,1));
116 foreach ($attrs as $key => $value) {
117 if (in_array ($key, array("id", "class", "title", "style",
118 "colspan", "rowspan", "width", "height",
119 "bgcolor", "align", "valign"))) {
120 $cell->setAttr($key, $value);
126 if (isset($row) and isset($cell)) {
127 $line = str_replace("?\>", "?>", $line);
128 $line = str_replace("\~", "~", $line);
129 if (empty($content)) $content = '';
130 $content .= $line . "\n";
135 if (isset($content)) {
136 if (is_numeric(trim($content))) {
137 $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($content)));
139 $cell->pushContent(TransformText($content, $markup, $basepage));
142 $row->pushContent($cell);
144 $table->pushContent($row);
155 // c-hanging-comment-ender-p: nil
156 // indent-tabs-mode: nil