diff options
Diffstat (limited to 'tdd')
-rw-r--r-- | tdd/tdd-bootstrap.php | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/tdd/tdd-bootstrap.php b/tdd/tdd-bootstrap.php index 59abdb6..de78192 100644 --- a/tdd/tdd-bootstrap.php +++ b/tdd/tdd-bootstrap.php @@ -31,27 +31,30 @@ class Protocol { $tr = @$header_tr->next_sibling(); while($tr) { $td = $tr->find('td/a', 0); - $table = trim($td->innertext); - $table = str_replace(' ', '', $table); - $table = (int)$table; - if($table && array_key_exists($table, $this->deals_by_tables)) { - $contract1 = trim(str_replace(' ', '', $tr->find('td[class="bdc"]', 0)->innertext)); - $score1 = trim(str_replace(' ', '', end($tr->find('td'))->innertext)); - $contract2 = trim(str_replace(' ', '', $tr->next_sibling()->find('td[class="bdc"]', 0)->innertext)); - $score2 = trim(str_replace(' ', '', end($tr->next_sibling()->find('td'))->innertext)); - - $deal = $this->deals_by_tables[$table]; - $insert = "<a href=\"#table-$table\"><h4 id=\"table-$table\">Stół $table – Rozdanie {$deal->deal_num}</h4></a>"; - // if is played on both tables of a match - // note that the contract field for arbitral scores starts with 'A' (e.g. 'ARB' or 'AAA') - if(($score1 !== '' || strpos($contract1, 'A') === 0) - && ($score2 !== '' || strpos($contract2, 'A') === 0)) { - $insert .= $deal->html(); - } else { - $insert .= '<p>...</p>'; + if ($td) { + $table = trim($td->innertext); + $table = str_replace(' ', '', $table); + $table = (int)$table; + if($table && array_key_exists($table, $this->deals_by_tables)) { + $nextTr = $tr->next_sibling(); + $contract1 = trim(str_replace(' ', '', $tr->find('td[class="bdc"]', 0)->innertext)); + $score1 = trim(str_replace(' ', '', $tr->find('td', 6)->innertext)); + $contract2 = trim(str_replace(' ', '', $tr->next_sibling()->find('td[class="bdc"]', 0)->innertext)); + $score2 = trim(str_replace(' ', '', $nextTr->find('td', 5)->innertext)); + + $deal = $this->deals_by_tables[$table]; + $insert = "<a href=\"#table-$table\"><h4 id=\"table-$table\">Stół $table – Rozdanie {$deal->deal_num}</h4></a>"; + // if is played on both tables of a match + // note that the contract field for arbitral scores starts with 'A' (e.g. 'ARB' or 'AAA') + if(($score1 !== '' || strpos($contract1, 'A') === 0) + && ($score2 !== '' || strpos($contract2, 'A') === 0)) { + $insert .= $deal->html(); + } else { + $insert .= '<p>...</p>'; + } + + $tr->outertext = '<tr class="tdd-header"><td colspan="' . (count($tr->find('td'))-1) . '">' . $insert . '</td></tr>' . $tr->outertext; } - - $tr->outertext = '<tr class="tdd-header"><td colspan="7">' . $insert . '</td></tr>' . $tr->outertext; } $tr = @$tr->next_sibling(); } |