content = ''; require 'Templates.php'; $this->templates = new Templates($this->content); $this->response = './inc/bogartResponseFrame.html'; } /** * Add tables for one 'Akzession' */ public function addTablesForOneAkzession($akzIndex, $rows) { $this->addAkzessionTable($akzIndex, $rows); $this->addTaxonTable($rows); $this->addHerkunftTable($rows); $this->addGartenherbarTable($rows); $this->addGartenstandortTable($rows); } private function addAkzessionTable($rowCount, $rows) { $row = $rows[0]; $akzDataJahr = $row['AkzDatJahr']; $akzNr = $row['AkzNr']; $template = <<
$rowCount. Akzession Akzessionsjahr: $akzDataJahr Akzessionsnummer: $akzNr

EOT; $this->content .= $template; } /** * Add a line of text */ public function addTextLine($value) { $template = <<content .= $template; } /** * Add a paragraph */ public function addParagraph($value) { $template = <<$value

EOT; $this->content .= $template; } /** * Add Taxon table */ private function addTaxonTable($rows) { // looking for non empty entries $nonEmpty = array(); for ($i = 0; $i < count($rows); $i++) { if ($this->hasContentTaxonData($rows[$i])) { $nonEmpty[] = $rows[$i]; } } if (count($nonEmpty) > 0) { // remove duplicates $entries = array(); $entries[] = $nonEmpty[0]; for ($j = 1; $j < count($nonEmpty); $j++) { $existsElementInEntries = false; $nextCandidate = $nonEmpty[$j]; for ($k = 0; $k < count($entries); $k++) { if ($this->equalsTaxonData($nextCandidate, $entries[$k])) { $existsElementInEntries = true; break; } } if (!$existsElementInEntries) { $entries[] = $nextCandidate; } } for ($i = 0; $i < count($entries); $i++) { $this->addOneTaxonTable($entries[$i]); } } else { // case 'Gartenherbar' (..._H) // looking for non empty entries $nonEmpty = array(); for ($i = 0; $i < count($rows); $i++) { if ($this->hasContentTaxonData_H($rows[$i])) { $nonEmpty[] = $rows[$i]; } } if (count($nonEmpty) > 0) { // remove duplicates $entries = array(); $entries[] = $nonEmpty[0]; for ($j = 1; $j < count($nonEmpty); $j++) { $existsElementInEntries = false; $nextCandidate = $nonEmpty[$j]; for ($k = 0; $k < count($entries); $k++) { if ($this->equalsTaxonData_H($nextCandidate, $entries[$k])) { $existsElementInEntries = true; break; } } if (!$existsElementInEntries) { $entries[] = $nextCandidate; } } for ($i = 0; $i < count($entries); $i++) { $this->addOneTaxonTable_H($entries[$i]); } } } } private function equalsTaxonData($row1, $row2) { $equals = $row1['WissNameTax'] == $row2['WissNameTax'] && $row1['Familie'] == $row2['Familie'] && $row1['HTaxon'] == $row2['HTaxon'] && $row1['DeutscheNamen'] == $row2['DeutscheNamen'] && $row1['IstGiftText'] == $row2['IstGiftText'] && $row1['IstArzneiText'] == $row2['IstArzneiText']; return $equals; } private function equalsTaxonData_H($row1, $row2) { $equals = $row1['H_WissNameTax'] == $row2['H_WissNameTax'] && $row1['H_Familie'] == $row2['H_Familie'] && $row1['H_HTaxon'] == $row2['H_HTaxon'] && $row1['H_DeutscheNamen'] == $row2['H_DeutscheNamen'] && $row1['H_IstGiftText'] == $row2['H_IstGiftText'] && $row1['H_IstArzneiText'] == $row2['H_IstArzneiText']; return $equals; } private function hasContentTaxonData($row) { $hasContent = $row['WissNameTax'] || $row['Familie'] || $row['HTaxon'] || $row['DeutscheNamen'] || ($row['IstGiftText'] && $row['IstGiftText'] != 'k.A.') || ($row['IstArzneiText'] && $row['IstArzneiText'] != 'k.A.'); return $hasContent; } private function hasContentTaxonData_H($row) { $hasContent = $row['H_WissNameTax'] || $row['H_Familie'] || $row['H_HTaxon'] || $row['H_DeutscheNamen'] || ($row['H_IstGiftText'] && $row['H_IstGiftText'] != 'k.A.') || ($row['H_IstArzneiText'] && $row['H_IstArzneiText'] != 'k.A.'); return $hasContent; } private function addOneTaxonTable($row) { $this->templates->addTaxonTableBegin(); if ($row['WissNameTax']) { $this->templates->addTaxonFirstRow('Taxon Name (zur Akzession)', $row['WissNameTax']); } if ($row['BestimmerITF']) { $this->templates->addTaxonRow('Verif. Name', $row['BestimmerITF']); } if ($row['BestDatum']) { $this->templates->addTaxonRow('Verif. Datum', $row['BestDatum']); } if ($row['Familie']) { $this->templates->addTaxonRow('Familie', $row['Familie']); } if ($row['HTaxon']) { $this->templates->addTaxonRow('höhere Taxoneinheit', $row['HTaxon']); } if ($row['DeutscheNamen']) { $this->templates->addTaxonRow('deutscher Name', $row['DeutscheNamen']); } if ($row['IstGiftText'] && $row['IstGiftText'] != 'k.A.') { $this->templates->addTaxonRow('Giftig', $row['IstGiftText']); } if ($row['IstArzneiText'] && $row['IstArzneiText'] != 'k.A.') { $this->templates->addTaxonRow('Arzneipflanze', $row['IstArzneiText']); } $this->templates->addTaxonTableEnd(); } private function addOneTaxonTable_H($row) { $this->templates->addTaxonTableBegin(); if ($row['H_WissNameTax']) { $this->templates->addTaxonFirstRow('Taxon Name (zum GH)', $row['H_WissNameTax']); } if ($row['H_BestimmerITF']) { $this->templates->addTaxonRow('Verif. Name', $row['H_BestimmerITF']); } if ($row['H_BestDatum']) { $this->templates->addTaxonRow('Verif. Datum', $row['H_BestDatum']); } if ($row['H_Familie']) { $this->templates->addTaxonRow('Familie', $row['H_Familie']); } if ($row['H_HTaxon']) { $this->templates->addTaxonRow('höhere Taxoneinheit', $row['H_HTaxon']); } if ($row['H_DeutscheNamen']) { $this->templates->addTaxonRow('deutscher Name', $row['H_DeutscheNamen']); } if ($row['H_IstGiftText'] && $row['H_IstGiftText'] != 'k.A.') { $this->templates->addTaxonRow('Giftig', $row['H_IstGiftText']); } if ($row['H_IstArzneiText'] && $row['H_IstArzneiText'] != 'k.A.') { $this->templates->addTaxonRow('Arzneipflanze', $row['H_IstArzneiText']); } $this->templates->addTaxonTableEnd(); } /** * Add Herkunft table * @param type $row */ private function addHerkunftTable($rows) { // looking for non empty entries $nonEmpty = array(); for ($i = 0; $i < count($rows); $i++) { if ($this->hasContentHerkunftData($rows[$i])) { $nonEmpty[] = $rows[$i]; } } if (count($nonEmpty) > 0) { // remove duplicates $entries = array(); $entries[] = $nonEmpty[0]; for ($j = 1; $j < count($nonEmpty); $j++) { $existsElementInEntries = false; $nextCandidate = $nonEmpty[$j]; for ($k = 0; $k < count($entries); $k++) { if ($this->equalsHerkunftData($nextCandidate, $entries[$k])) { $existsElementInEntries = true; break; } } if (!$existsElementInEntries) { $entries[] = $nextCandidate; } } for ($i = 0; $i < count($entries); $i++) { $this->addOneHerkunftTable($entries[$i]); } } } private function equalsHerkunftData($row1, $row2) { $equals = $row1['WildHerkLand'] == $row2['WildHerkLand'] && $row1['NaehereOrtsangaben'] == $row2['NaehereOrtsangaben'] && $row1['Hoehe'] == $row2['Hoehe'] && $row1['BreiteGrad'] == $row2['BreiteGrad'] && $row1['LaengeGrad'] == $row2['LaengeGrad'] && $row1['Sammler'] == $row2['Sammler'] && $row1['WildSamDatum'] == $row2['WildSamDatum'] && $row1['AndereHerkunft'] == $row2['AndereHerkunft'] && $row1['Sonstige'] == $row2['Sonstige']; return $equals; } private function hasContentHerkunftData($row) { $hasContent = $row['WildHerkLand'] || $row['NaehereOrtsangaben'] || $row['Hoehe'] || $row['BreiteGrad'] || $row['LaengeGrad'] || $row['Sammler'] || $row['WildSamDatum'] || $row['AndereHerkunft'] || $row['Sonstige']; return $hasContent; } private function addOneHerkunftTable($row) { $this->templates->addHerkunftTableBegin(); if ($row['WildHerkLand']) { $this->templates->addHerkunftRow('Herkunftsland', $row['WildHerkLand']); } if ($row['NaehereOrtsangaben']) { $this->templates->addHerkunftRow('Wildherkunft', $row['NaehereOrtsangaben']); } if ($row['Hoehe']) { $this->templates->addHerkunftRow('Höhe', $row['Hoehe'] . ' m'); } if ($row['BreiteGrad']) { $value = $row['BreiteGrad'] . '° '; $value .= $row['BreiteMin'] . "' "; $value .= $row['BreiteNS']; $this->templates->addHerkunftRow('Breite', $value); } if ($row['LaengeGrad']) { $value = $row['LaengeGrad'] . '° '; $value .= $row['LaengeMin'] . "' "; $value .= $row['LaengeWE']; $this->templates->addHerkunftRow('Länge', $value); } if ($row['Sammler']) { $this->templates->addHerkunftRow('Sammler', $row['Sammler']); } if ($row['WildSamDatum']) { $this->templates->addHerkunftRow('Sammeldatum', $row['WildSamDatum']); } if ($row['AndereHerkunft']) { $this->templates->addHerkunftRow('Botanischer Garten', $row['AndereHerkunft']); } if ($row['Sonstige']) { $this->templates->addHerkunftRow('andere Institute / Arboreten', $row['Sonstige']); } $this->templates->addHerkunftTableEnd(); } /** * Add Gartenherbar table * @param type $rows */ private function addGartenherbarTable($rows) { $ghData = array(); // looking for non empty rows for ($i = 0; $i < count($rows); $i++) { if ($this->hasContentGartenherbarData($rows[$i])) { $ghData[] = $rows[$i]; } } // add the table to the html content if (count($ghData) > 0) { usort($ghData, array($this, 'cmpGartenherbarData')); $this->templates->addGartenherbarTableBegin(); $this->templates->addGartenherbarRow($ghData[0]); $referenceIndex = 0; // looking for different rows for ($i = 1; $i < count($ghData); $i++) { if (!$this->equalsGartenherbarData($ghData[$referenceIndex], $ghData[$i])) { $this->templates->addGartenherbarRow($ghData[$i]); $referenceIndex = $i; } } $this->templates->addGartenherbarTableEnd(); } } private function equalsGartenherbarData($row1, $row2) { return $row1['GHBelegId'] == $row2['GHBelegId']; } private function hasContentGartenherbarData($row) { return $row['GHBelegId']; } function cmpGartenherbarData($a, $b) { if ($a['GHBelegId'] == $b['GHBelegId']) { return 0; } return ($a['GHBelegId'] < $b['GHBelegId']) ? -1 : 1; } /** * Add Gartenstandort table */ private function addGartenstandortTable($rows) { $gsData = array(); // looking for non empty rows for ($i = 0; $i < count($rows); $i++) { if ($this->hasContentGartenstandortData($rows[$i])) { $gsData[] = $rows[$i]; } } // add the table to the html content if (count($gsData) > 0) { usort($gsData, array($this, 'cmpGartenstandortData')); $this->templates->addGartenstandortTableBegin(); $this->templates->addGartenstandortRow($gsData[0]); $referenceIndex = 0; // looking for different rows for ($i = 1; $i < count($gsData); $i++) { if (!$this->equalsGartenstandortData($gsData[$referenceIndex], $gsData[$i])) { $this->templates->addGartenstandortRow($gsData[$i]); $referenceIndex = $i; } } $this->templates->addGartenstandortTableEnd(); } } private function equalsGartenstandortData($row1, $row2) { return $row1['EinheitNr'] == $row2['EinheitNr']; } private function hasContentGartenstandortData($row) { return $row['EinheitNr']; } function cmpGartenstandortData($a, $b) { if ($a['EinheitNr'] == $b['EinheitNr']) { return 0; } return ($a['EinheitNr'] < $b['EinheitNr']) ? -1 : 1; } /** * Get the HTML content for the response document */ public function getContent() { return $this->content; } /** * Print the html response page * @global type $page */ public function printPage() { global $page; $page = $this; require $this->response; } } ?>