function get_species_urls()
 {
     $species_urls = array();
     if ($xml = Functions::get_hashed_response(DUTCH_SPECIES_LIST)) {
         foreach ($xml->id as $id) {
             print "\n {$id}";
             $pos = stripos($id, "/");
             $id = trim(substr($id, $pos + 1, strlen($id)));
             print "\n {$id}";
             $species_urls[] = TAXON_SERVICE . $id;
         }
     } else {
         echo "\n\n Remote XML not available.";
     }
     return $species_urls;
 }
Exemplo n.º 2
0
function fill_up_values($resource_path, $dataObjects)
{
    if ($xml = Functions::get_hashed_response($resource_path, array('download_wait_time' => 1000000, 'timeout' => 600, 'download_attempts' => 5))) {
        foreach ($xml->taxon as $taxon) {
            foreach ($taxon->dataObject as $dataObject) {
                $do_dcterms = $dataObject->children("http://purl.org/dc/terms/");
                $do_dc = $dataObject->children("http://purl.org/dc/elements/1.1/");
                if (@$dataObjects["{$do_dc->identifier}"]) {
                    $do_dcterms->bibliographicCitation = $dataObjects["{$do_dc->identifier}"]['agent'];
                    $dataObject->subject = $dataObjects["{$do_dc->identifier}"]['subject'];
                    $do_dc->description = $dataObjects["{$do_dc->identifier}"]['description'];
                    $do_dc->description->attributes('http://www.w3.org/XML/1998/namespace')->lang = $dataObjects["{$do_dc->identifier}"]['description_lang'];
                }
            }
        }
        return $xml->asXML();
    }
}
 public static function scrape_species_page($url, $ancestry)
 {
     $arr_acknowledgement = self::prepare_acknowledgement();
     $arr_scraped = array();
     $arr_photos = array();
     $arr_sciname = array();
     $ctr = 0;
     print $url . "\n";
     $xml = Functions::get_hashed_response($url);
     print "taxa count = " . count($xml) . "\n";
     foreach ($xml->url as $u) {
         $u_video = $u->children("http://www.google.com/schemas/sitemap-video/1.0");
         if ($url == "http://www.rkwalton.com/nhsskippers_videositemap.xml") {
             $string = $u_video->video->description;
         } else {
             $string = $u_video->video->title;
         }
         $scientific_names = self::get_sciname($string, $url);
         if (!$scientific_names) {
             continue;
         }
         foreach ($scientific_names as $sciname) {
             $exclude = array("Spiders In The Field", "Spiders and jumping Spiders", "Introduction to Solitary Wasps");
             if (in_array($sciname, $exclude)) {
                 continue;
             }
             print "\n" . "[{$sciname}]";
             $acknowledgement = self::get_acknowledgement($sciname, $arr_acknowledgement);
             $description = "{$acknowledgement}<br>" . $u_video->video->description;
             if ($u_video->video->description) {
                 $description .= "<br>Duration: " . $u_video->video->duration . " seconds";
             }
             //object agents
             $agent = array();
             $agent[] = array("role" => "author", "homepage" => "http://www.rkwalton.com", "name" => "Richard K. Walton");
             $arr_photos["{$sciname}"][] = array("identifier" => $u_video->video->content_loc . "_" . str_replace(" ", "_", $sciname), "mediaURL" => str_ireplace(' ', '', $u_video->video->content_loc), "mimeType" => "video/mp4", "dataType" => "http://purl.org/dc/dcmitype/MovingImage", "description" => $description, "title" => $u_video->video->description, "location" => "", "dc_source" => $u->loc, "thumbnailURL" => $u_video->video->thumbnail_loc, "agent" => $agent);
             $arr_sciname[$sciname] = 1;
         }
     }
     foreach (array_keys($arr_sciname) as $sci) {
         $arr_scraped[] = array("id" => $ctr, "kingdom" => $ancestry["kingdom"], "phylum" => $ancestry["phylum"], "class" => $ancestry["class"], "order" => @$ancestry["order"], "family" => @$ancestry["family"], "sciname" => $sci, "dc_source" => $ancestry["taxon_source_url"], "photos" => $arr_photos["{$sci}"]);
     }
     return $arr_scraped;
 }
 private function get_objects_info($id, $scientific_name, $orig_sciname)
 {
     $total_objects = 0;
     $id = str_ireplace("http://www.eol.org/pages/", "", $id);
     $file = self::API_PAGES . $id . self::API_PAGES_PARAMS;
     $text = 0;
     $image = 0;
     if ($xml = Functions::get_hashed_response($file, array('download_wait_time' => 1000000, 'timeout' => 240, 'download_attempts' => 5))) {
         if ($xml->dataObject) {
             foreach ($xml->dataObject as $object) {
                 if ($object->dataType == "http://purl.org/dc/dcmitype/StillImage") {
                     $image++;
                 } elseif ($object->dataType == "http://purl.org/dc/dcmitype/Text") {
                     $text++;
                 }
             }
         }
         $total_objects = $image + $text;
     }
     return array($orig_sciname => 1, "orig_sciname" => $orig_sciname, "tc_id" => $id, "sciname" => $scientific_name, "text" => $text, "image" => $image, "total_objects" => $total_objects);
 }
Exemplo n.º 5
0
 function get_all_taxa($resource_id)
 {
     $xml = Functions::get_hashed_response(CONTENT_RESOURCE_LOCAL_PATH . "35.xml");
     $all_taxa = array();
     $i = 0;
     $total = count($xml->taxon);
     foreach ($xml->taxon as $t) {
         $i++;
         $t_dwc = $t->children("http://rs.tdwg.org/dwc/dwcore/");
         $t_dc = $t->children("http://purl.org/dc/elements/1.1/");
         print "\n {$i} of {$total} " . $t_dc->identifier;
         $url = str_replace('xxx', str_replace('STRI-fish-', '', $t_dc->identifier), $this->map_url);
         print " [{$url}] ";
         if ($file = fopen($url, "r")) {
             if (stripos(fgets($file), "no_website_found")) {
                 print " - no map";
             } else {
                 print " - with map";
                 $taxon_record["taxon"] = array("sciname" => $t_dwc->ScientificName, "family" => $t_dwc->Family, "kingdom" => '', "phylum" => '', "class" => '', "order" => '', "id" => str_replace('STRI-fish-', '', $t_dc->identifier), "mediaURL" => $url, "source" => $this->taxon_page . str_replace('STRI-fish-', '', $t_dc->identifier));
                 $taxon_record["dataobjects"] = array();
                 $arr = self::get_stri_taxa($taxon_record);
                 $page_taxa = $arr[0];
                 if ($page_taxa) {
                     $all_taxa = array_merge($all_taxa, $page_taxa);
                 }
                 unset($page_taxa);
             }
         } else {
             debug(__CLASS__ . ":" . __LINE__ . ": Couldn't open file: " . $url);
         }
     }
     $xml = \SchemaDocument::get_taxon_xml($all_taxa);
     $resource_path = CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml";
     if (!($OUT = fopen($resource_path, "w"))) {
         debug(__CLASS__ . ":" . __LINE__ . ": Couldn't open file: " . $resource_path);
         return;
     }
     fwrite($OUT, $xml);
     fclose($OUT);
 }
Exemplo n.º 6
0
 public static function auth_get_token($frob)
 {
     $url = self::generate_rest_url("flickr.auth.getToken", array("frob" => $frob), 1);
     return Functions::get_hashed_response($url);
 }
Exemplo n.º 7
0
 function get_synonyms($taxon_id)
 {
     $arr_synonyms = array();
     $arr = array();
     $xml = Functions::get_hashed_response(TROPICOS_API_SERVICE . $taxon_id . "/Synonyms?format=xml&apikey=" . TROPICOS_API_KEY, array('timeout' => 4800, 'download_attempts' => 5));
     foreach ($xml->Synonym as $syn) {
         $synonym = trim($syn->SynonymName->ScientificNameWithAuthors);
         $arr[$synonym] = "";
     }
     foreach (array_keys($arr) as $synonym) {
         if ($synonym) {
             $arr_synonyms[] = array("synonym" => $synonym, "relationship" => "synonym");
         }
     }
     return $arr_synonyms;
 }
Exemplo n.º 8
0
 public function get_mediaURL($url)
 {
     if (!($xml = Functions::get_hashed_response($url))) {
         // url not accessible
         return;
     }
     foreach ($xml->Items->I as $rec) {
         $mediaURL = str_ireplace('.dzi', '_files/thumb.jpg', @$rec["Source"]);
     }
     return $mediaURL;
 }
Exemplo n.º 9
0
 function get_id_list()
 {
     $urls = array();
     // $urls[] = DOC_ROOT . "/update_resources/connectors/files/WORMS/2011_small.xml"; //for debug
     $urls[] = DOC_ROOT . "/update_resources/connectors/files/WORMS/2007.xml";
     $urls[] = DOC_ROOT . "/update_resources/connectors/files/WORMS/2008.xml";
     $urls[] = DOC_ROOT . "/update_resources/connectors/files/WORMS/2009.xml";
     $urls[] = DOC_ROOT . "/update_resources/connectors/files/WORMS/2010.xml";
     $urls[] = "http://dl.dropbox.com/u/7597512/WORMS/2011.xml";
     $urls[] = "http://dl.dropbox.com/u/7597512/WORMS/2012.xml";
     //append year (the current year) and onwards
     $urls = self::generate_url_list($urls);
     /* debug
        $r = array();
        $r[] = $urls[0];
        $urls = $r;
        */
     echo "\n URLs = " . sizeof($urls) . "\n";
     print_r($urls);
     $ids = array();
     $file_ctr = 0;
     foreach ($urls as $url) {
         echo "\n Processing: {$url} \n";
         if ($xml = Functions::get_hashed_response($url, array('timeout' => 240, 'download_attempts' => 5))) {
             foreach ($xml->taxdetail as $taxdetail) {
                 $id = @$taxdetail["id"];
                 $ids[] = $id;
             }
         }
         sleep(30);
         //debug orig 30
     }
     //delete temp XML files
     Functions::delete_temp_files($this->TEMP_FILE_PATH . "xmlcontent_", "xml");
     $ids = array_unique($ids);
     echo "\n total ids: " . sizeof($ids);
     echo "\n" . sizeof($urls) . " URLs | taxid count = " . sizeof($ids) . "\n";
     /* debug
        $r = array();
        $r[] = $ids[0];
        $r[] = $ids[1];
        $r[] = $ids[2];
        $r[] = $ids[3];
        $r[] = $ids[4];
        $r[] = $ids[5];
        $r[] = $ids[6];
        $r[] = $ids[7];
        $r[] = $ids[8];
        $r[] = $ids[9];
        $r[] = $ids[10];
        $r[] = $ids[11];
        $r[] = $ids[12];
        $r[] = $ids[13];
        $r[] = $ids[14];
        $r[] = $ids[15];
        $r[] = $ids[16];
        $r[] = $ids[17];
        $r[] = $ids[18];
        $r[] = $ids[19];
        $ids = $r;
        */
     // $ids = array(); $ids[] = 246718;//9182;//243944;
     /*debug: to be used when searching for an id
       foreach(array(582008, 582009, 582010) as $id)
       {
           if(in_array($id, $ids)) echo "\n $id found";
           else echo "\n $id not found";
       }
       */
     return $ids;
 }
Exemplo n.º 10
0
$total_image_ids = count($image_ids);
print "\n count of image ID's = {$total_image_ids}";
if ($total_image_ids == 0) {
    exit("\n Program will terminate. MorphBank service not ready.");
}
/* loop through image ids */
$k = 0;
foreach ($image_ids as $image_id) {
    $k++;
    if ($k % 5000 == 0) {
        sleep(60);
    }
    // might need this as MorphBank service chokes on continues request. They have not yet solved this problem. Service still chokes.
    print "\n {$image_id} [{$k} of {$total_image_ids}]";
    print "\n " . $details_method_prefix . $image_id . " \n";
    if (!($xml = Functions::get_hashed_response($details_method_prefix . $image_id))) {
        continue;
    }
    foreach ($xml->object as $object) {
        if (!$object["type"] == "Image") {
            break;
        }
        $dwc = $object->children("http://rs.tdwg.org/dwc/dwcore/");
        $dwc_Kingdom = trim($dwc->Kingdom);
        $dwc_Phylum = trim($dwc->Phylum);
        $dwc_Class = trim($dwc->Class);
        $dwc_Order = trim($dwc->Order);
        $dwc_Family = trim($dwc->Family);
        $dwc_Genus = trim($dwc->Genus);
        $dwc_ScientificName = trim($dwc->ScientificName);
        $taxon_identifier = str_replace(" ", "_", $dwc_ScientificName);
Exemplo n.º 11
0
 function get_objects_info($id, $sciname, $orig_sciname)
 {
     $sciname_4color = "";
     $total_objects = 0;
     $id = str_ireplace("http://www.eol.org/pages/", "", $id);
     $file = self::API_PAGES . $id . self::API_PAGES_PARAMS;
     $text = 0;
     $image = 0;
     if ($xml = Functions::get_hashed_response($file)) {
         $score = $xml->taxonConcept->additionalInformation->richness_score;
         if ($xml->dataObject) {
             foreach ($xml->dataObject as $object) {
                 if ($object->dataType == "http://purl.org/dc/dcmitype/StillImage") {
                     $image++;
                 } elseif ($object->dataType == "http://purl.org/dc/dcmitype/Text") {
                     $text++;
                 }
             }
         }
         $total_objects = $image + $text;
     }
     if ($orig_sciname != $sciname_4color) {
         $sciname_4color = $sciname;
     }
     return array($orig_sciname => 1, "orig_sciname" => $orig_sciname, "tc_id" => $id, "sciname" => $sciname, "text" => $text, "image" => $image, "total_objects" => $total_objects, "score" => $score, "last_curated" => '', "overview_word_count" => self::get_word_count($id, "brief summary"), "general_description_word_count" => self::get_word_count($id, "comprehensive description"));
 }
Exemplo n.º 12
0
 public static function get_inotaxa_taxa($url, $debug = NULL)
 {
     global $taxon_identifier;
     global $taxon_parameters;
     global $used_taxa;
     global $taxon;
     global $rightsHolder;
     /*
     TaxonomicPublication
         IndividualPublication
             Metadata
             PublicationFrontMatter
             PublicationTaxonomicMatter  Heading="none"
                 TaxonTreatment
                     TreatmentAuthors
                         TreatmentAuthorAtomised
                     TreatmentDate
                     TaxonHeading
                         RankDesignation
                         TaxonHeadingName
                             AlternateUsedInWork
                                 TaxonName
                                 GenusName
                     TaxonCitationGroup
                     Descriptions
                     DistributionAndOrSpecimenCitations
                     Discussions
             PublicationTaxonomicMatter  Heading="Supplement"
             PublicationBackMatter
             OtherNamesIndex
     */
     $schema_taxa = array();
     ///////////////////////////////
     $used_taxa = array();
     /*  If this is outside the main loop then, data objects from a single species
             coming from 2 INOTAXA providers will be placed in 1 <taxon> element.        
             If this is inside the loop then, there will be 2 <taxon> elements for 2 same species from 2 BCA providers.
         */
     ///////////////////////////////
     $xml = Functions::get_hashed_response($url);
     if (!($xml = Functions::get_hashed_response($url))) {
         print "\n <a href='{$url}'>{$url}</a> not accessible";
         return;
     }
     $i = 0;
     $sciname = array();
     //just for debugging
     $hierarchy = array();
     $rightsHolder = trim(strip_tags($xml->IndividualPublication->PublicationFrontMatter->SeriesTitle->Title->asXML()));
     $main_count = 0;
     foreach ($xml->IndividualPublication as $main) {
         $main_count++;
         //print"<pre>";print_r($main);print"</pre>";
         $ptm_count = 0;
         foreach ($main->PublicationTaxonomicMatter as $ptm) {
             $ptm_count++;
             $tt_count = 0;
             foreach ($ptm->TaxonTreatment as $tt) {
                 $tt_count++;
                 //print"\n $main_count of " . count($xml->IndividualPublication);
                 //print" | $ptm_count of " . count($main->PublicationTaxonomicMatter);
                 //print" | $tt_count of " . count($ptm->TaxonTreatment);
                 $taxon_identifier = @$tt["TaxonID"];
                 $dwc_ScientificName = trim($tt->TaxonHeading->TaxonHeadingName->AlternateUsedInWork->TaxonName);
                 if ($debug) {
                     if (in_array($dwc_ScientificName, array("Attelabus ater"))) {
                     } else {
                         continue;
                     }
                     /*  
                         Thecesternus affinis - Context in original:
                         Thecesternus humeralis - separate or put citation
                     */
                     /*
                     if(in_array($dwc_ScientificName, array( "Thecesternus humeralis",
                                                             "Ophryastes ovipennis",
                                                             "Anypotactus",
                                                             "Ophryastes bituberosus",
                                                             "Aphrastus angularis",
                                                             "Attelabus ater"
                                                             ))){}                    
                     else continue;                                                                                
                     */
                     //debug
                 }
                 $rank = $tt->TaxonHeading->RankDesignation;
                 $i++;
                 $sciname["{$dwc_ScientificName}"] = $dwc_ScientificName;
                 $taxon = str_replace(" ", "_", $dwc_ScientificName);
                 if (@$used_taxa[$taxon]) {
                     $taxon_parameters = $used_taxa[$taxon];
                 } else {
                     $taxon_parameters = array();
                     //start get hierarchy
                     foreach ($tt->TaxonHierarchyAbove as $tha) {
                         $ranks = array("kingdom", "phylum", "class", "order", "family", "genus");
                         $rank = $tha->RankDesignation;
                         if (in_array($rank, $ranks)) {
                             $taxon_parameters["{$rank}"] = $tha->TaxonHeadingName->AlternateUsedInWork->TaxonName;
                             $hierarchy["{$rank}"] = $tha->TaxonHeadingName->AlternateUsedInWork->TaxonName;
                         }
                     }
                     if ($hierarchy) {
                         $arr = array_keys($hierarchy);
                         foreach ($arr as $rank) {
                             $taxon_parameters["{$rank}"] = $hierarchy["{$rank}"];
                         }
                     }
                     //end get hierarchy
                     $main_citation = "";
                     if (isset($xml->IndividualPublication->Metadata->FullBibliographicCitation)) {
                         $main_citation = $xml->IndividualPublication->Metadata->FullBibliographicCitation;
                     }
                     $taxon_parameters["identifier"] = $taxon_identifier;
                     $taxon_parameters["scientificName"] = $dwc_ScientificName;
                     $taxon_parameters["source"] = SOURCE_URL_PREFIX . $taxon_identifier;
                     if ($main_citation) {
                         $taxon_parameters["references"] = array();
                         $referenceParameters = array();
                         $referenceParameters["fullReference"] = trim($main_citation);
                         $references = array();
                         $references[] = new \SchemaReference($referenceParameters);
                         $taxon_parameters["references"] = $references;
                     }
                     $taxon_parameters["dataObjects"] = array();
                     $ref = "";
                     if (isset($tt->TaxonCitationGroup->AcceptedOrValidTaxonName->AcceptedOrValidTaxonNameParagraph)) {
                         foreach ($tt->TaxonCitationGroup->AcceptedOrValidTaxonName->AcceptedOrValidTaxonNameParagraph as $aovtp) {
                             $ref = strip_tags($aovtp->asXML());
                         }
                     }
                     $used_taxa[$taxon] = $taxon_parameters;
                 }
                 /*
                 <Descriptions>
                     <SameLanguageDiagnosis>
                         <SameLanguageDiagnosisParagraph Display="true" Explicit="true" ElementID="BCA-coleoptv4p3-4435">
                             Convex, black; variegated above with a dense clothing of light and dark brown scales, the dark brown scales on the elytra condensed into a transverse or curved mark below the base, extending forward along the third interstice to the anterior margin, an angulate median fascia (not reaching the suture), and a small triangular patch on the disc towards the apex, the scales along the exposed basal margin of the head, at the base of the femora above, and on the under surface paler or whitish; the elytra also thickly set with long, stiff, erect setæ, and the rest of the surface with short setiform scales. Head and rostrum finely canaliculate, the rostrum hollowed towards the apex; joint 2 of the funiculus nearly twice as long as 1. Prothorax much broader than long, rounded at the sides, in the ? not narrower at the apex than at the base, densely, finely punctate. Elytra oval, convex, rather short, constricted immediately below the base, 
                             <pb id="BCA-coleoptv4p3-p339" Explicit="true"/>
                             the base itself not or very little wider than that of the prothorax; coarsely punctate-striate (when seen abraded), the interstices feebly convex.
                         </SameLanguageDiagnosisParagraph>
                         <SameLanguageDiagnosisParagraph Display="true" Explicit="true" ElementID="BCA-coleoptv4p3-4436">
                             Length 4½—5½, breadth 2 1/10—2½ millim. (? ?.)
                         </SameLanguageDiagnosisParagraph>
                     </SameLanguageDiagnosis>
                 </Descriptions>
                 <Discussions>
                     <DiscussionBody Display="true">
                         <DiscussionParagraph KindOfDiscussion="general" Explicit="true" ElementID="BCA-coleoptv4p3-4438">Five specimens.
                         </DiscussionParagraph>
                     </DiscussionBody>
                 </Discussions>                    
                 */
                 if (isset($tt->Descriptions->SameLanguageDescription->SameLanguageDescriptionBody->SameLanguageDescriptionParagraph)) {
                     /* this is for Hamilton XML */
                     $title = "Description";
                     $arr = $tt->Descriptions->SameLanguageDescription->SameLanguageDescriptionBody->SameLanguageDescriptionParagraph;
                     $temp = self::process_dataobjects($arr, 1, $ref, $title, $tt);
                 }
                 /*
                 <Descriptions>
                     <LatinDiagnosis>
                         <LatinDiagnosisParagraph Display="true" Explicit="true" ElementID="BCA-coleoptv4p3-2374">
                             Sat robustus, piceus, parce setoso-squamosus, setis crassiusculis brevibus vestitus; antennis tarsisque rufis; prothorace rugoso, elytris fortiter seriatim punctatis.
                         </LatinDiagnosisParagraph>
                         <LatinDiagnosisParagraph Display="true" Explicit="true" ElementID="BCA-coleoptv4p3-2375">
                             Long. 5½ millim.
                         </LatinDiagnosisParagraph>
                     </LatinDiagnosis>
                 </Descriptions>                    
                 
                 <DistributionAndOrSpecimenCitations>
                     <DistributionAndOrSpecimenParagraph Display="true" Explicit="true" ElementID="BCA-coleoptv4p3-62">
                         <hi rend="italic">Hab.</hi>
                         MEXICO, Omilteme in Guerrero 8000 feet (
                         <hi rend="italic">H. H. Smith</hi>
                         ).
                     </DistributionAndOrSpecimenParagraph>        
                 */
                 //start the new one
                 if (isset($tt->Descriptions->LatinDiagnosis->LatinDiagnosisParagraph)) {
                     $title = "Latin Diagnosis";
                     $arr = $tt->Descriptions->LatinDiagnosis->LatinDiagnosisParagraph;
                     $temp = self::process_dataobjects($arr, 1, $ref, $title, $tt);
                 }
                 if (is_numeric(stripos($dwc_ScientificName, " "))) {
                     if (isset($tt->NomenclaturalType->NomenclaturalTypeParagraph)) {
                         //$title = "Habitat";
                         $title = "Distribution";
                         $arr = $tt->NomenclaturalType->NomenclaturalTypeParagraph;
                         $temp = self::process_dataobjects($arr, 1, $ref, $title, $tt);
                     }
                 }
                 if (isset($tt->Descriptions->SameLanguageDiagnosis->SameLanguageDiagnosisParagraph)) {
                     $title = "Description";
                     $arr = $tt->Descriptions->SameLanguageDiagnosis->SameLanguageDiagnosisParagraph;
                     $temp = self::process_dataobjects($arr, 1, $ref, $title, $tt);
                 }
                 //end the new one
                 if (isset($tt->DistributionAndOrSpecimenCitations->DistributionAndOrSpecimenParagraph)) {
                     $arr = $tt->DistributionAndOrSpecimenCitations->DistributionAndOrSpecimenParagraph;
                     $str = $arr->asXML();
                     $str = trim(strip_tags($str));
                     if (substr($str, 0, 4) == "Hab.") {
                         $title = "Distribution";
                     } else {
                         $title = "Distribution";
                     }
                     //$title = "Specimen Citations";
                     $temp = self::process_dataobjects($arr, 1, $ref, $title, $tt);
                 }
                 if (isset($tt->Discussions->DiscussionBody->DiscussionParagraph)) {
                     $title = "Discussion";
                     $arr = $tt->Discussions->DiscussionBody->DiscussionParagraph;
                     $temp = self::process_dataobjects($arr, 1, $ref, $title, $tt);
                 }
                 /*
                 <NomenclaturalType>
                     <NameTypified Explicit="false" NameID="BCA-coleoptv4p3-t687"/>
                     <NomenclaturalTypeParagraph Display="true" Explicit="true" ElementID="BCA-coleoptv4p3-3746">
                         <hi rend="italic">Hab.</hi>
                         MEXICO
                         <ref target="BCA-coleoptv4p3-t687-x1">¹</ref>
                          (
                         <hi rend="italic">coll. Solari, ex Jekel</hi>
                         ), Panistlahuaca in Oaxaca (
                         <hi rend="italic">Sallé</hi>
                         ).
                     </NomenclaturalTypeParagraph>
                 */
                 //start image dataobject
                 if (isset($tt->TaxonHeading->TaxonHeadingParagraph->ref)) {
                     $arr = $tt->TaxonHeading->TaxonHeadingParagraph->ref;
                     $temp = self::process_dataobjects($arr, 2, "", "", array());
                 }
                 //end image dataobject
             }
         }
     }
     // end loop through
     foreach ($used_taxa as $taxon_parameters) {
         $schema_taxa[] = new \SchemaTaxon($taxon_parameters);
     }
     return $schema_taxa;
 }
Exemplo n.º 13
0
 function get_taxon_details($id)
 {
     $languages = array("en" => self::ENGLISH_DIR, "nl" => self::DUTCH_DIR);
     $description = "";
     $title = "";
     $identifier = "";
     $mediaURL = "";
     $mimeType = "";
     $rightsHolder = "";
     $source = "";
     $texts = array();
     $objects = array();
     $text_rightsHolder = "";
     foreach ($languages as $language => $dir) {
         debug("\n {$language} - {$dir} \n");
         if ($language == "nl") {
             if (substr($description, strlen($description) - 2, 2) == ". ") {
                 $description = substr($description, 0, strlen($description) - 2) . "; ";
             }
             if (substr($title, strlen($title) - 2, 2) == ". ") {
                 $title = substr($title, 0, strlen($title) - 2) . "; ";
             }
         }
         $xml_file = self::ECOMARE_SOURCE_DIR . "/{$dir}/" . $id . ".xml";
         debug("\n Accessing: {$xml_file} \n");
         if ($xml = Functions::get_hashed_response($xml_file, array('download_wait_time' => 1000000, 'timeout' => 600, 'download_attempts' => 2, 'delay_in_minutes' => 2))) {
             debug(" - OK ");
             foreach ($xml->content_item as $item) {
                 if ($item->type == 9) {
                     $source_url = str_ireplace("L=0", "L=2", $xml->subject_setup->source_url);
                     if (trim($item->file_name) != "") {
                         $description .= $item->image_description != '' ? "" . $item->image_description . ". " : '';
                         $title .= $item->header != '' ? "" . $item->header . ". " : '';
                         $identifier = "img_" . $item->uid;
                         $mediaURL = self::ECOMARE_DOMAIN . $item->file_path . $item->file_name;
                         $mimeType = Functions::get_mimetype($item->file_name);
                         $rightsHolder = $item->image_copyright;
                         $source = $source_url;
                     }
                     if (!in_array($item->bodytext, $texts)) {
                         $objects[] = array("identifier" => $item->uid, "mediaURL" => '', "mimeType" => 'text/html', "dataType" => 'http://purl.org/dc/dcmitype/Text', "rightsHolder" => '', "title" => '', "description" => strip_tags($item->bodytext), "source" => $source_url, "license" => "http://creativecommons.org/licenses/by-nc/3.0/", "subject" => "http://rs.tdwg.org/ontology/voc/SPMInfoItems#TaxonBiology", "language" => $language);
                         $texts[] = $item->bodytext;
                     }
                 } elseif ($item->type == 10) {
                     $text_rightsHolder = strip_tags($item->bodytext);
                 }
             }
         }
     }
     // language loop
     $objects[] = array("identifier" => $identifier, "mediaURL" => $mediaURL, "mimeType" => $mimeType, "dataType" => 'http://purl.org/dc/dcmitype/StillImage', "rightsHolder" => $rightsHolder, "title" => $title, "description" => strip_tags($description), "source" => $source, "license" => "http://creativecommons.org/licenses/by-nc/3.0/", "subject" => "", "language" => "en");
     $i = 0;
     foreach ($objects as $object) {
         if ($object["mimeType"] == 'text/html') {
             $objects[$i]["rightsHolder"] = $text_rightsHolder;
         }
         $i++;
     }
     return $objects;
 }
Exemplo n.º 14
0
function get_main_id_list()
{
    $urls[] = "http://www.habitas.org.uk/marinelife/specieslist_xml.asp";
    print "\n URLs = " . sizeof($urls) . "\n";
    $no_of_urls = sizeof($urls);
    $arr = array();
    foreach ($urls as $url) {
        $j = 0;
        if ($xml = Functions::get_hashed_response($url)) {
            foreach ($xml->id as $source_url) {
                print "\n --> " . $source_url;
                @($arr["{$source_url}"] = true);
                $j++;
            }
            print "\n";
        }
        print "\n" . " no. of urls: " . $no_of_urls . " URLs | taxid count = " . $j . "\n";
    }
    print " \n";
    $arr = array_keys($arr);
    return $arr;
}
Exemplo n.º 15
0
 public function get_upload_videos_from_usernames($usernames)
 {
     $max_results = 50;
     $user_video_ids = array();
     foreach ($usernames as $username) {
         debug("\n Getting video list for {$username}...");
         $start_index = 1;
         while (true) {
             $url = YOUTUBE_API . "/users/" . $username . "/uploads?" . "start-index={$start_index}&max-results={$max_results}";
             if ($xml = Functions::get_hashed_response($url, array('download_wait_time' => 3000000, 'timeout' => 240, 'download_attempts' => 2, 'delay_in_minutes' => 5))) {
                 if ($xml->entry) {
                     foreach ($xml->entry as $entry) {
                         $user_video_pathinfo = pathinfo($entry->id);
                         $user_video_ids[$username][] = $user_video_pathinfo['basename'];
                     }
                 } else {
                     break;
                 }
                 $start_index += $max_results;
             } else {
                 break;
             }
         }
     }
     return $user_video_ids;
 }