From: Reini U. <ru...@x-...> - 2003-12-04 14:08:21
|
That's IMHO the easiest way to do this. This patch supports some table arguments: cellspacing, cellpadding, border and caption. One could also use handle_plugin_args_cruft() to do the dirty work in the $lines loop. Please test this, I'm still a little bit rusty and don't dare yet to commit this. $ cvs diff lib/plugin/OldStyleTable.php Index: lib/plugin/OldStyleTable.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/OldStyleTable.php,v retrieving revision 1.7 diff -u -b -r1.7 OldStyleTable.php --- lib/plugin/OldStyleTable.php 21 Feb 2003 23:00:35 -0000 1.7 +++ lib/plugin/OldStyleTable.php 4 Dec 2003 14:05:10 -0000 @@ -59,21 +59,43 @@ } function getDefaultArguments() { - return array(); + return array( + 'caption' => '', + 'cellpadding' => '1', + 'cellspacing' => '1', + 'border' => '1', + ); + } + + function handle_plugin_args_cruft($argstr, $args) { + return; } function run($dbi, $argstr, $request, $basepage) { global $Theme; include_once('lib/InlineParser.php'); + $args = $this->getArgs($argstr, $request); + $default = $this->getDefaultArguments(); + foreach (array('cellpadding','cellspacing','border') as $arg) { + if (!is_numeric($args[$arg])) { + $args[$arg] = $default[$arg]; + } + } $lines = preg_split('/\s*?\n\s*/', $argstr); - $table = HTML::table(array('cellpadding' => 1, - 'cellspacing' => 1, - 'border' => 1)); - + $table = HTML::table(array('cellpadding' => $args['cellpadding'], + 'cellspacing' => $args['cellspacing'], + 'caption' => $args['caption'], + 'border' => $args['border'])); + $default_args = array_keys($default); foreach ($lines as $line) { if (!$line) continue; + if (strstr($line,"=")) { + $tmp = explode("=",$line); + if (in_array(trim($tmp[0]),$default_args)) + continue; + } if ($line[0] != '|') return $this->error(fmt("Line does not begin with a '|'.")); $table->pushContent($this->_parse_row($line, $basepage)); Carsten Klapp schrieb: > On Wednesday, December 3, 2003, at 10:18 am, Micki Kaufman wrote: > >> Hi phpwiki folks. >> >> After basing our documentation project (covering 1000s of pages) on >> the wiki, we're seeing amazing results. I'm available to discuss, >> etc., should anyone want to know more about how we use this awesome >> wiki. >> >> One thing I've been looking for is a way to associate a 'title' or >> 'caption' with a table (either OldStyle or NewStyle), so that the >> title obeys the proper 'keep-with', etc., when the title is printed >> in our pdf workflow. >> >> I'd like a modification that allows: >> - one extra parameter within the table plugin called 'caption', like >> >> <?plugin OldStyleTable caption="Caption Text" >> >> - which renders its contents as >> ...<table> >> '<caption>Caption Text</caption>' >> <tr>... >> at the beginning of the table, before the first <tr> tag. >> >> This is valid html, and it will allow seriously cool functionality in >> our printed workflow - titles will remain with tables, automatically >> generate 'list of tables' at the top of each doc, etc. Real >> MSWord-kiiling stuff. >> >> Anyone have any ideas, or willing to help? This will be the first >> hardcore mod of our system that we'd have to carry forward, and >> logically I'd much prefer for this useful if obscure mod to be in the >> core code if folks find value to it. >> >> If no one would like to work on it, I'll begin the process of >> figuring it out and will offer it back to the code base once we're done. >> >> Thanks to all for making phpwiki continue to rock. >> >> Micki > > > > Hi Micki, > > User-definable table captions sound like an awesome feature, I'm all > for it! > > I'm not sure that this is something I can write, so if you or anyone > else figures out how to do it (add table captions and/or table summary > attribute) send me a patch and I'll gladly check it into the PhpWiki > CVS for everyone to have. > > Table captions are already defined in lib/HtmlElement.php, so I hope it > isn't too hard to add something to InlineParser or whatever else needs > to be modified. > > Carsten > > Ref.: > http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#h- 11.2.2 -- Reini Urban http://xarch.tu-graz.ac.at/home/rurban/ |