<?php if (!defined('PmWiki')) exit(); /* Copyright 2005 Ben Wilson (ameen@dausha.net) This recipe extends PmWiki; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, provided this copyright statement remains with this recipe. See pmwiki.php for full details. This recipe provides very simple markup to allow a page to contain a section sub-divided into two columns of equal width, and optionally allows full-width text above and below the two-column section. Note the restriction here is that there can only be one section per page that is broken into columns. The recipe provides exact control so the (:colstart:) -- This markup tag allows the editor to indicate where the column block of text begins. All text before this tag will appear above the two-column block. (:colend:) -- This markup tag alllows the editor to indicate where the columns should end. Any text after this tag will appear after the two-column block. (:column:) -- this markup tag tells the recipe where to split the two columns. As this recipe does not attempt to calculate where an equidistant split should be, it is up to the editor to decide where. Everything before this tag (not including any text before the (:colstart:) tag) will be put into the first column. Everything after this tag (not including any text after the (:colend:) tag) will be put into the second column. */ # Version 1.0 Markup('columns', '_begin', '/(.*?)\(:column:\)(.*)$/se', "stripslashes(Columnize('$1', '$2'))"); function Columnize($one, $two) { $bits = preg_split("/\(:colstart:\)/", $one); list($pre, $one) = (count($bits) > 1) ? $bits : array('', $bits[0]); $bits = preg_split("/\(:colend:\)/", $two); list($two, $post) = (count($bits) > 1) ? $bits : array($bits[0],''); return<<<RETURN $pre (:table class=columns border=0 cellspacing=0 cellpadding=6:) (:cellnr valign=top width=50%:) $one (:cell valign=top width=50%:) $two (:tableend:) $post RETURN; }