Source for file Save_ABCD1.2.php

Documentation is available at Save_ABCD1.2.php

  1. <?php
  2. /**
  3. * extracting data from original specimen data provider, following ABCD1.2 format, using DOM
  4. * <br/><br/>
  5. @author Gabriele Droege, DNA Bank Network <contact@dnabank-network.org>
  6. @version 2.0
  7. @package Input
  8. @copyright Copyright © 2011 DNA Bank Network http://www.dnabank-network.org<br>The contents of this file are subject to the Mozilla Public License Version 1.1
  9. @filesource
  10. @license http://www.mozilla.org/MPL/ MPL
  11. */
  12. $Datasets $dom->getElementsByTagName('DataSet');
  13.  
  14. foreach ($Datasets as $Dataset{
  15.  
  16.   $SourceInstitutionCode $Dataset->getElementsByTagName('SourceInstitutionCode');
  17.   $SourceName $Dataset->getElementsByTagName('SourceName');
  18.  
  19.  // echo "Source Institution: " . $SourceInstitutionCode->item(0)->nodeValue . "<br>";
  20.  // echo "Source Collection: " . $SourceName->item(0)->nodeValue . "<br>"; 
  21.   $sqlSourceInstitutionCode addslashes($SourceInstitutionCode->item(0)->nodeValue);
  22.   $sqlSourceName addslashes($SourceName->item(0)->nodeValue);
  23.  
  24. $Units $Dataset->getElementsByTagName('Unit');
  25.  
  26. foreach ($Units as $Unit{
  27.  
  28.   $UnitID $Unit->getElementsByTagName('UnitID');
  29.   $GatheringNo $Unit->getElementsByTagName('CollectorsFieldNumber');
  30.   
  31.  // echo "Unit ID: " . $UnitID->item(0)->nodeValue . "<br>";
  32.   $sqlUnitID addslashes($UnitID->item(0)->nodeValue);
  33.   $sqlGatheringNo addslashes($GatheringNo->item(0)->nodeValue);
  34.   
  35. /*----------------------------GATHERING---------------------------------------------------------*/
  36.   
  37.   $Gatherings $Unit->getElementsByTagName('Gathering');
  38.  
  39.   foreach ($Gatherings as $Gathering{
  40.  
  41.     $CollectionDate $Gathering->getElementsByTagName('DateText');
  42.     $GatheringDateText $Gathering->getElementsByTagName('GatheringDateTime');  //if (empty($CollectionDate))
  43.     $GatheringISODateTimeBegin $Gathering->getElementsByTagName('ISODateTimeBegin');
  44.     $GatheringDayNumberBegin $Gathering->getElementsByTagName('DayNumberBegin');
  45.     $GatheringTimeOfDayBegin $Gathering->getElementsByTagName('ISOTimeOfDayBegin');    
  46.     $GatheringISODateTimeEnd $Gathering->getElementsByTagName('ISODateTimeEnd');
  47.     $GatheringDayNumberEnd $Gathering->getElementsByTagName('DayNumberEnd');
  48.     $GatheringTimeOfDayEnd $Gathering->getElementsByTagName('TimeOfDayEnd');
  49.     $GatheringAgents $Gathering->getElementsByTagName('GatheringAgent');
  50.     $GatheringSites $Gathering->getElementsByTagName('GatheringSite');
  51.   
  52.  
  53.     if($GatheringDateText->item(0)->nodeValue != ""{
  54.  //   echo "Date: " . $GatheringDateText->item(0)->nodeValue . "<br>";
  55.     $sqlCollectionDate addslashes($GatheringDateText->item(0)->nodeValue)}
  56.     else $sqlCollectionDate ""}
  57.      
  58.     if($GatheringISODateTimeBegin->item(0)->nodeValue != ""{
  59.     $sqlCollectionDateMin $GatheringISODateTimeBegin->item(0)->nodeValue}
  60.     
  61.     if($GatheringDayNumberBegin->item(0)->nodeValue != ""{
  62.     $sqlCollectionDateMin .= " " $GatheringDayNumberBegin->item(0)->nodeValue}
  63.     
  64.     if($GatheringTimeOfDayBegin->item(0)->nodeValue != ""{
  65.     $sqlCollectionDateMin .= " " $GatheringTimeOfDayBegin->item(0)->nodeValue}
  66.     
  67.     if($GatheringISODateTimeEnd->item(0)->nodeValue != ""{
  68.     $sqlCollectionDateMax " " $GatheringISODateTimeEnd->item(0)->nodeValue}    
  69.     
  70.     if($GatheringDayNumberEnd->item(0)->nodeValue != ""{
  71.     $sqlCollectionDateMax .= " " $GatheringDayNumberEnd->item(0)->nodeValue}    
  72.     
  73.     if($GatheringTimeOfDayEnd->item(0)->nodeValue != ""{
  74.     $sqlCollectionDateMax .= " " $GatheringTimeOfDayEnd->item(0)->nodeValue}    
  75.   
  76.     foreach ($GatheringAgents as $Collectors{
  77.  
  78.       $PersonName $Collectors->getElementsByTagName('PersonName');
  79.       $AgentText $Collectors->getElementsByTagName('AgentText');   //if (empty($Collectors)
  80.       
  81.       if(empty($Collectors)) {
  82.    //     echo "Person2: " . $AgentText->item(0)->nodeValue . "<br>";
  83.         $sqlPersonName addslashes($AgentText->item(0)->nodeValue)}
  84.  
  85.       else {
  86.   //      echo "Person: " . $PersonName->item(0)->nodeValue . "<br>"; 
  87.         $sqlPersonName addslashes($PersonName->item(0)->nodeValue)} }
  88.   
  89.     foreach ($GatheringSites as $GatheringSite{
  90.   
  91.       $Locality $GatheringSite->getElementsByTagName('LocalityText');
  92.       $ContinentOrOcean $GatheringSite->getElementsByTagName('ContinentOrOcean');
  93.       $CountryName $GatheringSite->getElementsByTagName('CountryName');
  94.       $Country $GatheringSite->getElementsByTagName('Country');  //if (empty($CountryName))
  95.       $ISO2 $GatheringSite->getElementsByTagName('ISO2Letter');
  96.       $NamedArea $GatheringSite->getElementsByTagName('NamedArea');  //if (empty($Country))
  97.       $NearNamedPlaces $GatheringSite->getElementsByTagName('NearNamedPlaces');  //if (empty($Country))
  98.       $Longitude $GatheringSite->getElementsByTagName('LongitudeDecimal');
  99.       $Latitude $GatheringSite->getElementsByTagName('LatitudeDecimal');
  100.       $SiteCoordinates $GatheringSite->getElementsByTagName('SiteCoordinates');  //if (empty($Longitude & Latitude))  
  101.       $Altitude $GatheringSite->getElementsByTagName('Altitude');
  102.   
  103.   //    echo "Locality: " . $Locality->item(0)->nodeValue . "<br>"; 
  104.       $sqlLocality addslashes($Locality->item(0)->nodeValue);
  105.   //    echo "Continent: " . $ContinentOrOcean->item(0)->nodeValue . "<br>"; 
  106.       $sqlContinentOrOcean addslashes($ContinentOrOcean->item(0)->nodeValue);
  107.       
  108.  
  109.       if(empty($CountryName)) {
  110.   //      echo "Country2: " . $Country->item(0)->nodeValue . "<br>"; 
  111.         $sqlCountryName addslashes($Country->item(0)->nodeValue)}
  112.         
  113.       else {
  114.  //       echo "Country: " . $CountryName->item(0)->nodeValue . "<br>";
  115.         $sqlCountryName addslashes($CountryName->item(0)->nodeValue)}
  116.       
  117.   //      echo "ISO2: " . $ISO2->item(0)->nodeValue . "<br>";
  118.         $sqlISO2 addslashes($ISO2->item(0)->nodeValue);
  119.       
  120.       if(empty($NamedArea)) {
  121.   //      echo "NearNamedPlaces: " . $NearNamedPlaces->item(0)->nodeValue . "<br>";
  122.         $sqlGatheringOther addslashes($NearNamedPlaces->item(0)->nodeValue);
  123.         }
  124.         
  125.         else {
  126.        if(!empty($GatheringOther)) {
  127.  //       echo "NamedAreas: " . $NamedAreas->item(0)->nodeValue . "<br>";
  128.         $sqlGatheringOther addslashes($NamedAreas->item(0)->nodeValue);
  129.         }      }
  130.       
  131.   //    echo "Longitude: " . $Longitude->item(0)->nodeValue . "<br>";
  132.       $sqlLongitude $Longitude->item(0)->nodeValue;
  133.  //     echo "Latitude: " . $Latitude->item(0)->nodeValue . "<br>";
  134.       $sqlLatitude $Latitude->item(0)->nodeValue;
  135.  //     echo "Coordinates: " . $SiteCoordinates->item(0)->nodeValue . "<br>";
  136.   //    echo "Altitude: " . $Altitude->item(0)->nodeValue . "<br>";
  137.       $sqlAltitude addslashes($Altitude->item(0)->nodeValue);
  138.     // foreach $GatheringSites
  139.   //foreach $Gatherings
  140.  
  141.   
  142. /*----------------------------IDENTIFICATIONS---------------------------------------------------------*/  
  143.   
  144.   $Identifications $Unit->getElementsByTagName('Identification');
  145.   
  146.   foreach ($Identifications as $IndexIdentification => $Identification{     // more than one Identification possible
  147.   
  148. //     $TaxaIdentified = $Identification->getElementsByTagName('TaxonIdentified');
  149.   
  150.    // foreach ($TaxaIdentified as $TaxonIdentified) {
  151.   
  152.      $NameAuthorYearString $Identification->getElementsByTagName('NameAuthorYearString');            // Name, Author, Year
  153.      $ScientificNamesAtomized $Identification->getElementsByTagName('ScientificNameAtomized');
  154.      $HigherTaxa $Identification->getElementsByTagname('HigherTaxon');     
  155.  
  156. //     echo "Name All: " . $NameAuthorYearString->item(0)->nodeValue . "<br>";
  157.      $sqlNameAuthorYearString[addslashes($NameAuthorYearString->item(0)->nodeValue);
  158.  //    echo "Preferred: " . $Identification->getAttribute('PreferredIdentificationFlag') . "<br>";
  159.      $sqlPreferredIdentificationFlag[$Identification->getAttribute('PreferredIdentificationFlag');
  160.  
  161.       foreach ($HigherTaxa as $index => $HigherTaxon// more than one HigherTaxon per Identification possible
  162.        
  163.  //        echo "Higher Taxon: " .$HigherTaxon->nodeValue." (".$HigherTaxon->getAttribute('TaxonRank').")<br>";
  164.          $sqlHigherTaxon[$HigherTaxon->nodeValue;
  165.          $sqlHigherTaxonRank[]  $HigherTaxon->getAttribute('TaxonRank');
  166.  
  167.       //foreach $HugherTaxa
  168.     
  169.      foreach ($ScientificNamesAtomized as $ScientificNameAtomized{
  170.     
  171.       $Bacteria $ScientificNameAtomized->getElementsByTagName('Bacterial');
  172.       $Botany $ScientificNameAtomized->getElementsByTagName('Botanical');
  173.       $Zoology $ScientificNameAtomized->getElementsByTagName('Zoological');   
  174.       $Virology $ScientificNameAtomized->getElementsByTagName('Viral');         
  175.       
  176.  
  177.       if($Bacteria{
  178.  
  179.         foreach ($Bacteria as $Bacterical{
  180.       
  181.          $GenusBac $Bacterical->getElementsByTagName('Genus');
  182.          $SubgenusBac $Bacterical->getElementsByTagName('Subgenus');
  183.          $SpeciesEpithetBac $Bacterical->getElementsByTagName('SpeciesEpithet');
  184.          $SubspeciesEpithetBac $Bacterical->getElementsByTagName('SubspeciesEpithet');
  185.         
  186.   //       echo "Genus: " . $GenusBac->item(0)->nodeValue . "<br>";
  187.          $sqlGenus[$GenusBac->item(0)->nodeValue;
  188.  //        echo "Subgenus: " . $SubgenusBac->item(0)->nodeValue . "<br>";
  189.          $sqlSubgenus[$SubgenusBac->item(0)->nodeValue;         
  190.  //        echo "Spec.Epi: " . $SpeciesEpithetBac->item(0)->nodeValue . "<br>";
  191.          $sqlFirstEpithet[$SpeciesEpithetBac->item(0)->nodeValue;                  
  192.  //        echo "SspEpi: " . $SubspeciesEpithetBac->item(0)->nodeValue . "<br>";
  193.          $sqlSecondEpithet[$SubspeciesEpithetBac->item(0)->nodeValue;
  194.          if(empty($sqlGenusand empty($sqlSubgenusand empty($sqlFirstEpithetand empty($sqlSubspecies))
  195.          {              
  196.  //        echo "Bacteria_All: " . $Bacteria->item(0)->nodeValue . "<br>"; //if (empty -> $GenusBac, $SubgenusBac, $SpeciesEpithetBac, $SubspeciesEpithetBac)      
  197.          $sqlName_All[$Bacteria->item(0)->nodeValue;    }     
  198.  
  199.         //foreach $Bacteria
  200.       //if($Bacteria)
  201.  
  202.       if($Botany{
  203.       
  204.         foreach ($Botany as $Botanical{
  205.         
  206.           $GenusBot $Botanical->getElementsByTagName('Genus');
  207.           $FirstEpithet $Botanical->getElementsByTagName('FirstEpithet');
  208.           $SecondEpithet $Botanical->getElementsByTagName('SecondEpithet');
  209.           $Rank $Botanical->getElementsByTagName('Rank');
  210.           $HybridFlag $Botanical->getElementsByTagName('HybridFlag');
  211.         
  212.   //        echo "Genus: " . $GenusBot->item(0)->nodeValue . "<br>";
  213.           $sqlGenus[$GenusBot->item(0)->nodeValue;         
  214.  //         echo "Spec.Epi: " . $FirstEpithet->item(0)->nodeValue . "<br>";
  215.           $sqlFirstEpithet[$FirstEpithet->item(0)->nodeValue;         
  216.    //       echo "Rank: " . $Rank->item(0)->nodeValue . "<br>";            
  217.           $sqlRank[$Rank->item(0)->nodeValue;                   
  218.   //        echo "Sec.Epi: " . $SecondEpithet->item(0)->nodeValue . "<br>";    
  219.           $sqlSecondEpithet[$SecondEpithet->item(0)->nodeValue;                   
  220.   //        echo "Hybrid: " . $HybridFlag->item(0)->nodeValue . "<br>";
  221.           $sqlHybridFlag[$HybridFlag->item(0)->nodeValue;           
  222.           if(empty($sqlGenusand empty($sqlFirstEpithetand empty($sqlRankand empty($sqlSecondEpithet))
  223.           {        
  224.   //        echo "Botany_All: " . $Botany->item(0)->nodeValue . "<br>"; //if (empty -> $GenusBot, $FirstEpithet, $SecondEpithet, $Rank, $HybridFlag)      
  225.           $sqlName_All[$Botany->item(0)->nodeValue;   }
  226.       
  227.         //foreach $Botany
  228.       //if($Botany)
  229.       
  230.       if($Zoology{
  231.       
  232.         foreach ($Zoology as $Zoological => $Zoo{
  233.       
  234.           $GenusZoo $Zoo->getElementsByTagName('Genus');
  235.           $SubgenusZoo $Zoo->getElementsByTagName('Subgenus');
  236.           $SpeciesEpithetZoo $Zoo->getElementsByTagName('SpeciesEpithet');
  237.           $SubspeciesEpithetZoo $Zoo->getElementsByTagName('SubspeciesEpithet');
  238.  
  239.   //        echo "Genus: " .$GenusZoo->item(0)->nodeValue."<br>"; 
  240.           $sqlGenus[$GenusZoo->item(0)->nodeValue;                   
  241.  //         echo "Subgenus: " . $SubgenusZoo->item(0)->nodeValue . "<br>";
  242.           $sqlSubgenus[$SubgenusZoo->item(0)->nodeValue;         
  243.   //        echo "Spec.Epi: " . $SpeciesEpithetZoo->item(0)->nodeValue . "<br>"; 
  244.           $sqlFirstEpithet[$SpeciesEpithetZoo->item(0)->nodeValue;                   
  245.   //        echo "SspEpi: " . $SubspeciesEpithetZoo->item(0)->nodeValue . "<br>";
  246.           $sqlSecondEpithet[$SubspeciesEpithetZoo->item(0)->nodeValue;
  247.           if($sqlSecondEpithet{
  248.             $sqlRank "ssp."}
  249.           if(empty($sqlGenusand empty($sqlSubgenusand empty($sqlFirstEpithetand empty($sqlSecondEpithet))
  250.             {        
  251.    //         echo "Zoology_All: " . $Zoo->nodeValue . "<br>"; //if (empty -> $GenusZ, $SubgenusZ, $SpeciesEpithetZ, $SubspeciesEpithetZ)      
  252.             $sqlName_All[$Zoology->item(0)->nodeValue}
  253.       
  254.         //foreach $Zoology
  255.       //if($Zoology)
  256.       
  257.       if($Virology)
  258.       {
  259.       
  260.         foreach ($Virology as $Viral{
  261.         
  262.           $GenusV $Viral->getElementsByTagName('Genus');
  263.         
  264.     //      echo "Genus: " . $GenusV->item(0)->nodeValue . "<br>";
  265.           $sqlGenus[$GenusV->item(0)->nodeValue;
  266.           if(empty($sqlGenus)) 
  267.           {              
  268.  //         echo "Virology_All: " . $Virology->item(0)->nodeValue . "<br>";
  269.           $sqlName_All[$Virology->item(0)->nodeValue}
  270.       
  271.         //foreach $Virology
  272.       //if($Virology)
  273.     
  274.     //foreach $ScientificNamesAtomized
  275.     
  276.  // } //foreach $TaxaIdentified
  277.   
  278.   //foreach $Identifications
  279.   
  280. /*----------------------------------------MULTI MEDIA OBJECTS -----------------------------*/
  281.   $MultiMediaObjects $Unit->getElementsByTagName('UnitDigitalImage');
  282.  
  283. foreach ($MultiMediaObjects as $IndexMultiMediaObjects => $MultiMediaObject{     // more than one Identification possible
  284.   
  285.      $FileURI $MultiMediaObject->getElementsByTagName('ImageURI');
  286.      
  287.      $sqlFileURI[$FileURI->item(0)->nodeValue;
  288.  
  289.      
  290.   }   // foreach $MultiMediaObjects
  291.   
  292.   $TypeDesignations $Unit->getElementsByTagName('NomenclaturalTypeDesignation');
  293.   
  294.   foreach ($TypeDesignations as $TypeDesignation{
  295.   
  296.   $TypeStatus $TypeDesignation->getElementsByTagName('TypeStatus');
  297.   $sqlTypeStatus $TypeStatus->item(0)->nodeValue;
  298.   
  299.   }
  300.   
  301. //foreach $Units
  302.  
  303. // foreach $Datasets
  304.  
  305.  
  306. ?>

Documentation generated on Tue, 29 Nov 2011 10:45:06 +0100 by phpDocumentor 1.4.3