Source for file Table.php
Documentation is available at Table.php
public $elements =
array('tr' =>
true, 'tbody' =>
true, 'thead' =>
true,
'tfoot' =>
true, 'caption' =>
true, 'colgroup' =>
true, 'col' =>
true);
if (empty($tokens_of_children)) return false;
// this ensures that the loop gets run one last time before closing
// up. It's a little bit of a hack, but it works! Just make sure you
// get rid of the token later.
$tokens_of_children[] =
false;
// only one of these elements is allowed in a table
// as many of these as you want
$nesting =
0; // current depth so we can determine nodes
$is_collecting =
false; // are we globbing together tokens to package
// into one of the collectors?
$collection =
array(); // collected nodes
$tag_index =
0; // the first node might be whitespace,
// so this tells us where the start tag is
foreach ($tokens_of_children as $token) {
$is_child =
($nesting ==
0);
// terminating sequence started
// handle node collection
// okay, let's stash the tokens away
// first token tells us the type of the collection
switch ($collection[$tag_index]->name) {
$content[] =
$collection;
if ($caption !==
false) break;
// access the appropriate variable, $thead or $tfoot
$var =
$collection[$tag_index]->name;
// transmutate the first and less entries into
// tbody tags, and then put into content
$collection[$tag_index]->name =
'tbody';
$collection[count($collection)-
1]->name =
'tbody';
$content[] =
$collection;
// add the node to the collection
if ($token ===
false) break;
// determine what we're dealing with
if ($token->name ==
'col') {
// the only empty tag in the possie, we can handle it
if (empty($content)) return false;
if ($caption !==
false) $ret =
array_merge($ret, $caption);
if ($cols !==
false) foreach ($cols as $token_array) $ret =
array_merge($ret, $token_array);
if ($thead !==
false) $ret =
array_merge($ret, $thead);
if ($tfoot !==
false) $ret =
array_merge($ret, $tfoot);
foreach ($content as $token_array) $ret =
array_merge($ret, $token_array);
if (!empty($collection) &&
$is_collecting ==
false){
// grab the trailing space
array_pop($tokens_of_children); // remove phantom token
return ($ret ===
$tokens_of_children) ?
true :
$ret;
Documentation generated on Thu, 19 Jun 2008 18:50:22 -0400 by phpDocumentor 1.4.2