private function get_images($records) { foreach ($records as $rec) { /* not used [http://purl.org/dc/terms/format] => jpeg [http://purl.org/dc/terms/audience] => experts, general public */ $mr = new \eol_schema\MediaResource(); $mr->taxonID = $rec["http://rs.tdwg.org/dwc/terms/taxonID"]; $mr->identifier = $rec["http://purl.org/dc/terms/identifier"]; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->title = (string) @$rec["http://purl.org/dc/terms/title"]; $mr->description = (string) @$rec["http://purl.org/dc/terms/description"]; $mr->accessURI = $rec["http://purl.org/dc/terms/identifier"]; if ($val = Functions::get_mimetype($mr->accessURI)) { $mr->format = $val; } else { continue; } if ($val = self::get_license(@$rec["http://purl.org/dc/terms/license"])) { $mr->UsageTerms = $val; } else { continue; } $mr->creator = (string) @$rec["http://purl.org/dc/terms/creator"]; $mr->publisher = (string) @$rec["http://purl.org/dc/terms/publisher"]; // $mr->subtype = (string) $rec["http://rs.tdwg.org/audubon_core/subtype"]; // $mr->Rating = (string) $rec["http://ns.adobe.com/xap/1.0/Rating"]; // $mr->audience = (string) $rec["http://purl.org/dc/terms/audience"]; // $mr->language = (string) $rec["http://purl.org/dc/terms/language"]; // $mr->CVterm = (string) $rec["http://iptc.org/std/Iptc4xmpExt/1.0/xmlns/CVterm"]; // $mr->CreateDate = (string) $rec["http://ns.adobe.com/xap/1.0/CreateDate"]; // $mr->modified = (string) $rec["http://purl.org/dc/terms/modified"]; // $mr->Owner = (string) $rec["http://ns.adobe.com/xap/1.0/rights/Owner"]; // $mr->rights = (string) $rec["http://purl.org/dc/terms/rights"]; // $mr->bibliographicCitation = (string) $rec["http://purl.org/dc/terms/bibliographicCitation"]; // $mr->derivedFrom = (string) $rec["http://rs.tdwg.org/ac/terms/derivedFrom"]; // $mr->LocationCreated = (string) $rec["http://iptc.org/std/Iptc4xmpExt/1.0/xmlns/LocationCreated"]; // $mr->spatial = (string) $rec["http://purl.org/dc/terms/spatial"]; // $mr->lat = (string) $rec["http://www.w3.org/2003/01/geo/wgs84_pos#lat"]; // $mr->long = (string) $rec["http://www.w3.org/2003/01/geo/wgs84_pos#long"]; // $mr->alt = (string) $rec["http://www.w3.org/2003/01/geo/wgs84_pos#alt"]; // $mr->contributor = (string) $rec["http://purl.org/dc/terms/contributor"]; // if($agentID = (string) $rec["http://eol.org/schema/agent/agentID"]) // { // $ids = explode(",", $agentID); // not sure yet what separator Worms used, comma or semicolon - or if there are any // $agent_ids = array(); // foreach($ids as $id) $agent_ids[] = $id; // $mr->agentID = implode("; ", $agent_ids); // } // if($referenceID = self::prepare_reference((string) $rec["http://eol.org/schema/reference/referenceID"])) $mr->referenceID = $referenceID; // $mr->thumbnailURL = (string) $rec["http://eol.org/schema/media/thumbnailURL"]; // if($source = (string) $rec["http://rs.tdwg.org/ac/terms/furtherInformationURL"]) $mr->furtherInformationURL = $source; if (!isset($this->object_ids[$mr->identifier])) { $this->object_ids[$mr->identifier] = ''; $this->archive_builder->write_object_to_file($mr); } } }
private function create_images($description, $taxon_id, $media_id, $media_url, $source_url) { if (in_array($media_id, $this->media_ids)) { return; } $this->media_ids[] = $media_id; $mr = new \eol_schema\MediaResource(); if ($val = $this->agent_id) { $mr->agentID = implode("; ", $val); } $mr->taxonID = $taxon_id; $mr->identifier = $media_id; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->language = 'en'; $mr->format = Functions::get_mimetype($media_url); $mr->CVterm = ""; $mr->rights = ""; $mr->Owner = "Chaloklum Diving"; $mr->title = ""; $mr->UsageTerms = "http://creativecommons.org/licenses/by/3.0/"; $mr->description = $description; $mr->accessURI = $media_url; $mr->furtherInformationURL = $source_url; $this->archive_builder->write_object_to_file($mr); }
private function get_images($sciname, $description, $taxon_id, $media_id, $media_url, $source_url, $reference_ids, $agent_ids) { /* this has to be done because there are many maps written in html as jpg but are actually gif. in the site these maps are not showing, meaning typo in html. since there is only a handful of jpg maps, i set all maps to gif */ $jpeg_maps = array("343dm.jpg", "341dm.jpg", "484ddm.jpg", "535dm2.jpg", "172ms.jpg", "202md.jpg"); $parts = pathinfo($media_url); if (!in_array($parts["basename"], $jpeg_maps)) { $media_url = str_ireplace(".jpg", ".gif", $media_url); } if (in_array($media_id, $this->media_ids)) { return; } $this->media_ids[] = $media_id; $mr = new \eol_schema\MediaResource(); if ($reference_ids) { $mr->referenceID = implode("; ", $reference_ids); } if ($agent_ids) { $mr->agentID = implode("; ", $agent_ids); } $mr->taxonID = (string) $taxon_id; $mr->identifier = (string) $media_id; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->language = 'en'; $mr->format = Functions::get_mimetype($media_url); $mr->furtherInformationURL = $source_url; $mr->CVterm = ""; $mr->Owner = ""; $mr->rights = ""; $mr->title = "Distribution of {$sciname} in North America north of Mexico"; $mr->UsageTerms = "http://creativecommons.org/licenses/by-nc/3.0/"; $mr->audience = 'Everyone'; $description = str_ireplace("available on this site", "available on the Singing Insects of North America site", $description); $mr->description = $description; $mr->subtype = "Map"; $mr->accessURI = (string) trim($media_url); $this->archive_builder->write_object_to_file($mr); }
private function get_images($rec, $reference_ids = null, $agent_ids = null) { /* <specimen_multimedia> <media> <mediaID>1203947</mediaID> <image_link>http://www.boldsystems.org/pics/_w300/BLPDT/10-SRNP-108212_DHJ653087+1309969002.jpg</image_link> <photographer>Daniel H. Janzen</photographer> <licensing> <license>CreativeCommons - Attribution Non-Commercial Share-Alike</license> <licenseholder>Daniel H. Janzen</licenseholder> <licenseholder_institution>Guanacaste Dry Forest Conservation Fund</licenseholder_institution> <year>2010</year> </licensing> </media> </specimen_multimedia> */ if (!@$rec->specimen_multimedia) { return; } $count = 0; foreach (@$rec->specimen_multimedia->media as $media) { if (trim(@$media->image_link) != "" && !is_numeric(stripos($media->licensing->license, "No Derivatives"))) { $SampleID = trim($rec->specimen_identifiers->sampleid); $ProcessID = trim($rec->processid); $Orientation = trim($media->caption); // start checking if image already exists from first/original images resource $old_id = $SampleID . "_" . $ProcessID . "_" . $Orientation; if (in_array($old_id, $this->old_bolds_image_ids)) { echo "\n [{$old_id}] Found an old ID, will ignore \n"; $this->old_bolds_image_ids_count++; continue; } // end - $taxon_id = trim($rec->taxon_id); if (@$this->info[$taxon_id]) { if ($this->info[$taxon_id] == $this->max_images_per_taxon) { echo " --- max {$this->max_images_per_taxon} images reached for [{$taxon_id}][{$rec->sciname}] -- "; break; } $this->info[$taxon_id]++; } else { $this->info[$taxon_id] = 1; } $description = ""; if (@$rec->specimen_identifiers->sampleid) { $description .= "Sample ID = " . $SampleID . "<br>"; } if (@$rec->processid) { $description .= "Process ID = " . $ProcessID . "<br>"; } if (@$media->caption) { $description .= "Caption = " . $Orientation . "<br>"; } $rights = ""; if (@$media->licensing->year) { $rights = "Copyright " . $media->licensing->year; } $rightsHolder = ""; if (@$media->licensing->licenseholder) { $rightsHolder = $media->licensing->licenseholder; } if (@$media->licensing->licenseholder_institution) { $rightsHolder .= ". " . $media->licensing->licenseholder_institution . "."; } $agent_ids = self::get_object_agents($media); $mediaID = trim($media->mediaID); $license = self::get_license($media->licensing->license); if (trim($rec->taxon_id) != "" && $mediaID != "" && $license && Functions::get_mimetype($media->image_link) != "") { if (in_array($mediaID, $this->do_ids)) { echo "\n it should not pass here, just in case... \n"; continue; } else { $this->do_ids[] = $mediaID; } $mr = new \eol_schema\MediaResource(); if ($reference_ids) { $mr->referenceID = implode("; ", $reference_ids); } if ($agent_ids) { $mr->agentID = implode("; ", $agent_ids); } $mr->taxonID = (string) $rec->taxon_id; $mr->identifier = (string) $mediaID; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->language = 'en'; $mr->format = (string) Functions::get_mimetype($media->image_link); $mr->furtherInformationURL = (string) $this->sourceURL . $rec->taxon_id; $mr->description = (string) $description; $mr->UsageTerms = (string) $license; $mr->Owner = (string) $rightsHolder; $mr->rights = (string) $rights; $mr->accessURI = (string) $media->image_link; $mr->Rating = 2; $this->archive_builder->write_object_to_file($mr); } } } }
private function get_images($taxon_id, $rec, $reference_ids = null, $agent_ids = null) { if (!$rec->Filename) { return; } $exclude = array("Animals_Birds_00787.jpg", "Animals_Crustaceans_00008.jpg", "Management_ParksProtectedAreas_OtherProtections_00026.jpg"); if (in_array($rec->Filename, $exclude)) { return; } $mediaURL = trim($this->eol_defined_image_path . $rec->Filename); $description = ""; if ($rec->navigationalCategoryHierarchy) { $description .= "<br>Category hierarchy: " . str_replace("|", " | ", $rec->navigationalCategoryHierarchy); } if ($rec->description) { $description .= "<br>Description: " . $rec->description; } if ($rec->captureDevice) { $description .= "<br>Capture device: " . $rec->captureDevice; } if ($rec->captureDetails) { $description .= "<br>Capture details: " . $rec->captureDetails; } if ($rec->dateOriginal) { if (stripos($rec->dateOriginal, "null") === false) { $description .= "<br>Original date: " . $rec->dateOriginal; } } $locality = ""; if ($rec->Geo_latitude) { $locality .= "Latitude: " . $rec->Geo_latitude; } if ($rec->Geo_longitude) { $locality .= "; Longitude: " . $rec->Geo_longitude; } if ($locality) { $description .= "<br><br>Locality: " . $locality; } if ($life_stage = self::get_lifestage($rec)) { $description .= "<br><br>Life stage: " . $life_stage; } // if($related_media = self::get_related_media($rec)) $description .= "<br><br>Related media: " . $related_media; $location_created = ""; if ($rec->Geo_description) { $location_created .= "Locality: " . $rec->Geo_description . ". "; } if ($rec->Geo_subprovince) { $location_created .= "Sub-province: " . $rec->Geo_subprovince . ". "; } if ($rec->Geo_stateProvince) { $location_created .= "State Province: " . $rec->Geo_stateProvince . ". "; } if ($rec->Geo_country) { $location_created .= "Country: " . $rec->Geo_country . ". "; } if ($rec->Geo_continentOcean) { $location_created .= "Continent Ocean: " . $rec->Geo_continentOcean . ". "; } $mr = new \eol_schema\MediaResource(); if ($reference_ids) { $mr->referenceID = implode("; ", $reference_ids); } if ($agent_ids) { $mr->agentID = implode("; ", $agent_ids); } $mr->taxonID = (string) $taxon_id; $mr->identifier = (string) $rec->Filename; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->language = 'en'; $mr->format = Functions::get_mimetype($mediaURL); if ($mr->format != "image/jpeg") { echo "\n investigate: not jpg: {$mediaURL} [{$mr->format}] \n"; } $mr->title = (string) $rec->title; $mr->CreateDate = (string) $rec->dateOriginal; $mr->CVterm = ""; // $mr->rights = ""; $info = self::process_credit_line((string) $rec->creditLine); $mr->Owner = $info["creditLine"]; $mr->UsageTerms = $info["license"]; $mr->audience = 'Everyone'; $mr->description = (string) $description; $mr->LocationCreated = (string) $location_created; $mr->accessURI = $mediaURL; // for stats if (stripos($rec->originalFileName, "(c)") !== false) { $this->copyrighted++; } $resourceid = (string) $rec->resourceid; if (!in_array($resourceid, $this->resourceids)) { $this->resourceids[] = $resourceid; } else { return; } if (!in_array($mr->identifier, $this->object_ids)) { $this->object_ids[] = $mr->identifier; $this->archive_builder->write_object_to_file($mr); // for stats $archiveName = (string) $rec->archiveName; if ($archiveName) { $this->debug_archives[$archiveName][] = (string) $rec->Filename; } } }
private function create_image_objects($records) { foreach ($records as $rec) { if (!$rec->url_foto) { continue; } $rec->especie = self::clean_name($rec->especie); $taxon_id = strtolower(str_replace(" ", "_", $rec->especie)); $mr = new \eol_schema\MediaResource(); $mr->taxonID = $taxon_id; $mr->identifier = md5($rec->url_foto); $mr->type = 'http://purl.org/dc/dcmitype/StillImage'; $mr->language = 'es'; $mr->format = Functions::get_mimetype($rec->url_foto); $mr->furtherInformationURL = "http://www.acguanacaste.ac.cr/biodiversidad/voucher.php?voucher=" . $rec->voucher; $mr->accessURI = $rec->url_foto; $mr->thumbnailURL = $rec->url_thumb; $mr->Owner = 'Guanacaste Conservation Area'; $mr->rights = ''; $mr->title = ''; $mr->UsageTerms = 'http://creativecommons.org/licenses/by-nc-sa/3.0/'; $mr->description = self::get_description($rec); $mr->LocationCreated = self::get_location($rec); if ($agent_ids = self::get_agent_ids($rec->autor)) { $mr->agentID = implode("; ", $agent_ids); } if (!isset($this->object_ids[$mr->identifier])) { $this->object_ids[$mr->identifier] = ''; $this->archive_builder->write_object_to_file($mr); } } }
private function prepare_images($taxon, $images) { $reference_ids = array(); $ref_ids = array(); $agent_ids = array(); foreach ($images as $rec) { echo "\n - " . $taxon . " - " . $rec['url']; $media_url = $rec["image"]; echo "\n media url: " . $media_url . "\n\n"; $path_parts = pathinfo($rec["image"]); $identifier = (string) $rec["taxon_id"] . "_" . str_replace(" ", "_", $path_parts["basename"]); if (in_array($identifier, $this->do_ids)) { continue; } else { $this->do_ids[] = $identifier; } $mr = new \eol_schema\MediaResource(); if ($reference_ids) { $mr->referenceID = implode("; ", $reference_ids); } if ($agent_ids) { $mr->agentID = implode("; ", $agent_ids); } $mr->taxonID = (string) $rec["taxon_id"]; $mr->identifier = $identifier; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->language = 'en'; $mr->format = (string) Functions::get_mimetype($media_url); $mr->furtherInformationURL = (string) $rec['url']; $mr->accessURI = (string) $media_url; $mr->Owner = ""; $mr->UsageTerms = "http://creativecommons.org/licenses/by-nc-sa/3.0/"; $mr->description = (string) $rec["caption"]; $this->archive_builder->write_object_to_file($mr); $this->create_instances_from_taxon_object($taxon, $rec, $reference_ids); } }
private function prepare_images($rec) { if ($mediaURLs = self::get_image_urls($rec)) { print "\n images: " . count($mediaURLs) . "\n"; foreach ($mediaURLs as $mediaURL) { /* not used for now $desc = ""; if($val = $rec["Locality"]) $desc .= "Locality: " . $val . "<br>"; if($val = $rec["Size"]) $desc .= "Size: " . $val . "<br>"; if($val = $rec["Book"]) $desc .= "Book: " . $val . "<br>"; if($val = $rec["Synonym"]) $desc .= "Synonym: " . $val . "<br>"; */ $mr = new \eol_schema\MediaResource(); $mr->taxonID = $rec["taxon_id"]; $mr->identifier = md5($mediaURL); $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->format = Functions::get_mimetype($mediaURL); $mr->Owner = "Femorale"; $mr->UsageTerms = "http://creativecommons.org/licenses/by-nc/3.0/"; $mr->accessURI = $mediaURL; $mr->furtherInformationURL = str_replace(" ", "%20", $rec["Expr1"]); if (!isset($this->object_ids[$mr->identifier])) { $this->archive_builder->write_object_to_file($mr); $this->object_ids[$mr->identifier] = ''; } } } }
private function process_records($records) { /* [257] => Array ( [img] => /caribbean/resources/img/images/species/3908_3406.jpg [url] => /caribbean/en/thefishes/species/3908 [sciname] => Xyrichtys novacula [vernacular] => Pearly razorfish ) */ foreach ($records as $contributor => $contributor_images) { foreach ($contributor_images as $rec) { if ($rec["sciname"]) { $taxon = new \eol_schema\Taxon(); $taxon->taxonID = str_replace(" ", "_", $rec["sciname"]); $taxon->scientificName = $rec["sciname"]; if ($val = $rec["url"]) { $taxon->furtherInformationURL = $this->domain . $val; } if (!isset($this->taxa[$taxon->taxonID])) { $this->taxa[$taxon->taxonID] = ''; $this->archive_builder->write_object_to_file($taxon); } } if ($rec["img"]) { $temp = pathinfo($rec["img"]); $identifier = $temp["filename"]; $agent_ids = self::process_agent($contributor); $mr = new \eol_schema\MediaResource(); if ($agent_ids) { $mr->agentID = implode("; ", $agent_ids); } $mr->taxonID = $taxon->taxonID; $mr->identifier = $identifier; $mr->type = 'http://purl.org/dc/dcmitype/StillImage'; $mr->format = Functions::get_mimetype($rec["img"]); if (preg_match("/_(.*?)\\./ims", $rec["img"], $arr)) { $mr->furtherInformationURL = $this->image_summary_page . $arr[1]; } $mr->UsageTerms = 'http://creativecommons.org/licenses/by-nc-sa/3.0/'; $mr->accessURI = $this->domain . $rec["img"]; $mr->Owner = $contributor; $mr->description = ''; $mr->publisher = ''; $mr->CVterm = ''; $mr->title = ''; $mr->spatial = ''; //this is 'location' in attribution in EOL's data_object page if (!isset($this->object_ids[$mr->identifier])) { $this->object_ids[$mr->identifier] = ''; $this->archive_builder->write_object_to_file($mr); } } } //inner loop } //outer loop }
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; }
private function get_images($description, $taxon_id, $media_id, $media_url, $reference_ids, $agent_ids) { $description = utf8_encode(self::remove_quotes($description)); if (in_array($media_id, $this->media_ids)) { return; } $this->media_ids[] = $media_id; $bibliographicCitation = false; if ($reference_ids = @$this->image_references[$media_id]) { $reference_ids = array_unique($reference_ids); $bibliographicCitation = self::get_citation($reference_ids); } $mr = new \eol_schema\MediaResource(); if ($reference_ids) { $mr->referenceID = implode("; ", $reference_ids); } if ($agent_ids) { $mr->agentID = implode("; ", $agent_ids); } $mr->taxonID = (string) $taxon_id; $mr->identifier = (string) $media_id; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->language = 'en'; $mr->format = Functions::get_mimetype($media_url); $mr->CVterm = ""; $mr->Owner = ""; $mr->rights = ""; $mr->title = ""; $mr->UsageTerms = "http://creativecommons.org/licenses/by-nc/3.0/"; $mr->audience = 'Everyone'; $mr->description = (string) $description; $mr->accessURI = $media_url; $mr->furtherInformationURL = $this->taxon_url . $taxon_id; if ($bibliographicCitation) { $mr->bibliographicCitation = $bibliographicCitation; } $this->archive_builder->write_object_to_file($mr); }
private function get_images($rec, $agent_ids, $reference_ids) { $texts = $rec['texts']; if (@$texts['map_caption'] && @$texts['map_image']) { $description = (string) utf8_encode($texts['map_caption']); $mediaURL = (string) utf8_encode($texts['map_image']); $dc_identifier = "map_" . $rec['taxonID']; if (trim($description) && trim($mediaURL)) { $mr = new \eol_schema\MediaResource(); if ($reference_ids) { $mr->referenceID = implode("; ", $reference_ids); } if ($agent_ids) { $mr->agentID = implode("; ", $agent_ids); } $mr->taxonID = (string) $rec['taxonID']; $mr->identifier = (string) $dc_identifier; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->language = 'en'; $mr->format = Functions::get_mimetype($mediaURL); $mr->furtherInformationURL = (string) self::clean_str(trim($rec['url'])); $mr->CVterm = ""; $mr->Owner = "IUCN/SSC Tortoise and Freshwater Turtle Specialist Group"; $mr->rights = "Copyright 2009 Chelonian Research Foundation"; $mr->title = "Distribution"; $mr->UsageTerms = "http://creativecommons.org/licenses/by-nc-sa/3.0/"; $mr->audience = 'Everyone'; $mr->description = (string) $description; $mr->subtype = "Map"; $mr->accessURI = $mediaURL; // $mr->bibliographicCitation = ''; $this->archive_builder->write_object_to_file($mr); } } }
private function process_record($rec) { $rec["sciname"] = self::valid_sciname($rec); if ($rec["sciname"]) { $taxon = new \eol_schema\Taxon(); $taxon->taxonID = str_replace(" ", "_", $rec["sciname"]); $taxon->scientificName = $rec["sciname"]; $taxon->furtherInformationURL = $rec["page"]; if (!isset($this->taxa[$taxon->taxonID])) { $this->taxa[$taxon->taxonID] = ''; $this->archive_builder->write_object_to_file($taxon); } } else { return; } if ($rec["src"]) { $agent_ids = self::process_agent(); $mr = new \eol_schema\MediaResource(); // if($reference_ids) $mr->referenceID = implode("; ", $reference_ids); //not used at the moment... if ($agent_ids) { $mr->agentID = implode("; ", $agent_ids); } $mr->taxonID = $taxon->taxonID; if ($rec["image_id"] == "258161") { $mr->taxonID .= ";" . str_replace(" ", "_", "Cistus creticus"); } elseif ($rec["image_id"] == "238990") { $mr->taxonID .= ";" . str_replace(" ", "_", "Euphorbia antilibanotica"); } elseif ($rec["image_id"] == "213710") { $mr->taxonID .= ";" . str_replace(" ", "_", "Ziziphora clinopodioides"); } elseif ($rec["image_id"] == "212647") { $mr->taxonID .= ";" . str_replace(" ", "_", "Melanargia galathea"); } elseif ($rec["image_id"] == "212559") { $mr->taxonID .= ";" . str_replace(" ", "_", "Galanthus"); } elseif ($rec["image_id"] == "120397") { $mr->taxonID .= ";" . str_replace(" ", "_", "Plantago ciliata"); } elseif ($rec["image_id"] == "48044") { $mr->taxonID .= ";" . str_replace(" ", "_", "Ixia sorrel"); } elseif ($rec["image_id"] == "231718") { $mr->taxonID .= ";" . str_replace(" ", "_", "Ranunculus asiaticus"); } $mr->identifier = $rec["image_id"]; $mr->type = 'http://purl.org/dc/dcmitype/StillImage'; $mr->format = Functions::get_mimetype($rec["src"]); $mr->furtherInformationURL = $rec["source"]; $mr->UsageTerms = 'http://creativecommons.org/licenses/by-nc-sa/3.0/'; $mr->accessURI = $rec["src"]; $mr->description = utf8_encode($rec["caption"]); $mr->Owner = ''; $mr->publisher = ''; $mr->CVterm = ''; $mr->title = ''; $mr->spatial = $rec["location"]; if (!isset($this->object_ids[$mr->identifier])) { $this->object_ids[$mr->identifier] = ''; $this->archive_builder->write_object_to_file($mr); } } }
private function process_images($rec, $url) { if ($html = self::get_html($url)) { // <img src="thb/11395a_thb.gif" alt="fig Calviria solaris"> $source_urls = self::get_source_urls($html); if (preg_match_all("/src=\"thb\\/(.*?)\"/ims", $html, $arr)) { // http://turbellaria.umaine.edu/gif/11397a.gif $index = 0; foreach ($arr[1] as $image) { // from: http://turbellaria.umaine.edu/thb/12223a_thb.gif to: http://turbellaria.umaine.edu/gif/12223a.gif $info = self::get_folder_of_image($image); $folder = $info["folder"]; $extension = $info["extension"]; if (!$folder) { // e.g <img src="thb/13158jpg_thb.158" alt="fig Kuma asilhas"> http://turbellaria.umaine.edu/turb3.php?action=2&code=13158&smk=0 if (is_numeric($extension)) { echo "\n [{$image}] \n"; $parts = explode(".", $image); $image = $parts[0]; $image = str_ireplace("jpg_thb", "_thb.jpg", $image); $image = str_ireplace("gif_thb", "_thb.gif", $image); $image = str_ireplace("png_thb", "_thb.png", $image); echo "\n [{$image}] \n"; $info = self::get_folder_of_image($image); $folder = $info["folder"]; $extension = $info["extension"]; if (!$folder) { echo "\n investigate no image 2 [{$url}][{$extension}] \n"; } } else { echo "\n investigate no image [{$url}][{$extension}] \n"; print_r($rec); continue; } } $mediaURL = $this->domain . $folder . str_ireplace("_thb", "", $image); $mr = new \eol_schema\MediaResource(); if ($this->agent_ids) { $mr->agentID = implode("; ", $this->agent_ids); } $mr->taxonID = (string) $rec["taxon_id"]; $mr->identifier = (string) $mediaURL; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->language = 'en'; $mr->format = Functions::get_mimetype($mediaURL); $mr->title = ""; $mr->CreateDate = ""; $mr->Owner = $this->rights_holder; $mr->rights = ""; $mr->UsageTerms = "http://creativecommons.org/licenses/by-nc-sa/3.0/"; $mr->audience = 'Everyone'; $mr->description = ""; $mr->accessURI = $mediaURL; if (@$source_urls[$index]) { $mr->furtherInformationURL = @$source_urls[$index]; } if (!in_array($mr->identifier, $this->object_ids)) { $this->object_ids[] = $mr->identifier; $this->archive_builder->write_object_to_file($mr); } $index++; } } } }
function prepare_species_page($taxon, $taxon_images, $taxon_comnames, $taxon_syn) { $arr_scraped = array(); $arr_photos = array(); $arr_sciname = array(); $taxon_id = $taxon["SId"]; $sciname = $taxon['GenusSpecies']; $agent = array(); $agent[] = array("role" => "project", "homepage" => "http://www.fishwisepro.com", "name" => "FishWise Professional"); $rights_holder = "FishWise Professional"; $mimeType = "text/html"; $dataType = "http://purl.org/dc/dcmitype/Text"; $mediaURL = ""; $reference = array(); $dc_source = FWP_SPECIES_PAGE_URL . $taxon['SId']; if (trim(@$taxon['DistributionT']) != "---") { $desc = $taxon['DistributionT']; $desc = utf8_decode($desc); $arr_texts[$sciname][] = self::fill_data_object($desc, "http://rs.tdwg.org/ontology/voc/SPMInfoItems#Distribution", "", $agent, $rights_holder, $mediaURL, $mimeType, $dataType, $dc_source); } if (trim(@$taxon['LengthMax']) > 0) { $desc = "Maximum size: {$taxon['LengthMax']} {$taxon['LengthMaxSuffix']} {$taxon['LengthMaxType']}"; $desc = utf8_decode($desc); $arr_texts[$sciname][] = self::fill_data_object($desc, "http://rs.tdwg.org/ontology/voc/SPMInfoItems#Size", "", $agent, $rights_holder, $mediaURL, $mimeType, $dataType, $dc_source); } if (trim(@$taxon['DepthRangeDeep']) > 0) { $desc = "Depth: {$taxon['DepthRangeShallow']} - {$taxon['DepthRangeDeep']}m. "; if (trim(@$taxon['DepthRange']) != "---") { $desc .= "<br>{$taxon['DepthRange']}"; } if (trim(@$taxon['Habitat']) != "---") { $desc .= "<br><br>Habitat: {$taxon['Habitat']}."; } if (trim(@$taxon['HabitatNotes']) != "---") { $desc .= " {$taxon['HabitatNotes']}"; } $desc = utf8_decode($desc); $arr_texts[$sciname][] = self::fill_data_object($desc, "http://rs.tdwg.org/ontology/voc/SPMInfoItems#Habitat", "", $agent, $rights_holder, $mediaURL, $mimeType, $dataType, $dc_source); } $arr_photos = array(); if ($arr = @$taxon_images) { foreach ($arr as $r) { if (trim(@$r['FileName']) != "---") { $path_info = pathinfo($r['FileName']); $extension = strtolower($path_info['extension']); $mediaURL = FWP_IMAGE_URL . "{$extension}/" . trim(@$r['FileName']); $mimeType = Functions::get_mimetype($mediaURL); $dataType = "http://purl.org/dc/dcmitype/StillImage"; $desc = ""; if (trim(@$r['LifeStage']) != "---") { $desc .= "Life stage: " . $r['LifeStage']; } if (trim(@$r['dbo_Picture_PictureNote']) != "---") { $desc .= "<br>Note: " . $r['dbo_Picture_PictureNote']; } if (trim(@$r['PictureType']) != "---") { $desc .= "<br>Type: " . $r['PictureType']; } if (trim(@$r['Location']) != "---") { $desc .= "<br>Location: " . $r['Location']; } $desc = utf8_decode(trim($desc)); $agent = array(); $agent[] = array("role" => "photographer", "homepage" => "", "name" => @$r['DisplayName']); $dc_source = FWP_IMAGE_PAGE_URL . "&SId=" . $r['SId'] . "&PictureId=" . $r['PictureId']; $arr_photos[$sciname][] = self::fill_data_object($desc, "", "", $agent, $rights_holder, $mediaURL, $mimeType, $dataType, $dc_source); } } } if (@$arr_texts[$sciname] || @$arr_photos[$sciname]) { $dc_source = FWP_SPECIES_PAGE_URL . $taxon['SId']; $arr_scraped[] = array("identifier" => "SId-" . $taxon['SId'], "kingdom" => "", "phylum" => "", "class" => "", "order" => $taxon['OrderName'], "family" => $taxon['Family'], "sciname" => $sciname, "dc_source" => $dc_source, "texts" => @$arr_texts[$sciname], "photos" => @$arr_photos[$sciname], "references" => $reference, "comnames" => $taxon_comnames, "synonyms" => $taxon_syn); } return $arr_scraped; }
private function create_media_object($rec, $type) { /* [source] => /accounts/Animalia/pictures/collections/contributors/james_dowlinghealey/Tibicencanicularis2/?start=18300 [cite] => Myers, P., R. Espinosa, C. S. Parr, T. Jones, G. S. Hammond, and T. A. Dewey. 2014. The Animal Diversity Web (online). Accessed at http://animaldiversity.org. [taxon] => Villosa iris [caption] => This map shows the watersheds of rivers in Michigan. Watersheds where this species has been found are colored yellow, those that this species is not recorded from are blue. The creation of this map was made possible by the Michigan Natural Heritage Small Grant Program, paid for by the Michigan Non-game Wildlife Fund. [subject] => Map :: Distribution [type] => Illustration [lifestage_gender][0] => Larva [contributors] => Renee Sherman Mulcrone (illustrator; copyright holder) [license] => <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"></a>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. [media] => /collections/contributors/mussel_distribution/Villosa_iris_map/large.jpg */ if (!isset($this->taxon_ids[$rec["taxon_id"]])) { $t = new \eol_schema\Taxon(); $t->taxonID = $rec["taxon_id"]; $t->scientificName = $rec["taxon"]; $t->furtherInformationURL = $this->domain . $rec["source"]; if ($ancestry = self::get_ancestry($rec["taxon_id"])) { foreach ($this->ranks as $rank) { if ($val = @$ancestry[$rank]) { $t->{$rank} = $val; } } } $this->archive_builder->write_object_to_file($t); $this->taxon_ids[$rec["taxon_id"]] = ''; } //start desc $desc = ""; if ($val = @$rec["caption"]) { $desc .= $val; } if ($val = @$rec["subject"]) { $desc .= "<br>Subject: " . $val; } if ($val = @$rec["type"]) { $desc .= "<br>Type: " . $val; } if ($vals = @$rec["lifestage_gender"]) { foreach ($vals as $val) { $desc .= "<br>Life Stages And Gender: " . $val; } } if ($vals = @$rec["anatomy"]) { foreach ($vals as $val) { $desc .= "<br>Anatomy: " . $val; } } if ($val = @$rec["date_taken"]) { $desc .= "<br>Date Taken: " . $val; } if ($val = @$rec["location"]) { $desc .= "<br>Location: " . $val; } if ($val = @$rec["contributors"]) { $desc .= "<br>Contributors: " . $val; } //start agents $agent_ids = array(); $agent_records = array(); if ($agent_info = self::create_agents(array(@$rec["contributors"]))) { $agent_ids = $agent_info["agent_ids"]; $agent_records = $agent_info["records"]; } /* illustrator; copyright holder photographer; copyright holder e.g. <dc:rights>Copyright Phil Myers</dc:rights> <dcterms:rightsHolder>Phil Myers</dcterms:rightsHolder> */ //start rights & rightsHolder $rights = ""; $rightsHolder = ""; $from_Phil_Myers = false; foreach ($agent_records as $agent_rec) { if (isset($this->agent_copyright_holders[$agent_rec["identifier"]])) { if (in_array($agent_rec["agent"], array("Phil Myers", "Philip Myers")) && in_array($agent_rec["role"], array("copyright holder", "copyright_holder"))) { $from_Phil_Myers = true; } $rights = "Copyright " . $agent_rec["agent"]; $rightsHolder = $agent_rec["agent"]; } } //start license if (!isset($rec["license"])) { if ($from_Phil_Myers) { $rec["license"] = "http://creativecommons.org/licenses/by-nc-sa/3.0/"; } else { echo "\n investigate: no license [{$type}]\n"; $this->debug["no license url"][$rec["source"]] = ''; print_r($rec); } } $license = ""; if (preg_match("/<a rel=\"license\" href=\"(.*?)\"/ims", @$rec["license"], $arr)) { $license = $arr[1]; } elseif (preg_match("/<a href=\"(.*?)\"/ims", @$rec["license"], $arr)) { $license = $arr[1]; } elseif ($val = @$rec["license"]) { $license = $val; } $license = self::format_string($license); if (!in_array($license, $this->valid_licenses)) { if ($attribution = self::further_check_license($license, $rightsHolder)) { $license = $attribution["license"]; $rights = $attribution["rights"]; $rightsHolder = $attribution["agent"]; } else { $this->debug["invalid license"]["{$license} [{$rightsHolder}]"] = ''; return; } } if (in_array($type, array("maps", "pictures"))) { $dataType = "http://purl.org/dc/dcmitype/StillImage"; /* /accounts/Animalia/pictures/collections/contributors/phil_myers/lepidoptera/Pieridae/Abaeis0791/ collections/contributors/phil_myers/lepidoptera/Pieridae/Abaeis0791 */ if (preg_match("/pictures\\/(.*?)_xxx/ims", $rec["source"] . "_xxx", $arr)) { $identifier = $arr[1]; } else { $identifier = $rec["source"]; } } elseif ($type == "sounds") { $dataType = "http://purl.org/dc/dcmitype/Sound"; /* /accounts/Animalia/sounds/collections/contributors/naturesongs/coopers1/ collections/contributors/naturesongs/coopers1 */ if (preg_match("/sounds\\/(.*?)\\/_xxx/ims", $rec["source"] . "_xxx", $arr)) { $identifier = $arr[1]; } else { $identifier = $rec["source"]; } } $rec["media"] = str_ireplace("/large.", "/medium.", $rec["media"]); /* collections/contributors/james_dowlinghealey/Macawblue3 collections/contributors/james_dowlinghealey/Macawblue3/?start=30 Ara_ararauna http://purl.org/dc/dcmitype/StillImage image/jpeg x http://animaldiversity.ummz.umich.edu/collections/contributors/james_dowlinghealey/Macawblue3/?start=30 en http://creativecommons.org/licenses/by-nc-sa/3.0/ Copyright James Dowling-Healey James Dowling-Healey Myers, P., R. Espinosa, C. S. Parr, T. Jones, G. S. Hammond, and T. A. Dewey. 2014. The Animal Diversity Web (online). Accessed at http://animaldiversity.org. 244633929999b7a4dde21d478182b47c; a8ae6a72a7c288902289f4a442f076cf http://animaldiversity.ummz.umich.edu/collections/contributors/james_dowlinghealey/Macawblue3/medium.jpg accounts/Animalia/pictures/collections/contributors/james_dowlinghealey/Macawblue3/?start=1560 Ara_ararauna http://purl.org/dc/dcmitype/StillImage image/jpeg x http://animaldiversity.ummz.umich.edu/accounts/Animalia/pictures/collections/contributors/james_dowlinghealey/Macawblue3/?start=1560 en http://creativecommons.org/licenses/by-nc-sa/3.0/ Copyright James Dowling-Healey James Dowling-Healey Myers, P., R. Espinosa, C. S. Parr, T. Jones, G. S. Hammond, and T. A. Dewey. 2014. The Animal Diversity Web (online). Accessed at http://animaldiversity.org. 244633929999b7a4dde21d478182b47c; a8ae6a72a7c288902289f4a442f076cf http://animaldiversity.ummz.umich.edu/collections/contributors/james_dowlinghealey/Macawblue3/medium.jpg */ $identifier = trim($identifier); $parts = pathinfo($identifier); $identifier = $parts["dirname"]; if (substr($identifier, -1) == "/") { $identifier = substr($identifier, 0, strlen($identifier) - 1); } if (substr($identifier, 0, 1) == "/") { $identifier = substr($identifier, 1, strlen($identifier)); } $identifier = trim($identifier); if (isset($this->object_ids[$identifier])) { return; } else { $this->object_ids[$identifier] = ''; } $mimeType = Functions::get_mimetype($rec["media"]); if (is_numeric(stripos($mimeType, 'video/'))) { $dataType = "http://purl.org/dc/dcmitype/MovingImage"; } $o = array("taxon_id" => $rec["taxon_id"], "identifier" => $identifier, "dataType" => $dataType, "source" => $this->domain . $rec["source"], "mimeType" => $mimeType, "subject" => "", "description" => $desc, "rights" => $rights, "rightsHolder" => $rightsHolder, "license" => $license, "bibliographicCitation" => $rec["cite"], "agent_ids" => $agent_ids, "mediaURL" => $this->domain . $rec["media"]); if ($type == "maps") { $o["subtype"] = "map"; } self::add_object($o); }
private function create_archive($rec) { $taxon = new \eol_schema\Taxon(); $taxon->taxonID = $rec['taxon_id']; $taxon->scientificName = utf8_encode($rec['sciname']); $taxon->furtherInformationURL = $rec['source']; $taxon->phylum = @$rec['ancestry']['phylum']; $taxon->class = @$rec['ancestry']['class']; $taxon->order = @$rec['ancestry']['order']; $taxon->family = @$rec['ancestry']['family']; if (!isset($this->taxon_ids[$taxon->taxonID])) { $this->archive_builder->write_object_to_file($taxon); $this->taxon_ids[$taxon->taxonID] = ''; } if (@$rec['comnames']) { self::generate_comnames($rec); } if (@$rec['synonyms']) { self::generate_synonyms($rec); } // for text objects $param = array("taxon_id" => $rec['taxon_id'], "source" => $rec['source'], "agent_ids" => self::generate_agent_ids($rec['editors'], 'editor')); if ($val = @$rec['txt']['desc']) { $param["identifier"] = $rec['taxon_id'] . "_desc"; $param["desc"] = $val; $param["subject"] = "http://rs.tdwg.org/ontology/voc/SPMInfoItems#Description"; $param["reference_ids"] = self::generate_reference_ids($rec['references']); self::generate_text_object($param); } $param["reference_ids"] = array(); if ($val = @$rec['txt']['lookalikes']) { $param["identifier"] = $rec['taxon_id'] . "_lookalikes"; $param["desc"] = "<b>How to Distinguish from Similar Species:</b> " . $val; $param["subject"] = "http://rs.tdwg.org/ontology/voc/SPMInfoItems#LookAlikes"; self::generate_text_object($param); } if ($val = @$rec['txt']['biology']) { $param["identifier"] = $rec['taxon_id'] . "_biology"; $param["desc"] = "<b>Biology/Natural History:</b> " . $val; $param["subject"] = "http://rs.tdwg.org/ontology/voc/SPMInfoItems#Biology"; self::generate_text_object($param); } if ($val = @$rec['txt']['habitat']) { $param["identifier"] = $rec['taxon_id'] . "_habitat"; $param["desc"] = $val; $param["subject"] = "http://rs.tdwg.org/ontology/voc/SPMInfoItems#Habitat"; self::generate_text_object($param); } if ($val = @$rec['txt']['distribution']) { $param["identifier"] = $rec['taxon_id'] . "_distribution"; $param["desc"] = "<b>Geographical Range:</b> " . $val; $param["subject"] = "http://rs.tdwg.org/ontology/voc/SPMInfoItems#Distribution"; self::generate_text_object($param); } if ($val = @$rec['txt']['depth range']) { $param["identifier"] = $rec['taxon_id'] . "_depth"; $param["desc"] = "<b>Depth Range:</b> " . $val; $param["subject"] = "http://rs.tdwg.org/ontology/voc/SPMInfoItems#Habitat"; self::generate_text_object($param); } // for image objects $param = array("taxon_id" => $rec['taxon_id'], "source" => $rec['source'], "type" => "http://purl.org/dc/dcmitype/StillImage"); foreach ($rec['images']['src'] as $src) { $rec['img'][] = array("src" => $src, "caption" => @$rec['images']['caption'], "agent" => @$rec['images']['agent']); } $rec['img'] = self::append_all_other_images($rec['all_images'], $rec['img']); if ($val = @$rec['img']) { foreach ($val as $i) { if ($param["identifier"] = $i['src']) { $param["desc"] = @$i['caption']; $param["mediaURL"] = pathinfo($param['source'], PATHINFO_DIRNAME) . "/" . $i['src']; $param["agent_ids"] = self::generate_agent_ids(array(@$i['agent']), 'photographer'); $param['format'] = Functions::get_mimetype($i['src']); self::generate_object($param); } } } }
private function create_images($description, $taxon_id, $media_id, $media_url, $reference_ids, $agent_ids, $source_url) { if (in_array($media_id, $this->media_ids)) { return; } $this->media_ids[] = $media_id; $mr = new \eol_schema\MediaResource(); if ($reference_ids) { $mr->referenceID = implode("; ", $reference_ids); } if ($agent_ids) { $mr->agentID = implode("; ", $agent_ids); } $mr->taxonID = (string) $taxon_id; $mr->identifier = (string) $media_id; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; $mr->language = 'en'; $mr->format = Functions::get_mimetype($media_url); $mr->CVterm = ""; $mr->rights = ""; $mr->Owner = "Animal Demography Unit " . date("Y") . ". Department of Biological Sciences - University of Cape Town"; $mr->title = ""; $mr->UsageTerms = "http://creativecommons.org/licenses/by-nc-sa/3.0/"; $mr->description = (string) $description; $mr->accessURI = $media_url; $mr->furtherInformationURL = $source_url; $this->archive_builder->write_object_to_file($mr); }
public static function get_data_objects($photo, $user_id) { $data_objects = array(); $data_object_parameters = array(); $data_object_parameters["identifier"] = $photo->id; $data_object_parameters["dataType"] = "http://purl.org/dc/dcmitype/StillImage"; $data_object_parameters["mimeType"] = Functions::get_mimetype($photo->originalformat, true); $data_object_parameters["title"] = $photo->title->_content; $data_object_parameters["description"] = $photo->description->_content; $data_object_parameters["mediaURL"] = self::photo_url($photo->id, $photo->secret, $photo->server, $photo->farm); $data_object_parameters["license"] = @$GLOBALS["flickr_licenses"][$photo->license]; $data_object_parameters["language"] = 'en'; if (isset($photo->dates->taken)) { $data_object_parameters["created"] = $photo->dates->taken; } // only the original forms need rotation if (isset($photo->rotation) && $photo->rotation && preg_match("/_o\\./", $data_object_parameters["mediaURL"])) { $data_object_parameters["additionalInformation"] = '<rotation>' . $photo->rotation . '</rotation>'; } foreach ($photo->urls->url as $url) { if ($url->type == "photopage") { $data_object_parameters["source"] = $url->_content; } } $agent_parameters = array(); if (trim($photo->owner->realname) != "") { $agent_parameters["fullName"] = $photo->owner->realname; } else { $agent_parameters["fullName"] = $photo->owner->username; } $agent_parameters["homepage"] = "http://www.flickr.com/photos/" . $photo->owner->nsid; $agent_parameters["role"] = "photographer"; if ($user_id == FLICKR_SMITHSONIAN_ID) { $data_object_parameters["rightsHolder"] = "Smithsonian Wild"; } else { $data_object_parameters["rightsHolder"] = $agent_parameters["fullName"]; } $data_object_parameters["agents"] = array(); $data_object_parameters["agents"][] = new \SchemaAgent($agent_parameters); if (@($photo->geoperms->ispublic = 1)) { $geo_point_parameters = array(); if (isset($photo->location->latitude)) { $geo_point_parameters["latitude"] = $photo->location->latitude; } if (isset($photo->location->longitude)) { $geo_point_parameters["longitude"] = $photo->location->longitude; } if ($geo_point_parameters) { $data_object_parameters["point"] = new \SchemaPoint($geo_point_parameters); } $locations = array(); if (isset($photo->location->locality->_content)) { $locations[0] = $photo->location->locality->_content; } if (isset($photo->location->region->_content)) { $locations[1] = $photo->location->region->_content; } if (isset($photo->location->country->_content)) { $locations[2] = $photo->location->country->_content; } if ($locations) { $data_object_parameters["location"] = implode(", ", $locations); } } // If the media type is video, there should be a Video Player type linking to the video // move the image into the thumbnail and video into mediaURL if ($photo->media == "video") { debug("getting sizes for id: " . $photo->id . "\n"); $data_object_parameters["thumbnailURL"] = $data_object_parameters["mediaURL"]; $data_object_parameters["mediaURL"] = NULL; if ($file_json_object = self::check_cache('photosGetSizes', $photo->id)) { $sizes = $file_json_object; } else { $sizes = self::photos_get_sizes($photo->id); } if (@$sizes) { foreach ($sizes->sizes->size as $size) { if ($size->label == "Video Player") { $data_object_parameters["identifier"] .= "_video"; $data_object_parameters["dataType"] = "http://purl.org/dc/dcmitype/MovingImage"; $data_object_parameters["mimeType"] = "video/x-flv"; $data_object_parameters["mediaURL"] = $size->source; $data_objects[] = new \SchemaDataObject($data_object_parameters); } } } } else { // if its not a video, its an image so add it to the list $data_objects[] = new \SchemaDataObject($data_object_parameters); } return $data_objects; }
private function get_objects($taxon, $records, $type) { foreach ($records as $rec) { $mr = new \eol_schema\MediaResource(); if ($type == "text") { $mr->type = 'http://purl.org/dc/dcmitype/Text'; $mr->format = 'text/html'; $mr->CVterm = $rec["subject"]; $mr->bibliographicCitation = "Australian Institute of Marine Science, (" . date("Y") . "). AIMS Coral Fact Sheets - " . $taxon["sciname"] . ". Viewed " . date("d M Y") . ". http://coral.aims.gov.au/factsheet.jsp?speciesCode=" . $taxon["taxon_id"]; } elseif ($type == "image") { $mr->type = 'http://purl.org/dc/dcmitype/StillImage'; $mr->format = Functions::get_mimetype($rec["media_url"]); $mr->accessURI = $rec["media_url"]; $mr->title = ""; } $mr->taxonID = $taxon["taxon_id"]; $mr->identifier = $rec["identifier"]; $mr->language = 'en'; $mr->furtherInformationURL = $this->domain . $taxon["source"]; $mr->description = $rec["description"]; $mr->UsageTerms = 'http://creativecommons.org/licenses/by-nc/3.0/'; $mr->Owner = @$rec["photographer"] ? $rec["photographer"] : "Australian Institute of Marine Science"; if ($val = @$rec["photographer"]) { $agent_ids = self::create_agent($val); if ($agent_ids) { $mr->agentID = implode("; ", $agent_ids); } } if (!isset($this->object_ids[$mr->identifier])) { $this->object_ids[$mr->identifier] = 1; $this->archive_builder->write_object_to_file($mr); } } }
private function create_data_object($rec) { if (in_array($rec["media_id"], $this->media_ids)) { return; } $this->media_ids[] = $rec["media_id"]; $mr = new \eol_schema\MediaResource(); if (@$rec["reference_ids"]) { $mr->referenceID = implode("; ", $rec["reference_ids"]); } if (@$rec["agent_ids"]) { $mr->agentID = implode("; ", $rec["agent_ids"]); } $mr->taxonID = (string) $rec["taxon_id"]; $mr->identifier = (string) $rec["media_id"]; $mr->language = 'en'; if (@$rec["media_url"]) { $mr->accessURI = $rec["media_url"]; $mr->type = "http://purl.org/dc/dcmitype/StillImage"; if ($val = Functions::get_mimetype($rec["media_url"])) { $mr->format = $val; } else { $mr->format = "image/jpeg"; } } elseif ($val = @$rec["sound_url"]) { $mr->accessURI = $val; $mr->type = "http://purl.org/dc/dcmitype/Sound"; $mr->format = Functions::get_mimetype($val); } else { $mr->type = "http://purl.org/dc/dcmitype/Text"; $mr->format = "text/html"; $mr->CVterm = "http://www.eol.org/voc/table_of_contents#TypeInformation"; if (!$rec["description"]) { return; } } $mr->subtype = @$rec["subtype"]; $mr->bibliographicCitation = @$rec["citation"]; // $mr->rights = @$rec["rights_statement"]; if (@$rec["rights_statement"]) { $mr->Owner = @$rec["rights_statement"]; } else { $mr->Owner = ucfirst($rec["group"]["name"]) . " Species File Online " . date("Y") . "."; } if ($val = @$rec["title"]) { $mr->title = $val; } if ($license = self::valid_license($rec)) { $mr->UsageTerms = $license; } else { echo "\ninvalid license\n"; print_r($rec); exit; } $mr->description = (string) $rec["description"]; $mr->furtherInformationURL = @$rec["source_url"]; $this->archive_builder->write_object_to_file($mr); }