getElementsByTagName('DataSet');
foreach ($Datasets as $Dataset) {
$Units = $Dataset->getElementsByTagName('Unit');
if(!$Units) { echo "
Provider sendet keine Suchergebnisse. Bitte prüfen Sie, ob der Provider nicht verfügbar ist und ob sie die richten UnitIDs abgefragt haben, mitunter sind z.B. für die UnitIDs keine Buchstaben zulässig sind (letzteres erzeugt einen Fehler auf Provider-Seite!) |
"; }
foreach ($Units as $Unit) {
$UnitID = $Unit->getElementsByTagName('UnitID');
$SourceInstitutionCode = $Unit->getElementsByTagName('SourceInstitutionID');
$SourceName = $Unit->getElementsByTagName('SourceID');
echo "Unit ID: | " . $UnitID->item(0)->nodeValue . " |
";
echo "Source Institution: | " . $SourceInstitutionCode->item(0)->nodeValue . " |
";
echo "Source Collection: | " . $SourceName->item(0)->nodeValue . " |
";
if(!empty($UnitID))
{ $sqlUnitID = addslashes($UnitID->item(0)->nodeValue);}
else { $sqlUnitID = ""; }
if(!empty($SourceInstitutionCode))
{ $sqlSourceInstitutionCode = addslashes(utf8_decode($SourceInstitutionCode->item(0)->nodeValue));}
else { $sqlSourceInstitutionCode = "";}
if(!empty($SourceName))
{ $sqlSourceName = addslashes(utf8_decode($SourceName->item(0)->nodeValue));}
else { $sqlSourceName = ""; }
$resultTest = "SELECT ID_Cache FROM tablecache WHERE UnitID_Specimen = '$sqlUnitID' AND CollectionCode_Specimen = '$sqlSourceName' AND InstitutionCode_Specimen = '$sqlSourceInstitutionCode' AND ID_Dataset_Specimen = '$formProviderIntern'";
$sqlTest = mysql_query($resultTest);
if(mysql_num_rows($sqlTest)) { echo "Specimen already exist in database |
|
"; }
if(!mysql_num_rows($sqlTest)) {
/*----------------------------GATHERING--------------------------------------------------------- */
$Gatherings = $Unit->getElementsByTagName('Gathering');
foreach ($Gatherings as $Gathering) {
$GatheringDate = $Gathering->getElementsByTagName('DateTime');
$GatheringAgents = $Gathering->getElementsByTagName('Agents');
$LocalityText = $Gathering->getElementsByTagName('LocalityText');
$Country = $Gathering->getElementsByTagName('Country');
$NamedArea = $Gathering->getElementsByTagName('NamedArea'); //if (empty($Country))
$AreaName = $Gathering->getElementsByTagName('AreaName');
$NearNamedPlaces = $Gathering->getElementsByTagName('NearNamedPlaces'); //if (empty($Country))
$Altitude = $Gathering->getElementsByTagName('Altitude');
$LongitudeDecimal = $Gathering->getElementsByTagName('LongitudeDecimal');
$LatitudeDecimal = $Gathering->getElementsByTagName('LatitudeDecimal');
$SiteCoordinates = $Gathering->getElementsByTagName('SiteCoordinatesSets'); //if (empty($LongitudeDecimal & LatitudeDecimal))
if($Altitude->item(0)->nodeValue != "")
{
foreach ($Altitude as $AltitudeDetail) {
$AltitudeLowerValue = $AltitudeDetail->getElementsByTagName('LowerValue');
$AltitudeUpperValue = $AltitudeDetail->getElementsByTagName('UpperValue');
if($AltitudeLowerValue->item(0)->nodeValue != "")
{$sqlAltitude = addslashes($AltitudeLowerValue->item(0)->nodeValue);}
if($AltitudeUpperValue->item(0)->nodeValue != "")
{ $sqlAltitude .= addslashes($AltitudeUpperValue->item(0)->nodeValue);}
}
}
else { $sqlAltitude = ""; }
if($GatheringDate->item(0)->nodeValue != "")
{
foreach ($GatheringDate as $DateTime) {
$GatheringDateText = $DateTime->getElementsByTagName('DateText');
$GatheringISODateTimeBegin = $DateTime->getElementsByTagName('ISODateTimeBegin');
$GatheringDayNumberBegin = $DateTime->getElementsByTagName('DayNumberBegin');
$GatheringTimeOfDayBegin = $DateTime->getElementsByTagName('ISOTimeOfDayBegin');
$GatheringISODateTimeEnd = $DateTime->getElementsByTagName('ISODateTimeEnd');
$GatheringDayNumberEnd = $DateTime->getElementsByTagName('DayNumberEnd');
$GatheringTimeOfDayEnd = $DateTime->getElementsByTagName('TimeOfDayEnd');
if($GatheringDateText->item(0)->nodeValue != "") {
// echo "Date: " . $GatheringDateText->item(0)->nodeValue . "
";
$sqlGatheringDate = addslashes($GatheringDateText->item(0)->nodeValue); }
if(empty($GatheringDateText)) {
// echo "Date2: " . $GatheringDate->item(0)->nodeValue . "
"; //if (empty($GatheringDate))
if($GatheringISODateTimeBegin) {
$sqlGatheringDate .= " " . $GatheringISODateTimeBegin->item(0)->nodeValue; }
if($GatheringDayNumberBegin) {
$sqlGatheringDate .= " " . $GatheringDayNumberBegin->item(0)->nodeValue; }
if($GatheringTimeOfDayBegin) {
$sqlGatheringDate .= " " . $GatheringTimeOfDayBegin->item(0)->nodeValue; }
if($GatheringISODateTimeEnd) {
$sqlGatheringDate .= " " . $GatheringISODateTimeEnd->item(0)->nodeValue; }
if($GatheringDayNumberEnd) {
$sqlGatheringDate .= " " . $GatheringDayNumberEnd->item(0)->nodeValue; }
if($GatheringTimeOfDayEnd) {
$sqlGatheringDate .= " " . $GatheringTimeOfDayEnd->item(0)->nodeValue; }
}
} }
else { $sqlGatheringDate = ""; }
if($GatheringAgents->item(0)->nodeValue != "")
{
foreach ($GatheringAgents as $GatheringAgent) {
$PersonName = $GatheringAgent->getElementsByTagName('GatheringAgent');
$AgentText = $GatheringAgent->getElementsByTagName('GatheringAgentsText'); //if (empty($GatheringAgent)
if($PersonName->item(0)->nodeValue != "") {
// echo $PersonName->item(0)->nodeValue."
";
$sqlPersonName = addslashes(utf8_decode($PersonName->item(0)->nodeValue)); }
if($AgentText->item(0)->nodeValue != "") {
// echo "Person: " . $PersonName->item(0)->nodeValue . "
";
$sqlPersonName = addslashes(utf8_decode($AgentText->item(0)->nodeValue));
echo $AgentText->item(0)->nodeValue."hallo2
";
}
} }
else {$sqlPersonName = ""; }
if($LocalityText->item(0)->nodeValue != "")
// echo "Locality: " . $LocalityText->item(0)->nodeValue . "
";
{ $sqlLocalityText = addslashes(utf8_decode($LocalityText->item(0)->nodeValue));}
else {$sqlLocalityText = "";}
if($Country->item(0)->nodeValue != "")
{
foreach ($Country as $Countries) {
$CountryName = $Countries->getElementsByTagName('Name');
$ISO2 = $Countries->getElementsByTagName('ISO3166Code');
if($CountryName->item(0)->nodeValue != "") {
// echo "Country: " . $CountryName->item(0)->nodeValue . "
";
$sqlCountryName = addslashes($CountryName->item(0)->nodeValue); }
if($ISO2->item(0)->nodeValue != "") {
// echo "Country2: " . $Country->item(0)->nodeValue . "
";
// echo "ISO2: " . $ISO2->item(0)->nodeValue . "
";
$sqlISO2 = addslashes($ISO2->item(0)->nodeValue); }
} }
else {$sqlCountryName = "";
$sqlISO2 = ""; }
if(empty($NamedArea)) {
$sqlGatheringOther = addslashes($NearNamedPlaces->item(0)->nodeValue);
}
if($AreaName->item(0)->nodeValue != "")
{$sqlNamedAreas = addslashes($AreaName->item(0)->nodeValue);}
if($sqlNamedAreas = 'Africa' or $sqlNamedAreas = 'Asia' or $sqlNamedAreas = 'Australia' or $sqlNamedAreas = 'Australia and Oceania' or $sqlNamedAreas = 'Europe' or $sqlNamedAreas = 'Middle America' or $sqlNamedAreas = 'South America' or $sqlNamedAreas = 'Middle America' or $sqlNamedAreas = 'Middle and South America' or $sqlNamedAreas = 'North America' or $sqlNamedAreas = ' Atlantic Ocean' or $sqlNamedAreas = 'Arctic Ocean' or $sqlNamedAreas = 'Indian Ocean' or $sqlNamedAreas = 'Pacific Ocean' or $sqlNamedAreas = 'Southern Ocean' or $sqlNamedAreas = 'Landlocked Sea')
{ $sqlContinentOrOcean = addslashes($AreaName->item(0)->nodeValue); }
else {
// echo "NamedAreas: " . $NamedAreas->item(0)->nodeValue . "
";
$sqlGatheringOther = addslashes($NamedArea->item(0)->nodeValue);
}
if($LongitudeDecimal->item(0)->nodeValue != "")
// echo "Longitude: " . $LongitudeDecimal->item(0)->nodeValue . "
";
{$sqlLongitudeDecimal = $LongitudeDecimal->item(0)->nodeValue;}
else { $sqlLongitudeDecimal = ""; }
if($LatitudeDecimal->item(0)->nodeValue != "")
// echo "Latitude: " . $LatitudeDecimal->item(0)->nodeValue . "
";
{$sqlLatitudeDecimal = $LatitudeDecimal->item(0)->nodeValue;}
else { $sqlLatitudeDecimal = "";}
// echo "Altitude: " . $Altitude->item(0)->nodeValue . "
";
} //foreach $Gatherings
$TypeDesignations = $Unit->getElementsByTagName('NomenclaturalTypeDesignation');
foreach ($TypeDesignations as $TypeDesignation) {
$TypeStatus = $TypeDesignation->getElementsByTagName('TypeStatus');
$sqlTypeStatus = $TypeStatus->item(0)->nodeValue;
}
$result1 = "INSERT INTO tablecache (UnitID_Specimen, CollectionCode_Specimen, InstitutionCode_Specimen, ContinentOrOcean, CountryName, CountryISO2, GatheringAgent, GatheringDate, LocalityText, LongitudeDecimal, LatitudeDecimal, Altitude, Gathering_Other, ID_Dataset_Specimen, TypeStatus, Created_Who) VALUES ('$sqlUnitID','$sqlSourceName','$sqlSourceInstitutionCode','$sqlContinentOrOcean','$sqlCountryName','$sqlISO2','$sqlPersonName','$sqlGatheringDate','$sqlLocalityText','$sqlLongitudeDecimal','$sqlLatitudeDecimal','$sqlAltitude','$sqlGatheringOther','$formProviderIntern','$sqlTypeStatus','$log')";
$sql1 = mysql_query($result1);
$IDTableCache=mysql_insert_id();
#######################################Error 1###############################################################
if(!$sql1)
{ $msg = $result1."\n";
$msg .= "####Error 1####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
/*----------------------------IDENTIFICATIONS--------------------------------------------------------- */
$Identifications = $Unit->getElementsByTagName('Identification');
foreach ($Identifications as $IndexIdentification => $Identification) { // more than one Identification possible
$NameAuthorYearString = $Identification->getElementsByTagName('FullScientificNameString'); // Name, Author, Year
$HigherTaxa = $Identification->getElementsByTagName('HigherTaxon');
$ScientificNames = $Identification->getElementsByTagName('ScientificName');
$Preferred = $Identification->getElementsByTagName('PreferredFlag');
if($NameAuthorYearString->item(0)->nodeValue != "")
// echo "Name All: " . $NameAuthorYearString->item(0)->nodeValue . "
";
{ $sqlNameAuthorYearString = addslashes(utf8_decode($NameAuthorYearString->item(0)->nodeValue));}
if($Preferred->item(0)->nodeValue != "")
// echo "Preferred: " . $Preferred->item(0)->nodeValue . "
";
{ $sqlPreferredIdentificationFlag = $Preferred->item(0)->nodeValue;}
foreach ($ScientificNames as $ScientificName) {
// $ScientificNamesAtomized = $ScientificName->getElementsByTagName('NameAtomised');
// foreach ($ScientificNamesAtomized as $ScientificNameAtomized) {
$Bacteria = $ScientificName->getElementsByTagName('Bacterial');
$Botany = $ScientificName->getElementsByTagName('Botanical');
$Zoology = $ScientificName->getElementsByTagName('Zoological');
$Virology = $ScientificName->getElementsByTagName('Viral');
if($Bacteria) {
foreach ($Bacteria as $Bacterical) {
$GenusBac = $Bacterical->getElementsByTagName('GenusOrMonomial');
$SubgenusBac = $Bacterical->getElementsByTagName('Subgenus');
$SpeciesEpithetBac = $Bacterical->getElementsByTagName('SpeciesEpithet');
$SubspeciesEpithetBac = $Bacterical->getElementsByTagName('SubspeciesEpithet');
if(!empty($GenusBac))
// echo "Genus: " . $GenusBac->item(0)->nodeValue . "
";
{ $sqlGenus = $GenusBac->item(0)->nodeValue;}
if(!empty($SubgenusBac))
// echo "Subgenus: " . $SubgenusBac->item(0)->nodeValue . "
";
{ $sqlSubgenus = $SubgenusBac->item(0)->nodeValue; }
if(!empty($SpeciesEpithetBac))
// echo "Spec.Epi: " . $SpeciesEpithetBac->item(0)->nodeValue . "
";
{ $sqlFirstEpithet = $SpeciesEpithetBac->item(0)->nodeValue; }
if(!empty($SubspeciesEpithetBac))
// echo "SspEpi: " . $SubspeciesEpithetBac->item(0)->nodeValue . "
";
{ $sqlSecondEpithet = $SubspeciesEpithetBac->item(0)->nodeValue;}
if(empty($sqlGenus) and empty($sqlSubgenus) and empty($sqlFirstEpithet) and empty($sqlSubspecies))
{
// echo "Bacteria_All: " . $Bacteria->item(0)->nodeValue . "
"; //if (empty -> $GenusBac, $SubgenusBac, $SpeciesEpithetBac, $SubspeciesEpithetBac)
$sqlName_All = $Bacteria->item(0)->nodeValue; }
} //foreach $Bacteria
} //if($Bacteria)
if($Botany) {
foreach ($Botany as $Botanical) {
$GenusBot = $Botanical->getElementsByTagName('GenusOrMonomial');
$FirstEpithet = $Botanical->getElementsByTagName('FirstEpithet');
$SecondEpithet = $Botanical->getElementsByTagName('InfraspecificEpithet');
$Rank = $Botanical->getElementsByTagName('Rank');
$HybridFlag = $Botanical->getElementsByTagName('HybridFlag');
if(!empty($GenusBot))
// echo "Genus: " . $GenusBot->item(0)->nodeValue . "
";
{ $sqlGenus = $GenusBot->item(0)->nodeValue; }
if(!empty($FirstEpithet))
// echo "Spec.Epi: " . $FirstEpithet->item(0)->nodeValue . "
";
{ $sqlFirstEpithet = $FirstEpithet->item(0)->nodeValue; }
if(!empty($Rank))
// echo "Rank: " . $Rank->item(0)->nodeValue . "
";
{ $sqlRank = $Rank->item(0)->nodeValue; }
if(!empty($SecondEpithet))
// echo "Sec.Epi: " . $SecondEpithet->item(0)->nodeValue . "
";
{ $sqlSecondEpithet = $SecondEpithet->item(0)->nodeValue; }
if(!empty($HybridFlag))
// echo "Hybrid: " . $HybridFlag->item(0)->nodeValue . "
";
{ $sqlHybridFlag = $HybridFlag->item(0)->nodeValue; }
if(empty($sqlGenus) and empty($sqlFirstEpithet) and empty($sqlRank) and empty($sqlSecondEpithet))
{
// echo "Botany_All: " . $Botany->item(0)->nodeValue . "
"; //if (empty -> $GenusBot, $FirstEpithet, $SecondEpithet, $Rank, $HybridFlag)
$sqlName_All = $Botany->item(0)->nodeValue; }
} //foreach $Botany
} //if($Botany)
if($Zoology) {
foreach ($Zoology as $Zoological => $Zoo) {
$GenusZoo = $Zoo->getElementsByTagName('GenusOrMonomial');
$SubgenusZoo = $Zoo->getElementsByTagName('Subgenus');
$SpeciesEpithetZoo = $Zoo->getElementsByTagName('SpeciesEpithet');
$SubspeciesEpithetZoo = $Zoo->getElementsByTagName('SubspeciesEpithet');
if(!empty($GenusZoo))
// echo "Genus: " .$GenusZoo->item(0)->nodeValue."
";
{ $sqlGenus = $GenusZoo->item(0)->nodeValue; }
if(!empty($SubgenusZoo))
// echo "Subgenus: " . $SubgenusZoo->item(0)->nodeValue . "
";
{ $sqlSubgenus = $SubgenusZoo->item(0)->nodeValue; }
if(!empty($SpeciesEpithetZoo))
// echo "Spec.Epi: " . $SpeciesEpithetZoo->item(0)->nodeValue . "
";
{ $sqlFirstEpithet = $SpeciesEpithetZoo->item(0)->nodeValue; }
if(!empty($SubspeciesEpithetZoo))
// echo "SspEpi: " . $SubspeciesEpithetZoo->item(0)->nodeValue . "
";
{ $sqlSecondEpithet = $SubspeciesEpithetZoo->item(0)->nodeValue;}
if($sqlSecondEpithet) {
$sqlRank = "ssp."; }
if(empty($sqlGenus) and empty($sqlSubgenus) and empty($sqlFirstEpithet) and empty($sqlSecondEpithet))
{
// echo "Zoology_All: " . $Zoo->nodeValue . "
"; //if (empty -> $GenusZ, $SubgenusZ, $SpeciesEpithetZ, $SubspeciesEpithetZ)
$sqlName_All = $Zoology->item(0)->nodeValue; }
} //foreach $Zoology
} //if($Zoology)
if($Virology)
{
foreach ($Virology as $Viral) {
$GenusV = $Viral->getElementsByTagName('GenusOrMonomial');
if(!empty($GenusV))
// echo "Genus: " . $GenusV->item(0)->nodeValue . "
";
{ $sqlGenus = $GenusV->item(0)->nodeValue;}
if(empty($sqlGenus))
{
// echo "Virology_All: " . $Virology->item(0)->nodeValue . "
";
$sqlName_All = $Virology->item(0)->nodeValue; }
} //foreach $Virology
} //if($Virology)
// } //foreach $ScientificNamesAtomized
$result2 = "INSERT INTO tablecachetaxonidentified (ID_Cache, Genus, Subgenus, FirstEpithet, SecondEpithet, Rank, HybridFlag, NameAuthorYear, Other, PreferredFlag, Created_Who) VALUES ('$IDTableCache','$sqlGenus','$sqlSubgenus','$sqlFirstEpithet','$sqlSecondEpithet','$sqlRank','$sqlHybridFlag','$sqlNameAuthorYearString','$sqlName_All','$sqlPreferredIdentificationFlag','$log')";
$sql2 = mysql_query($result2);
$IDTableCacheTaxonIdentified=mysql_insert_id();
#######################################Error 2###############################################################
if(!$sql2)
{ $msg = $result2."\n";
$msg .= "####Error 2####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
} //foreach $ScientificNames
foreach ($HigherTaxa as $index => $HigherTaxon1) { // more than one HigherTaxon per Identification possible
$HigherTaxon = $HigherTaxon1->getElementsByTagName('HigherTaxonName');
$TaxonRank = $HigherTaxon1->getElementsByTagName('HigherTaxonRank');
if(!empty($HigherTaxon))
// echo "Higher Taxon: " .$HigherTaxon->item(0)->nodeValue." (".$TaxonRank->item(0)->nodeValue.")
";
{ $sqlHigherTaxon = $HigherTaxon->item(0)->nodeValue;}
if(!empty($TaxonRank))
{ $sqlHigherTaxonRank = $TaxonRank->item(0)->nodeValue;}
$result3 = "INSERT INTO tablecachehighertaxa (ID_CacheTaxonIdentified, HigherTaxon, TaxonRank, Created_Who) VALUES ('$IDTableCacheTaxonIdentified','$sqlHigherTaxon','$sqlHigherTaxonRank','$log')";
$sql3 = mysql_query($result3);
#######################################Error 3###############################################################
if(!$sql3)
{ $msg = $result3."\n";
$msg .= "####Error 3####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
} //foreach $HugherTaxa
} //foreach $Identifications
/*-------------------------------------------MULTI MEDIA ---------------------------------------*/
$MultiMediaObjects = $Unit->getElementsByTagName('MultiMediaObject');
foreach ($MultiMediaObjects as $IndexMultiMediaObjects => $MultiMediaObject) { // more than one Identification possible
$FileURI = $MultiMediaObject->getElementsByTagName('FileURI');
$ProductURI = $MultiMediaObject->getElementsByTagName('ProductURI');
if(!empty($FileURI))
{$sqlFileURI = $FileURI->item(0)->nodeValue;}
if(empty($FileURI) and !empty($ProductURI))
{$sqlFileURI = $ProductURI->item(0)->nodeValue; }
$result4 = "INSERT INTO tablecacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$sqlFileURI','$log')";
$sql4 = mysql_query($result4);
#######################################Error 4###############################################################
if(!$sql4)
{ $msg = $result4."\n";
$msg .= "####Error 4####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php");
$error = "true"; }
#############################################################################################################
} // foreach $MultiMediaObjects
if($sql1 and $sql2)
{ echo "Data have been saved! |
|
"; }
} // if(!mysql_num_rows($sqlTest))
}
} // foreach $Datasets
?>