summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-02-04 13:05:14 +0100
committeremkael <emkael@tlen.pl>2018-02-04 13:05:14 +0100
commit4e91dd3b096afbd8e05fa052001589308e29405b (patch)
tree8a536c03fe3a01dc2514129c3ad3a24e853ce900
parente370fce634e5fd70da4be4dcb2f51abbfad21358 (diff)
Passing through unchanged original HTML file if no deal files are found
-rw-r--r--tdd-bootstrap.php12
-rw-r--r--tdd-protocol.php11
2 files changed, 12 insertions, 11 deletions
diff --git a/tdd-bootstrap.php b/tdd-bootstrap.php
index 9f874a3..48b088f 100644
--- a/tdd-bootstrap.php
+++ b/tdd-bootstrap.php
@@ -24,7 +24,6 @@ class Protocol {
function output() {
$content = file_get_contents($this->get_filename());
- $modified = 0;
$dom = str_get_html($content);
$header_td1 = $dom->find("/html/body/table/tr/td[class=\"bdcc12\"]", 0);
@@ -48,7 +47,6 @@ class Protocol {
if(($score1 !== '' || strpos($contract1, 'A') === 0)
&& ($score2 !== '' || strpos($contract2, 'A') === 0)) {
$insert .= $deal->html();
- $modified = 1;
} else {
$insert .= '<p>...</p>';
}
@@ -58,12 +56,10 @@ class Protocol {
$tr = @$tr->next_sibling();
}
- if($modified) {
- $header_tr2 = $header_tr->next_sibling();
- $header_tr->outertext = '';
- $header_tr2->outertext = '';
- $dom->find('/html/body/table/tr', 0)->outertext = '';
- }
+ $header_tr2 = $header_tr->next_sibling();
+ $header_tr->outertext = '';
+ $header_tr2->outertext = '';
+ $dom->find('/html/body/table/tr', 0)->outertext = '';
$head = $dom->find('/html/head', 0);
$head->innertext .= '<link rel="stylesheet" type="text/css" href="css/tdd.css" />'
diff --git a/tdd-protocol.php b/tdd-protocol.php
index 7f6eb7b..3dcc0d8 100644
--- a/tdd-protocol.php
+++ b/tdd-protocol.php
@@ -18,7 +18,12 @@ if($request_uri_ending != '/' . $html_filename) {
//
$deals_by_tables = load_deals_for_tables($prefix, $round, $board);
-foreach($deals_by_tables as $table => $deal) {
- $protocol->set_deal($table, $deal);
+if (count($deals_by_tables) > 0) {
+ foreach($deals_by_tables as $table => $deal) {
+ $protocol->set_deal($table, $deal);
+ }
+ echo $protocol->output();
+}
+else {
+ readfile($html_filename);
}
-echo $protocol->output();