Source for file Table.php
Documentation is available at Table.php
* Parses for table markup.
* This class implements a Text_Wiki_Parse to find source text marked as
* a set of table rows, where a line start (and optionally ends) with a
* single-pipe (|) and uses single-pipes to separate table cells.
* The rows must be on sequential lines (no blank lines between them).
* A blank line indicates the beginning of other text or another table.
* @author Michele Tomaiuolo <tomamic@yahoo.it>
* @author Paul M. Jones <pmjones@php.net>
* @version $Id: Table.php 243077 2007-09-28 17:14:58Z mic $
* The regular expression used to parse the source text and find
* matches conforming to this rule. Used by the parse() method.
var $regex = '/\n((\|).*)(\n)(?!(\|))/Us';
* Generates a replacement for the matched text.
* 'table_start' : the start of a bullet list
* 'table_end' : the end of a bullet list
* 'row_start' : the start of a number list
* 'row_end' : the end of a number list
* 'cell_start' : the start of item text (bullet or number)
* 'cell_end' : the end of item text (bullet or number)
* 'cols' => the number of columns in the table (for 'table_start')
* 'rows' => the number of rows in the table (for 'table_start')
* 'span' => column span (for 'cell_start')
* 'attr' => column attribute flag (for 'cell_start')
* @param array &$matches The array of matches from parse().
* @return A series of text and delimited tokens marking the different
* table elements and cell text.
// our eventual return value
// the number of columns in the table
// the number of rows in the table
// rows are separated by newlines in the matched text
$rows = explode("\n", $matches[1 ]);
foreach ($rows as $row) {
// increase the row count
// remove first and last (optional) pipe
if ($row[strlen($row) - 1 ] == '|') {
// cells are separated by pipes
if (count($cells) == 1 && $cells[0 ][0 ] == '=' && ($num_rows == 1 || $num_rows == count($rows)) && ! isset ($caption)) {
$return .= $this->wiki->addToken (
array ('type' => 'caption_start')
// ...and end the caption.
$return .= $this->wiki->addToken (
array ('type' => 'caption_end')
// update the column count
if (count($cells) > $num_cols) {
$num_cols = count($cells);
$return .= $this->wiki->addToken (
array ('type' => 'row_start')
for ($i = 0; $i < count($cells); $i++ ) {
// by default, cells span only one column (their own)
while ($i + 1 < count($cells) && ! strlen($cells[$i + 1 ])) {
if (strlen($cell) > 0 && $cell[0 ] == '=') {
$cell = trim($cell, '=');
$return .= $this->wiki->addToken (
$return .= $this->wiki->addToken (
$return .= $this->wiki->addToken (
array ('type' => 'row_end')
Documentation generated on Mon, 11 Mar 2019 15:40:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|