<?php if (!defined('PmWiki')) exit(); # Author: Martin Fick # Version: 1.1 # Date: 6/6/2006 # This defines a (:columns # Page:) directive # which acts like an include directive but formats # the included text so that each line will be in a # separate column. The # argument defines the # of # columns per row. function ColumnsFmt($ncols, $cells) { $out[] = '<TABLE>'; foreach($cells as $cell) { if ($c == 0) $out[]='<TR>'; $c++; $out[]="<TD> $cell </TD>"; if ($c == $ncols) { $c=0; $out[] = '</TR>'; } } if ($c>0 && $c < $ncols) { while($c < $ncols) { $c++; $out[] = '<TD></TD>'; } $out[] = '</TR>'; } $out[] = '</TABLE>'; return implode($out); } function ColumnsInclude($pagename, $ncols, $inclname) { $page = IncludeText($pagename, $inclname); $cells = explode("\n", $page); return ColumnsFmt($ncols, $cells); } Markup('columns','>if',"/\\(:columns\\s+(\\S*?)\\s+(\\S*?):\\)/ei", "PRR(ColumnsInclude(\$pagename, '$1', '$2'))"); ?>