get_elements_by_tagname('DataSet'); foreach ($Datasets as $Dataset) { $Units = $Dataset->get_elements_by_tagname('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->get_elements_by_tagname('UnitID'); $SourceInstitutionCode = $Unit->get_elements_by_tagname('SourceInstitutionID'); $SourceName = $Unit->get_elements_by_tagname('SourceID'); echo "Unit ID: " . $UnitID[0]->get_content() . ""; echo "Source Institution: " . $SourceInstitutionCode[0]->get_content() . ""; echo "Source Collection: " . $SourceName[0]->get_content() . ""; if(!empty($UnitID)) { $sqlUnitID = addslashes($UnitID[0]->get_content());} else { $sqlUnitID = ""; } if(!empty($SourceInstitutionCode)) { $sqlSourceInstitutionCode = addslashes(utf8_decode($SourceInstitutionCode[0]->get_content()));} else { $sqlSourceInstitutionCode = "";} if(!empty($SourceName)) { $sqlSourceName = addslashes(utf8_decode($SourceName[0]->get_content()));} 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->get_elements_by_tagname('Gathering'); foreach ($Gatherings as $Gathering) { $GatheringDate = $Gathering->get_elements_by_tagname('DateTime'); $GatheringAgents = $Gathering->get_elements_by_tagname('Agents'); $LocalityText = $Gathering->get_elements_by_tagname('LocalityText'); $Country = $Gathering->get_elements_by_tagname('Country'); $NamedArea = $Gathering->get_elements_by_tagname('NamedArea'); //if (empty($Country)) $AreaName = $Gathering->get_elements_by_tagname('AreaName'); $NearNamedPlaces = $Gathering->get_elements_by_tagname('NearNamedPlaces'); //if (empty($Country)) $Altitude = $Gathering->get_elements_by_tagname('Altitude'); $LongitudeDecimal = $Gathering->get_elements_by_tagname('LongitudeDecimal'); $LatitudeDecimal = $Gathering->get_elements_by_tagname('LatitudeDecimal'); $SiteCoordinates = $Gathering->get_elements_by_tagname('SiteCoordinatesSets'); //if (empty($LongitudeDecimal & LatitudeDecimal)) if($Altitude) { foreach ($Altitude as $AltitudeDetail) { $AltitudeLowerValue = $AltitudeDetail->get_elements_by_tagname('LowerValue'); $AltitudeUpperValue = $AltitudeDetail->get_elements_by_tagname('UpperValue'); if($AltitudeLowerValue) {$sqlAltitude = addslashes($AltitudeLowerValue[0]->get_content());} if($AltitudeUpperValue) { $sqlAltitude .= addslashes($AltitudeUpperValue[0]->get_content());} } } else { $sqlAltitude = ""; } if($GatheringDate) { foreach ($GatheringDate as $DateTime) { $GatheringDateText = $DateTime->get_elements_by_tagname('DateText'); $GatheringISODateTimeBegin = $DateTime->get_elements_by_tagname('ISODateTimeBegin'); $GatheringDayNumberBegin = $DateTime->get_elements_by_tagname('DayNumberBegin'); $GatheringTimeOfDayBegin = $DateTime->get_elements_by_tagname('ISOTimeOfDayBegin'); $GatheringISODateTimeEnd = $DateTime->get_elements_by_tagname('ISODateTimeEnd'); $GatheringDayNumberEnd = $DateTime->get_elements_by_tagname('DayNumberEnd'); $GatheringTimeOfDayEnd = $DateTime->get_elements_by_tagname('TimeOfDayEnd'); if($GatheringDateText) { // echo "Date: " . $GatheringDateText[0]->get_content() . "
"; $sqlGatheringDate = addslashes($GatheringDateText[0]->get_content()); } if(empty($GatheringDateText)) { // echo "Date2: " . $GatheringDate[0]->get_content() . "
"; //if (empty($GatheringDate)) if($GatheringISODateTimeBegin) { $sqlGatheringDate .= " " . $GatheringISODateTimeBegin[0]->get_content(); } if($GatheringDayNumberBegin) { $sqlGatheringDate .= " " . $GatheringDayNumberBegin[0]->get_content(); } if($GatheringTimeOfDayBegin) { $sqlGatheringDate .= " " . $GatheringTimeOfDayBegin[0]->get_content(); } if($GatheringISODateTimeEnd) { $sqlGatheringDate .= " " . $GatheringISODateTimeEnd[0]->get_content(); } if($GatheringDayNumberEnd) { $sqlGatheringDate .= " " . $GatheringDayNumberEnd[0]->get_content(); } if($GatheringTimeOfDayEnd) { $sqlGatheringDate .= " " . $GatheringTimeOfDayEnd[0]->get_content(); } } } } else { $sqlGatheringDate = ""; } if($GatheringAgents) { foreach ($GatheringAgents as $GatheringAgent) { $PersonName = $GatheringAgent->get_elements_by_tagname('GatheringAgent'); $AgentText = $GatheringAgent->get_elements_by_tagname('GatheringAgentsText'); //if (empty($GatheringAgent) if($PersonName) { $sqlPersonName = addslashes(utf8_decode($PersonName[0]->get_content())); } if($AgentText) { // echo "Person: " . $PersonName[0]->get_content() . "
"; $sqlPersonName = addslashes(utf8_decode($AgentText[0]->get_content())); // echo $AgentText[0]->get_content()."hallo2
"; } } } else {$sqlPersonName = ""; } if($LocalityText) // echo "Locality: " . $LocalityText[0]->get_content() . "
"; { $sqlLocalityText = addslashes(utf8_decode($LocalityText[0]->get_content()));} else {$sqlLocalityText = "";} if($Country) { foreach ($Country as $Countries) { $CountryName = $Countries->get_elements_by_tagname('Name'); $ISO2 = $Countries->get_elements_by_tagname('ISO3166Code'); if($CountryName) { // echo "Country: " . $CountryName[0]->get_content() . "
"; $sqlCountryName = addslashes($CountryName[0]->get_content()); } if($ISO2) { // echo "Country2: " . $Country[0]->get_content() . "
"; // echo "ISO2: " . $ISO2[0]->get_content() . "
"; $sqlISO2 = addslashes($ISO2[0]->get_content()); } } } else {$sqlCountryName = ""; $sqlISO2 = ""; } if(empty($NamedArea)) { $sqlGatheringOther = addslashes($NearNamedPlaces[0]->get_content()); } if($AreaName) {$sqlNamedAreas = addslashes($AreaName[0]->get_content());} 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[0]->get_content()); } // echo $AreaName[0]->get_content();} else { // echo "NamedAreas: " . $NamedAreas[0]->get_content() . "
"; $sqlGatheringOther = addslashes($NamedArea[0]->get_content()); } if($LongitudeDecimal) // echo "Longitude: " . $LongitudeDecimal[0]->get_content() . "
"; {$sqlLongitudeDecimal = $LongitudeDecimal[0]->get_content();} else { $sqlLongitudeDecimal = ""; } if($LatitudeDecimal) // echo "Latitude: " . $LatitudeDecimal[0]->get_content() . "
"; {$sqlLatitudeDecimal = $LatitudeDecimal[0]->get_content();} else { $sqlLatitudeDecimal = "";} // echo "Altitude: " . $Altitude[0]->get_content() . "
"; } //foreach $Gatherings $TypeDesignations = $Unit->get_elements_by_tagname('NomenclaturalTypeDesignation'); foreach ($TypeDesignations as $TypeDesignation) { $TypeStatus = $TypeDesignation->get_elements_by_tagname('TypeStatus'); $sqlTypeStatus = $TypeStatus[0]->get_content(); } $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->get_elements_by_tagname('Identification'); foreach ($Identifications as $IndexIdentification => $Identification) { // more than one Identification possible $NameAuthorYearString = $Identification->get_elements_by_tagname('FullScientificNameString'); // Name, Author, Year $HigherTaxa = $Identification->get_elements_by_tagname('HigherTaxon'); $ScientificNames = $Identification->get_elements_by_tagname('ScientificName'); $Preferred = $Identification->get_elements_by_tagname('PreferredFlag'); if($NameAuthorYearString) // echo "Name All: " . $NameAuthorYearString[0]->get_content() . "
"; { $sqlNameAuthorYearString = addslashes(utf8_decode($NameAuthorYearString[0]->get_content()));} if($Preferred) // echo "Preferred: " . $Preferred[0]->get_content() . "
"; { $sqlPreferredIdentificationFlag = $Preferred[0]->get_content();} foreach ($ScientificNames as $ScientificName) { // $ScientificNamesAtomized = $ScientificName->get_elements_by_tagname('NameAtomised'); // foreach ($ScientificNamesAtomized as $ScientificNameAtomized) { $Bacteria = $ScientificName->get_elements_by_tagname('Bacterial'); $Botany = $ScientificName->get_elements_by_tagname('Botanical'); $Zoology = $ScientificName->get_elements_by_tagname('Zoological'); $Virology = $ScientificName->get_elements_by_tagname('Viral'); if($Bacteria) { foreach ($Bacteria as $Bacterical) { $GenusBac = $Bacterical->get_elements_by_tagname('GenusOrMonomial'); $SubgenusBac = $Bacterical->get_elements_by_tagname('Subgenus'); $SpeciesEpithetBac = $Bacterical->get_elements_by_tagname('SpeciesEpithet'); $SubspeciesEpithetBac = $Bacterical->get_elements_by_tagname('SubspeciesEpithet'); if(!empty($GenusBac)) // echo "Genus: " . $GenusBac[0]->get_content() . "
"; { $sqlGenus = $GenusBac[0]->get_content();} if(!empty($SubgenusBac)) // echo "Subgenus: " . $SubgenusBac[0]->get_content() . "
"; { $sqlSubgenus = $SubgenusBac[0]->get_content(); } if(!empty($SpeciesEpithetBac)) // echo "Spec.Epi: " . $SpeciesEpithetBac[0]->get_content() . "
"; { $sqlFirstEpithet = $SpeciesEpithetBac[0]->get_content(); } if(!empty($SubspeciesEpithetBac)) // echo "SspEpi: " . $SubspeciesEpithetBac[0]->get_content() . "
"; { $sqlSecondEpithet = $SubspeciesEpithetBac[0]->get_content();} if(empty($sqlGenus) and empty($sqlSubgenus) and empty($sqlFirstEpithet) and empty($sqlSubspecies)) { // echo "Bacteria_All: " . $Bacteria[0]->get_content() . "
"; //if (empty -> $GenusBac, $SubgenusBac, $SpeciesEpithetBac, $SubspeciesEpithetBac) $sqlName_All = $Bacteria[0]->get_content(); } } //foreach $Bacteria } //if($Bacteria) if($Botany) { foreach ($Botany as $Botanical) { $GenusBot = $Botanical->get_elements_by_tagname('GenusOrMonomial'); $FirstEpithet = $Botanical->get_elements_by_tagname('FirstEpithet'); $SecondEpithet = $Botanical->get_elements_by_tagname('InfraspecificEpithet'); $Rank = $Botanical->get_elements_by_tagname('Rank'); $HybridFlag = $Botanical->get_elements_by_tagname('HybridFlag'); if(!empty($GenusBot)) // echo "Genus: " . $GenusBot[0]->get_content() . "
"; { $sqlGenus = $GenusBot[0]->get_content(); } if(!empty($FirstEpithet)) // echo "Spec.Epi: " . $FirstEpithet[0]->get_content() . "
"; { $sqlFirstEpithet = $FirstEpithet[0]->get_content(); } if(!empty($Rank)) // echo "Rank: " . $Rank[0]->get_content() . "
"; { $sqlRank = $Rank[0]->get_content(); } if(!empty($SecondEpithet)) // echo "Sec.Epi: " . $SecondEpithet[0]->get_content() . "
"; { $sqlSecondEpithet = $SecondEpithet[0]->get_content(); } if(!empty($HybridFlag)) // echo "Hybrid: " . $HybridFlag[0]->get_content() . "
"; { $sqlHybridFlag = $HybridFlag[0]->get_content(); } if(empty($sqlGenus) and empty($sqlFirstEpithet) and empty($sqlRank) and empty($sqlSecondEpithet)) { // echo "Botany_All: " . $Botany[0]->get_content() . "
"; //if (empty -> $GenusBot, $FirstEpithet, $SecondEpithet, $Rank, $HybridFlag) $sqlName_All = $Botany[0]->get_content(); } } //foreach $Botany } //if($Botany) if($Zoology) { foreach ($Zoology as $Zoological => $Zoo) { $GenusZoo = $Zoo->get_elements_by_tagname('GenusOrMonomial'); $SubgenusZoo = $Zoo->get_elements_by_tagname('Subgenus'); $SpeciesEpithetZoo = $Zoo->get_elements_by_tagname('SpeciesEpithet'); $SubspeciesEpithetZoo = $Zoo->get_elements_by_tagname('SubspeciesEpithet'); if(!empty($GenusZoo)) // echo "Genus: " .$GenusZoo[0]->get_content()."
"; { $sqlGenus = $GenusZoo[0]->get_content(); } if(!empty($SubgenusZoo)) // echo "Subgenus: " . $SubgenusZoo[0]->get_content() . "
"; { $sqlSubgenus = $SubgenusZoo[0]->get_content(); } if(!empty($SpeciesEpithetZoo)) // echo "Spec.Epi: " . $SpeciesEpithetZoo[0]->get_content() . "
"; { $sqlFirstEpithet = $SpeciesEpithetZoo[0]->get_content(); } if(!empty($SubspeciesEpithetZoo)) // echo "SspEpi: " . $SubspeciesEpithetZoo[0]->get_content() . "
"; { $sqlSecondEpithet = $SubspeciesEpithetZoo[0]->get_content();} if($sqlSecondEpithet) { $sqlRank = "ssp."; } if(empty($sqlGenus) and empty($sqlSubgenus) and empty($sqlFirstEpithet) and empty($sqlSecondEpithet)) { // echo "Zoology_All: " . $Zoo[0]->get_content() . "
"; //if (empty -> $GenusZ, $SubgenusZ, $SpeciesEpithetZ, $SubspeciesEpithetZ) $sqlName_All = $Zoology[0]->get_content(); } } //foreach $Zoology } //if($Zoology) if($Virology) { foreach ($Virology as $Viral) { $GenusV = $Viral->get_elements_by_tagname('GenusOrMonomial'); if(!empty($GenusV)) // echo "Genus: " . $GenusV[0]->get_content() . "
"; { $sqlGenus = $GenusV[0]->get_content();} if(empty($sqlGenus)) { // echo "Virology_All: " . $Virology[0]->get_content() . "
"; $sqlName_All = $Virology[0]->get_content(); } } //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->get_elements_by_tagname('HigherTaxonName'); $TaxonRank = $HigherTaxon1->get_elements_by_tagname('HigherTaxonRank'); if(!empty($HigherTaxon)) // echo "Higher Taxon: " .$HigherTaxon[0]->get_content()." (".$TaxonRank[0]->get_content().")
"; { $sqlHigherTaxon = $HigherTaxon[0]->get_content();} if(!empty($TaxonRank)) { $sqlHigherTaxonRank = $TaxonRank[0]->get_content();} $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->get_elements_by_tagname('MultiMediaObject'); foreach ($MultiMediaObjects as $IndexMultiMediaObjects => $MultiMediaObject) { // more than one Identification possible $FileURI = $MultiMediaObject->get_elements_by_tagname('FileURI'); $ProductURI = $MultiMediaObject->get_elements_by_tagname('ProductURI'); if(!empty($FileURI)) {$sqlFileURI = $FileURI[0]->get_content();} if(empty($FileURI) and !empty($ProductURI)) {$sqlFileURI = $ProductURI[0]->get_content(); } $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 ?>